qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,151,045 | <p>I have a huge amount of data where I have a column with multiple products and two signals "ID" & "Value". The signal "ID" increases from 1-40 several times a day. For each ID I have a value. In this example the data comes in 3 Hz and I only write down the IDs from 1-3 to make the table not to long.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Product</th>
<th>Date</th>
<th>ID</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>20.10.2021T20:01:01</td>
<td>1</td>
<td>32</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:01</td>
<td>1</td>
<td>32</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:01</td>
<td>1</td>
<td>32</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:03</td>
<td>3</td>
<td>52</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:03</td>
<td>3</td>
<td>52</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:04</td>
<td>1</td>
<td>32</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:04</td>
<td>1</td>
<td>32</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:04</td>
<td>1</td>
<td>32</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:05</td>
<td>2</td>
<td>40</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:05</td>
<td>2</td>
<td>40</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:06</td>
<td>3</td>
<td>52</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:06</td>
<td>1</td>
<td>20</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:06</td>
<td>1</td>
<td>20</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:06</td>
<td>1</td>
<td>20</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:07</td>
<td>2</td>
<td>68</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:07</td>
<td>2</td>
<td>68</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:07</td>
<td>2</td>
<td>68</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:08</td>
<td>3</td>
<td>41</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:08</td>
<td>3</td>
<td>41</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:08</td>
<td>3</td>
<td>41</td>
</tr>
<tr>
<td>B</td>
<td>20.12.2021T16:12:09</td>
<td>1</td>
<td>20</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:11</td>
<td>3</td>
<td>41</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:11</td>
<td>3</td>
<td>41</td>
</tr>
</tbody>
</table>
</div>
<p>The problem is that in some parts of the data the signal is not recorded or I get garbage entries. Therefore I only want the first data per day where it seems plausible. It should look something like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Product</th>
<th>Date</th>
<th>ID</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>20.10.2021T20:01:04</td>
<td>1</td>
<td>32</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:05</td>
<td>2</td>
<td>40</td>
</tr>
<tr>
<td>A</td>
<td>20.10.2021T20:01:06</td>
<td>3</td>
<td>52</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:06</td>
<td>1</td>
<td>20</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:07</td>
<td>2</td>
<td>68</td>
</tr>
<tr>
<td>B</td>
<td>20.10.2021T16:12:08</td>
<td>3</td>
<td>41</td>
</tr>
</tbody>
</table>
</div>
<p>Regarding the data size that I have I'm also looking for an effcient way to solve this problem.</p>
| [
{
"answer_id": 74151810,
"author": "cyberbrain",
"author_id": 2846138,
"author_profile": "https://Stackoverflow.com/users/2846138",
"pm_score": 0,
"selected": false,
"text": "import module namespace json = \"http://marklogic.com/xdmp/json\"\n at \"/MarkLogic/json/json.xqy\";\n\n\nlet ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18276297/"
] |
74,151,052 | <p>I keep trying to center my grid container (main) vertically but won't move. Tried with align-items and still won't move.
Can anyone help me, please?</p>
<p>HTML:</p>
<pre><code><body>
<main>
<img
src="images/image-qr-code.png"
width="250px"
height="auto"
alt="Photo of QR Code"
/>
<h1>Improve your front-end skills by building projects</h1>
<p>
Scan the QR code to visit Frontend Mentor and take your coding skills to
the next level
</p>
</main>
</code></pre>
<p>CSS:</p>
<pre><code>* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
width: 1440px;
height: 900px;
font-family: "Outfit", sans-serif;
background-color: hsl(212, 45%, 89%);
}
main {
display: grid;
grid-template-columns: 250px;
background-color: white;
border-radius: 10px;
width: 300px;
height: 500px;
justify-content: center;
margin: auto;
}
</code></pre>
| [
{
"answer_id": 74151810,
"author": "cyberbrain",
"author_id": 2846138,
"author_profile": "https://Stackoverflow.com/users/2846138",
"pm_score": 0,
"selected": false,
"text": "import module namespace json = \"http://marklogic.com/xdmp/json\"\n at \"/MarkLogic/json/json.xqy\";\n\n\nlet ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299250/"
] |
74,151,072 | <p>I'm trying to use a many to many field in order to add a set of facilities to a lead.
The trouble is that i need an extra field for the date and time of the tour scheduled for each of the facilities i add to the lead.
So when i create a lead and add facilities to the lead i have that extra field where i can enter date and time and access it afterwards as a list of facilities with their tour dates on the leads page.</p>
<p>I came across many to many fields using "through" but I'm not sure if that's even the right option to use in this case. <a href="https://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships" rel="nofollow noreferrer">ManyToMany Fields with extra fields</a></p>
<p>How can i use a many to many field using "through" and have the through field automatically be generated for each facility i add to my lead with the many to many field? Or is using through not a good option?</p>
<p>I'm using Django Rest Framework with a React Frontend:</p>
<p>models.py</p>
<pre><code>class Facility(models.Model):
Name = models.CharField(max_length=150, null=True, blank=False)
mainimage = models.ImageField(null=True, blank=True)
Email = models.EmailField(max_length=150, null=True, blank=True)
TelephoneNumber = models.CharField(max_length=30, null=True, blank=True)
FacilityDescription = models.TextField(max_length=1000, null=True, blank=True)
def __str__(self):
return self.Name
class Lead(models.Model):
assigned_facilities = models.ManyToManyField(Facility, related_name='assigned_facilities', null=True, blank=True)
first_name = models.CharField(max_length=40, null=True, blank=True)
last_name = models.CharField(max_length=40, null=True, blank=True)
def __str__(self):
return f"{self.first_name} {self.last_name}"
</code></pre>
<p>serializers.py</p>
<pre><code>class LeadUpdateSerializer(serializers.ModelSerializer):
is_owner = serializers.SerializerMethodField()
class Meta:
model = Lead
fields = (
"id",
"first_name",
"last_name",
"assigned_facilities",
)
read_only_fields = ("id")
def get_is_owner(self, obj):
user = self.context["request"].user
return obj.agent == user
</code></pre>
<p>Leads.js</p>
<pre><code> const cpBoard = useSelector((state) => state.cpBoard);
const facilityIds = (cpBoard.cpBoardItems?.map(cpBoardItem => (cpBoardItem.id)));
function submitFacilities() {
axios.patch(API.leads.update(id), { "assigned_facilities": facilityIds}, {
headers: {
"Authorization": `Bearer ${accessToken}`,
'Accept' : 'application/json',
},
withCredentials: true,
})
.then(res => {
fetchLeads()
})
.finally(() => {
})
}
</code></pre>
<h1>UPDATE:</h1>
<p>I'm currently trying to use the solution suggested below but i'm getting an error when i try to update a lead:</p>
<pre><code>AttributeError: 'NoneType' object has no attribute 'scheduled_datetime' File "/serializers.py", line 253, in to_representation ret["scheduled_datetime"] = str(instance.leadfacilityassociation.first().scheduled_datetime)
</code></pre>
<p>models.py</p>
<pre><code>class Facility(models.Model):
name = models.CharField(max_length=150, null=True, blank=False)
main_image = models.ImageField(null=True, blank=True)
email = models.EmailField(max_length=150, null=True, blank=True)
telephone_number = models.CharField(max_length=30, null=True, blank=True)
facility_description = models.TextField(max_length=1000, null=True, blank=True)
def __str__(self):
return self.Name
class Lead(models.Model):
first_name = models.CharField(max_length=40, null=True, blank=True)
last_name = models.CharField(max_length=40, null=True, blank=True)
def __str__(self):
return f"{self.first_name} {self.last_name}"
class LeadFacilityAssociation(models.Model):
assigned_facilities = models.ForeignKey(Facility, related_name='leadfacilityassociation')
lead = models.ForeignKey(Lead, related_name='leadfacilityassociation')
scheduled_datetime = models.DateTimeField(null=True, blank=True)
</code></pre>
<p>serializers.py</p>
<pre><code>class LeadUpdateSerializer(serializers.ModelSerializer):
is_owner = serializers.SerializerMethodField()
assigned_facilities = serializers.Integer(required=True)
scheduled_datetime = serializers.DateTimeField(required=True)
class Meta:
model = Lead
fields = (
"id",
"first_name",
"last_name",
"assigned_facilities",
"scheduled_datetime",
)
read_only_fields = ("id")
def get_is_owner(self, obj):
user = self.context["request"].user
return obj.agent == user
def create(self, validated_data):
assigned_facilities = validated_data.pop("assigned_facilities")
scheduled_datetime = validated_data.pop("scheduled_datetime")
instance = Lead.objects.create(**validated_data)
instance.leadfacilityassociation.create(assigned_facilities=assigned_facilities,scheduled_datetime=scheduled_datetime)
return instance
def to_representation(self, instance):
ret = super().to_representation(instance)
ret["scheduled_datetime"] = str(instance.leadfacilityassociation.first().scheduled_datetime)
ret["assigned_facilities"] = instance.leadfacilityassociation.first().assigned_facilities
return ret
</code></pre>
| [
{
"answer_id": 74153153,
"author": "Alombaros",
"author_id": 20263044,
"author_profile": "https://Stackoverflow.com/users/20263044",
"pm_score": 2,
"selected": false,
"text": "LeadFacility(models.Model):\n facility = models.ForeignKey(Facility, on_delete=models.CASCADE)\n lead = mo... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3530084/"
] |
74,151,106 | <p>I want to replace lines that start with G0 and G1 in a list; from G0 and G1 from another list. And doing this without changing anything else in the list.</p>
<pre><code>List1= ['G1 F2400 X101.031 Y24512.91 E769.44645', 'G0 F2400
X48501.031 Y112.91 E769.44645', 'G1 F2400 X5801.031 Y112.91
E769.44645','G0 F2400 X7801.031 Y112.91 E769.44645', 'G1 F2400
X1451.031 Y1452.91 E769.44645', 'G0 F2400 X101.031 Y112.91
E769.44645', 'G1 F2400 X101.031 Y112.91 E769.44645',] List2=['G1
X100 Y200 Z0', 'M205 E20', 'M204 E20', 'G0 X150 Y100']
List2=['G1 F2400 X101.031 Y112.91 E769.44645',
'M204 S5000',
'M205 X30 Y30',
'G0 F15000 X101.29 Y112.675',
'M204 S500',
'M205 X5 Y5',
'G1 F2400 X100.906 Y112.291 E769.46135',
'M204 S5000',
'M205 X30 Y30',
'G0 F15000 X101.163 Y112.053',
'M204 S500',
'M205 X5 Y5',
'G1 F2400 X101.545 Y112.434 E769.47615',
'M204 S5000',
'M205 X30 Y30',
'G0 F15000 X101.797 Y112.191',
'M204 S500',
'M205 X5 Y5',
'G1 F2400 X101.422 Y111.816 E769.49069']
</code></pre>
<h1>Then after the for loop the given list should be the result</h1>
<pre><code>TheListIWant=['G1 F2400 X101.031 Y24512.91 E769.44645',
'M204 S5000',
'M205 X30 Y30',
'G0 F2400 X48501.031 Y112.91 E769.44645',
'M204 S500',
'M205 X5 Y5',
'G1 F2400 X5801.031 Y112.91 E769.44645',
'M204 S5000',
'M205 X30 Y30',
'G0 F2400 X7801.031 Y112.91 E769.44645',
'M204 S500',
'M205 X5 Y5',
'G1 F2400 X1451.031 Y1452.91 E769.44645',
'M204 S5000',
'M205 X30 Y30',
'G0 F2400 X101.031 Y112.91 E769.44645',
'M204 S500',
'M205 X5 Y5',
'G1 F2400 X101.031 Y112.91 E769.44645']
theReplacement=[]
for i, x in enumerate(List2):
if (x.startswith("G1") or x.startswith("G0")):
theReplacement.append(x.replace((List2[i], y for y in List1)
</code></pre>
| [
{
"answer_id": 74151189,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 1,
"selected": false,
"text": "List1 = ['G1 F2400 X101.031 Y112.91 E769.44645', 'M204 S5000', 'M205 X30 Y30', 'G0 F15000 X101.29 Y112.675',\n ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20207332/"
] |
74,151,115 | <pre><code>class Config() {
var items = HashMap<String, Int>()
items.put("D", 1000)
items["A"] = 10
items["B"] = 20
items["C"] = 30
</code></pre>
<p>}</p>
<p>I think there is no problem, But the error happend "expecting member declaration"
How can I dodge that error</p>
| [
{
"answer_id": 74151189,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 1,
"selected": false,
"text": "List1 = ['G1 F2400 X101.031 Y112.91 E769.44645', 'M204 S5000', 'M205 X30 Y30', 'G0 F15000 X101.29 Y112.675',\n ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20297399/"
] |
74,151,219 | <p>I have a text file with this structure:</p>
<pre><code>- ASDF : |a=1|b=1|c=1|d=1
- QWER : |b=2|e=2|f=2
- ZXCV : |a=3|c=3|e=3|f=3|g=3
- TREW : |a=4|b=4|g=4
</code></pre>
<p>and I'd like to create a dataframe like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>index</th>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>
<th>F</th>
<th>G</th>
</tr>
</thead>
<tbody>
<tr>
<td>ASDF</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>NaN</td>
<td>NaN</td>
<td>NaN</td>
</tr>
<tr>
<td>QWER</td>
<td>NaN</td>
<td>2</td>
<td>NaN</td>
<td>NaN</td>
<td>NaN</td>
<td>2</td>
<td>NaN</td>
</tr>
<tr>
<td>ZXCV</td>
<td>3</td>
<td>NaN</td>
<td>3</td>
<td>NaN</td>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>TREW</td>
<td>4</td>
<td>4</td>
<td>NaN</td>
<td>NaN</td>
<td>NaN</td>
<td>NaN</td>
<td>4</td>
</tr>
</tbody>
</table>
</div>
<p>which solution could I implement? consider that I don't know in advance how many rows I have, nor the number or name of the tags.
thank you all in advance!</p>
| [
{
"answer_id": 74151292,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "read_csv"
},
{
"answer_id": 74151336,
"author": "mozway",
"author_id": 16343464,
"author_profile"... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11497899/"
] |
74,151,237 | <p>How do i can remove the "John Doo" text in this block and then add some html content?</p>
<pre><code><label><input type="radio" name="field-value-1359303" value="Joe Doe">Joe Doe</label>
</code></pre>
<p>My "solution"</p>
<pre><code>$('input[value="Joe Doe"]')
.hide()
.parents('label')
????
.append('<div>my content</div>');
</code></pre>
<p>The end result should be as follows:</p>
<pre><code><label><input type="radio" name="field-value-1359303" value="Joe Doe"><div>my content</div></label>
</code></pre>
| [
{
"answer_id": 74151292,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "read_csv"
},
{
"answer_id": 74151336,
"author": "mozway",
"author_id": 16343464,
"author_profile"... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5919943/"
] |
74,151,242 | <p>When I change a project's target framework from .NET Core 5 to .NET Core 6, the following code throws an exception, and it cannot be compiled.</p>
<pre><code>if (Database.IsMySql())
{
modelBuilder.MutableEntities()
.Where(entity => entity.GetProperties().Any(DatabaseHelper.HasGeneratedTimestamp))
.ForEach(entity =>
{
var properties = entity.GetProperties().Where(DatabaseHelper.HasGeneratedTimestamp);
var table = entity.GetTableName();
var key = (entity.FindPrimaryKey() ?? throw new InvalidOperationException($"primary key not defined on {table}"))
.Properties
.Select(property => property.Name)
.Apply(columns => columns.Count() > 1 ? $"({columns.Join(", ")})" : columns.First());
properties.Where(DatabaseHelper.IsOnInsert).ForEach(property =>
{
// property.SetDefaultValue(DateTimeOffset.Now);
});
properties.Where(DatabaseHelper.IsOnUpdate).ForEach(property =>
{
// // property.SetDefaultValue(DateTimeOffset.Now);
// if (property.ValueGenerated == ValueGenerated.OnAddOrUpdate)
// property.SetDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP");
});
});
}
</code></pre>
<p>Where <code>Any(DatabaseHelper.HasGeneratedTimestamp)</code> throws the following error:</p>
<blockquote>
<p>Cannot convert from 'method group' to 'Func<IMutableProperty, bool></p>
</blockquote>
<p><a href="https://i.stack.imgur.com/uDh5r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uDh5r.png" alt="The intellisense of Any()" /></a></p>
<p>How can I fix this error? Do any packages need to be updated?</p>
| [
{
"answer_id": 74151292,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "read_csv"
},
{
"answer_id": 74151336,
"author": "mozway",
"author_id": 16343464,
"author_profile"... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4160965/"
] |
74,151,265 | <p>I'm trying to increase the height of an SVG path (the border) and I'm getting the problem that the border gets hidden, only grows to down direction (not up) and the rounded corners get stretched. If I do the scale with the whole SVG also the icon inside get stretched and I want a uniform grow for that icon. I think using a div for that box is not a solution either because I would like the whole composition get resized to fill the space responsively.</p>
<p>Any solution?</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>#box{
position:absolute;
left: 80px;
}
#t-shirt{
position: absolute;
left:0;
top: 25%;
}
#t-shirt:hover {
transform: scale(1,1.2);
}
#pants{
position: absolute;
left: 160px;
top: 25%;
}
#pants:hover #pants-border{
transform: scale(1,1.2);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><svg id="box" width="315" height="341" viewBox="0 0 315 341" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="10.5" y="9.5" width="304" height="331" rx="19.5" fill="#242420" stroke="#242420"/>
<rect x="0.5" y="0.5" width="304" height="331" rx="19.5" fill="#D9D9D9" stroke="#242420"/>
<circle cx="23" cy="20" r="6.5" fill="#C9C9C9" stroke="#242420"/>
<circle cx="47" cy="20" r="6.5" fill="#C9C9C9" stroke="#242420"/>
<circle cx="71" cy="20" r="6.5" fill="#C9C9C9" stroke="#242420"/>
</svg>
<svg id="t-shirt" width="147" height="147" viewBox="0 0 147 147" fill="none" xmlns="http://www.w3.org/2000/svg">
<path height="200" d="M19.3522 0.706462H126.757C137.178 0.706462 145.626 9.15414 145.626 19.5749V126.98C145.626 137.4 137.178 145.848 126.757 145.848H19.3522C8.93148 145.848 0.483806 137.4 0.483806 126.98V19.5749C0.483806 9.15414 8.93149 0.706462 19.3522 0.706462Z" fill="#EBEBEB" stroke="#242420" stroke-width="0.967611"/>
<path d="M112.243 116.336H34.834L35.0547 113.12L35.2341 110.749L35.441 107.977L35.6066 105.579L35.8135 102.806L35.9928 100.408L36.1998 97.6353L36.3653 95.2648L41.1525 29.251H53.8172C53.9529 34.4014 56.0844 39.295 59.7577 42.8896C63.431 46.4841 68.3559 48.4956 73.4833 48.4956C78.6106 48.4956 83.5354 46.4841 87.2087 42.8896C90.882 39.295 93.0136 34.4014 93.1493 29.251H105.869L110.643 95.2648L110.822 97.6353L111.029 100.408L111.194 102.806L111.401 105.579L111.581 107.977L111.788 110.749L111.953 113.12L112.243 116.336Z" fill="#D9D9D9"/>
<path d="M37.7369 29.251L13.5466 58.7078L34.2872 75.6963L37.7369 29.251Z" fill="#d9d9d9"/>
<path d="M109.34 29.251L133.53 58.7078L112.776 75.6963L109.34 29.251Z" fill="#D9D9D9"/>
</svg>
<svg id="pants" width="148" height="147" viewBox="0 0 148 147" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="pants-border" d="M19.8137 0.706462H128.186C138.607 0.706462 147.055 9.15414 147.055 19.5749V126.98C147.055 137.4 138.607 145.848 128.186 145.848H19.8136C9.39288 145.848 0.945231 137.4 0.945231 126.98V19.5749C0.945231 9.15414 9.39291 0.706462 19.8137 0.706462Z" fill="#EBEBEB" stroke="#242420" stroke-width="0.967611"/>
<path d="M103.028 12.8018V19.575L74 19.5611V19.575H44.9717V12.8018H103.028Z" fill="#DADADA"/>
<path d="M94.3198 24.4131H103.028V33.1216C94.465 32.713 94.3198 24.4131 94.3198 24.4131Z" fill="#DADADA"/>
<path d="M103.028 38.4122V132.786H80.6181L74.021 45.4874L67.382 132.786H44.9717V38.4122C48.7254 37.779 57.6755 35.1361 57.6755 24.4131H71.5839C71.5839 31.7636 71.3738 38.1781 73.993 38.2607C76.6262 38.2607 76.4161 31.7636 76.4161 24.4131H90.3385C90.3245 35.1361 99.2746 37.779 103.028 38.4122Z" fill="#DADADA"/>
<path d="M44.9717 33.1216V24.4131H53.6802C53.6802 24.4131 53.5205 32.713 44.9717 33.1216Z" fill="#DADADA"/>
</svg></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74151562,
"author": "n--",
"author_id": 13993967,
"author_profile": "https://Stackoverflow.com/users/13993967",
"pm_score": 1,
"selected": false,
"text": "center"
},
{
"answer_id": 74153419,
"author": "herrstrietzel",
"author_id": 15015675,
"author_prof... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14399649/"
] |
74,151,271 | <p>I have a PostgreSQL instance running on Cloud SQL in GCP. I am connecting to it via a psql client from another machine. The connection is working fine.</p>
<p>However I want to know what happens when you run the following command.</p>
<p>Cloud SQL already uses SCRAM-SHA-256 as a password encryption mechanism by default. I have verified it. So I don't know what this command is doing.</p>
<blockquote>
<p>CREATE ROLE temprole NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN
NOREPLICATION NOBYPASSRLS PASSWORD
'SCRAM-SHA-256$4096:H45+UIZiJUcEXrB9SHlv5Q==$I0mc87UotsrnezRKv9Ijqn/zjWMGPVdy1zHPARAGfVs=:nSjwT9LGDmAsMo+GqbmC2X/9LMgowTQBjUQsl45gZzA=';</p>
</blockquote>
<p>Is the string inside <code>' '</code> set as password? If not, then what is it?</p>
<p>Secondly, how do I login as the <code>temprole</code> user? Do I need to set the password for it again?</p>
| [
{
"answer_id": 74151448,
"author": "Laurenz Albe",
"author_id": 6464308,
"author_profile": "https://Stackoverflow.com/users/6464308",
"pm_score": 3,
"selected": true,
"text": "password_encryption"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20109510/"
] |
74,151,300 | <p>I'm trying to plot a multi-equation ODE from <a href="https://escholarship.org/uc/item/2cz4q2jq" rel="nofollow noreferrer">this paper</a> and I'm having trouble figuring out how to express the dependencies between the functions. I.e, in <strong>3.1</strong>, it uses both <strong>z1</strong> and <strong>z2</strong>. Aswell as using its own precious state <strong>x</strong>. I've checked the Scipy documentation but they don't seem to express the functionality that I'm trying to achieve.</p>
<p>How do I express I.e equation <strong>3.1</strong> with Scipy?</p>
<p><a href="https://i.stack.imgur.com/ebtWV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ebtWV.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74151448,
"author": "Laurenz Albe",
"author_id": 6464308,
"author_profile": "https://Stackoverflow.com/users/6464308",
"pm_score": 3,
"selected": true,
"text": "password_encryption"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12463908/"
] |
74,151,312 | <p>On multiple environments of the app which we are testing, the ID of one element is different. I have this div ID</p>
<p><strong>CoredataForm:sec2_natural:grid1:left_section_natural:profession:selectProfession</strong>_auto_complete_force:<strong>ajax</strong></p>
<p>Bold marked parts of the id, is the part which is same for all the environments.</p>
<p>How should I write xpath expression which would fit to all of them?
I used this</p>
<pre><code>xpath="//div[starts-with(@id,'CoredataForm:sec2_natural:grid1:left_section_natural:profession:selectProfession') and ends-with(@id,'ajax')]"
</code></pre>
<p>but it doesn't work. Maybe another question: how can I use <code>contains()</code> function with multiple wildcards?</p>
| [
{
"answer_id": 74152593,
"author": "JaSON",
"author_id": 10682289,
"author_profile": "https://Stackoverflow.com/users/10682289",
"pm_score": 3,
"selected": true,
"text": "fn:ends-with"
},
{
"answer_id": 74153918,
"author": "Conal Tuohy",
"author_id": 7372462,
"author_... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19189121/"
] |
74,151,314 | <p>I have problems getting useState behave correctly.</p>
<p>I want to hide or show a sub element dependent of a calculation which is dependant on the previous state.</p>
<p>When I run it like this, it causes an infinite re-render:</p>
<pre><code>export function PersonWidget(props: Props) {
const store = useTableState();
const [positionsVorschlagVisible, setPositionsVorschlagVisible] = React.useState(false);
var positionsVorschlag = calculatePositionsvorschlag(
convertTokenToDTOToken(store.previousTokens),
convertTokenToDTOToken(store.tokens),
props.tokenId,
positionsVorschlagVisible.valueOf()
);
// this causes infinite loop
setPositionsVorschlagVisible(visible =>
(positionsVorschlagVisible && positionsVorschlag.showAction === showAction.keep) || positionsVorschlag.showAction === showAction.show);
return (
<div style={styles}>
{positionsVorschlagVisible &&
<PositionsVorschlag />
}
<Rente />
</div>
)
}
</code></pre>
<p>So I tried to place setting the state inside <code>useEffect</code>, but then it's not called anymore after initial rendering:</p>
<pre><code> // not called anymore after initial rendering
useEffect(() => {
setPositionsVorschlagVisible(visible =>
(positionsVorschlagVisible && positionsVorschlag.showAction === showAction.keep) || positionsVorschlag.showAction === showAction.show);
}, [positionsVorschlagVisible]);
</code></pre>
<p><strong>Why isn't the component re-rendered even if <code>positionsVorschlagVisible</code> has changed? Am I using <code>useEffect</code> or <code>useState</code> wrong?</strong></p>
<p>Just as a side note, (i don't know if it matters here), the parent component renders those PersonWidgets depenant of change in a mobx store:</p>
<pre><code>export const Screen = observer((): React.ReactElement => {
const store = useTableState();
var personTokens = store.tokens.filter(token => token.type === 'person');
return (<div style={ScreenStyles}>
{personTokens.map((personToken => {
return (
<div key={personToken.id} style={{ position: 'absolute', top: personToken.center.y, left: personToken.center.x }}>
<PersonWidget tokenId={personToken.id}/>
</div>
)
}))}
</div>)
});
</code></pre>
| [
{
"answer_id": 74152593,
"author": "JaSON",
"author_id": 10682289,
"author_profile": "https://Stackoverflow.com/users/10682289",
"pm_score": 3,
"selected": true,
"text": "fn:ends-with"
},
{
"answer_id": 74153918,
"author": "Conal Tuohy",
"author_id": 7372462,
"author_... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4600436/"
] |
74,151,326 | <p>When I try to run this in Jupyter Notebook:</p>
<pre><code>isolated = diff['2012-09-28' <= diff['start_date']]
isolated
</code></pre>
<p>I get this:</p>
<pre><code>TypeError: '>=' not supported between instances of 'datetime.date' and 'str'
</code></pre>
<p>What should I do? I already tried importing pandas and datetime but it didn't work.</p>
| [
{
"answer_id": 74151420,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 0,
"selected": false,
"text": "diff['2012-09-28' <= pd.to_datetime(diff['start_date'])]\n"
},
{
"answer_id": 74151470,
"author": "MOHAN... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299481/"
] |
74,151,327 | <p>As you can see from the attached sheet, I need to evaluate cells B2:K5 in "Internal Split" and paste cells that have values into Column A of sheet "Accounting Split". When it finds an empy cell (example: Cell D2), it should break and start looking in the next row for cells with values until it pastes all values vertically in column A of "Accounting Split". Thanks in advance</p>
| [
{
"answer_id": 74151420,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 0,
"selected": false,
"text": "diff['2012-09-28' <= pd.to_datetime(diff['start_date'])]\n"
},
{
"answer_id": 74151470,
"author": "MOHAN... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19749851/"
] |
74,151,341 | <p>I need to make a program where the user inputs all students names (this is then converted into a list each name becomes an item) and y amount of teams, the program will then randomize the teams with the names of the students. Ex. The user chooses 2 teams and has 4 different students the program then spits out 2 randomized teams with 2 students in each (these cannot be the same students).</p>
<pre><code>import random
import os
#clears the screen
os.system('cls')
#creates the list that later is filled with user input
list_name = []
temp_name = ""
#team_total is the user choosen amount of teams, this is then converted into integer
team_total = input("How many teams do you want?\n")
team_total = int(team_total)
#makes it so that all names written by the user are converted to individual list items
name = input("What are your students names?:\n")
for x in name:
if x == " ":
list_name.append(temp_name)
temp_name = ""
continue
else:
temp_name = temp_name + x
list_name.append(temp_name)
#using len to create varible that is equivilant to the amount of items in list_name
y = len(list_name)
#team_size is the amount of people in each team (amount of teams divided by amount of students)
team_size = (y / team_total)
print(f"There will be {team_size} per team!")
#r1 is the student in team_1
r1=random.randint(0,int(y))
team_a = (list_name[r1])
#r2 is the student in team_b (this also makes it so that r2 cant be the same as r1)
r2=random.randint(0,int(y))
while r2 == r1:
r2 = random.randint(0,(y))
r2=random.randint(0,int(y))
team_b = (list_name[r2])
</code></pre>
<p>This is how far I've gotten, I am completely stuck so help would be appriciated!</p>
| [
{
"answer_id": 74151835,
"author": "Alpa",
"author_id": 20299137,
"author_profile": "https://Stackoverflow.com/users/20299137",
"pm_score": 1,
"selected": false,
"text": "list.pop()"
},
{
"answer_id": 74152270,
"author": "Cobra",
"author_id": 17580381,
"author_profile... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19887480/"
] |
74,151,355 | <p>i am using usestate for transfer data. but ufotunately it not quite work.</p>
<p>here is my code:</p>
<pre><code>const [totCons, settotCons] = useState(null)
useEffect(() => {
// declare the async data fetching function
const fetchData = async () => {
// get the data from the api
const data = await fetch('https://piscons2.vercel.app/ConsPiscTotCons');
// convert the data to json
const json = await data.json();
// set state with the result
settotCons(json);
console.log(json)
console.log(totCons)
}
// call the function
fetchData()
// make sure to catch any error
.catch(console.error);;
}, [])
</code></pre>
<p>as you can see on image the json return data but the totCons return null.
i did set it <code>settotCons(json)</code></p>
<p><a href="https://i.stack.imgur.com/8Fwoh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Fwoh.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74151593,
"author": "Raison",
"author_id": 5033398,
"author_profile": "https://Stackoverflow.com/users/5033398",
"pm_score": 2,
"selected": false,
"text": "setState"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/609511/"
] |
74,151,366 | <p>I am trying to draw a choropleth map of municipalties in Denmark with color encoded as a sum of crimes in that municipalty.
I have several entries for each municipalty since the data is over a time-period and types of crime and I have a single geometry entry for each municipalty.
I want to perform a transform_lookup on the geometry field in the geopandas dataframe on the label_dk key, but I can't seem to get the map to render.</p>
<p>I could always merge the dataframes, but I am trying to save space by not repeating the geometry for every entry of crime, since I also want to plot the data in different charts and allow for slicing and dicing over time and offfence.</p>
<p>Bear in mind that this crime data is just a small example, and the real data I want to use has around 30,000 entries, so a merged geojson file takes up 647,000 KB and the map won't render.</p>
<p>Does anybody know why this transform_lookup doesn't work?</p>
<p>The data looks like this:</p>
<pre><code> label_dk geometry
0 Aabenraa MULTIPOLYGON Z (((9.51215 54.85672 -999.00000,...
1 Aalborg MULTIPOLYGON Z (((9.84688 57.04365 -999.00000,...
2 Aarhus POLYGON Z ((9.99682 56.17872 -999.00000, 9.990...
3 Albertslund POLYGON Z ((12.35234 55.70461 -999.00000, 12.3...
4 Allerød POLYGON Z ((12.31845 55.88305 -999.00000, 12.3...
.. ... ...
94 Vejle POLYGON Z ((9.11714 55.76669 -999.00000, 9.100...
95 Vesthimmerlands MULTIPOLYGON Z (((9.17798 56.91745 -999.00000,...
96 Viborg POLYGON Z ((9.29501 56.59336 -999.00000, 9.297...
97 Vordingborg MULTIPOLYGON Z (((12.04479 54.95566 -999.00000...
98 Ærø MULTIPOLYGON Z (((10.43467 54.87952 -999.00000...
[99 rows x 2 columns]
tid offence label_dk Anmeldte forbrydelser
0 2021K1 Seksualforbrydelser i alt København 133
1 2021K1 Voldsforbrydelser i alt København 900
2 2021K2 Seksualforbrydelser i alt København 244
3 2021K2 Voldsforbrydelser i alt København 996
4 2021K3 Seksualforbrydelser i alt København 174
.. ... ... ... ...
787 2021K2 Voldsforbrydelser i alt Aalborg 178
788 2021K3 Seksualforbrydelser i alt Aalborg 53
789 2021K3 Voldsforbrydelser i alt Aalborg 185
790 2021K4 Seksualforbrydelser i alt Aalborg 43
791 2021K4 Voldsforbrydelser i alt Aalborg 205
[792 rows x 4 columns]
</code></pre>
<p>The code is below:</p>
<pre><code>import altair as alt
import geopandas as gpd
import pandas as pd
import altair_viewer
alt.data_transformers.enable('data_server')
path = "data/small_few_umbrella_terms_crimes_2021.csv"
df = pd.read_csv(path,encoding="utf_8",index_col='Unnamed: 0')
geometry = gpd.read_file("data_with_geo/geometry.geojson")
map_chart = alt.Chart(df).mark_geoshape(
).transform_aggregate(
crime='sum(Anmeldte forbrydelser)',
groupby=["label_dk"]
).transform_lookup(
lookup='label_dk',
from_=alt.LookupData(geometry, 'label_dk', ['geometry'])
).encode(
color=alt.Color(
"crime:Q",
scale=alt.Scale(
scheme='viridis')
)
)
altair_viewer.show(map_chart)
</code></pre>
<p>The data can be found here:
<a href="https://github.com/Joac1137/Data-Visualization/blob/main/data_with_geo/geometry.geojson" rel="nofollow noreferrer">https://github.com/Joac1137/Data-Visualization/blob/main/data_with_geo/geometry.geojson</a>
and
<a href="https://github.com/Joac1137/Data-Visualization/blob/main/data/small_few_umbrella_terms_crimes_2021.csv" rel="nofollow noreferrer">https://github.com/Joac1137/Data-Visualization/blob/main/data/small_few_umbrella_terms_crimes_2021.csv</a></p>
| [
{
"answer_id": 74151593,
"author": "Raison",
"author_id": 5033398,
"author_profile": "https://Stackoverflow.com/users/5033398",
"pm_score": 2,
"selected": false,
"text": "setState"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299263/"
] |
74,151,403 | <p>I am having a problem using callback function in mongoose.</p>
<pre><code> Client.findOne({remarks}, (error, docs) => {
if(error){
//logging error to DB
return next(error)
}
if(docs){
return next(new ErrorResponse(IdenticalRemarksError, 400))
}
})
Client.create(
{ fullname, email, telephone, country, city, remarks },
(error, docs) => {
if(error){
return next(error)
}
res.status(201).json({
success: true,
data: docs
})
}
);
</code></pre>
<p>The return inside Client.findOne() callback does not end the entire register controler ie Client.create() still runs. I know this is because the return is local to the Client.findOne().</p>
<p>What is the best way of restructuring this in such a way that the return statement inside if(docs){} in Client.findOne() will end the entire controller function without imploying async await? ie The client wont be created if a remark is found in the findOne() method?</p>
| [
{
"answer_id": 74151521,
"author": "Drashti Kheni",
"author_id": 10535718,
"author_profile": "https://Stackoverflow.com/users/10535718",
"pm_score": 1,
"selected": true,
"text": "Client.findOne({ remarks }, (error, docs) => {\n if (error) {\n //logging error to DB\n return next(er... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17375720/"
] |
74,151,405 | <p>Hi I have a node like this:</p>
<pre><code>function socketIoEmit(n) {
RED.nodes.createNode(this, n);
const node = this;
this.instance = RED.nodes.getNode(n.instance).instance;
const optionsList = [];
node.on("input", (msg) => {
optionsList.push(msg);
});
// I want to output this optionsList
}
</code></pre>
<p>Is there any way to output this optionsList at once after all inputs have came. Maybe something like node.on("afterAllInputs") or node.on("end")?</p>
<p><a href="https://i.stack.imgur.com/4klTr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4klTr.png" alt="enter image description here" /></a></p>
<p>In here inputs are OPC UA Items. I want to store their nodeId value to the database such as {PLC1: {options: ['ns=3;x','ns=3;y']}. In OPC UA Clientv2 node, I have this type of object. Problem is, there is no certain number of OPC UA Item node, so there can be 1,2 may be 100 of them connected to OPC UA Clientv2. Because of that I do not know when to send this options data to the server.</p>
| [
{
"answer_id": 74151843,
"author": "knolleary",
"author_id": 2117239,
"author_profile": "https://Stackoverflow.com/users/2117239",
"pm_score": 1,
"selected": false,
"text": "node.on(\"input\", (msg) => {\n optionsList.push(msg);\n if (optionsList.length === NumberOfMessagesIExpect) {... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11293581/"
] |
74,151,412 | <p>I have some program with 2 screens made in Compose.
One of this screen have a button that makes transmission to another screen.
All works good, if I put only this action on this Button's onClick method.
But if I try to add something else, that should be made before changing screen, this navigate function no work anymore.</p>
<p>This way works:</p>
<pre><code>Button(
onClick = onNavigateToListUser
) {
Text(text = "Add")
}
</code></pre>
<p>This way does not:</p>
<pre><code> Button(
onClick = {
if (firstName != "" && lastName != "") {
val user = User(uid = 555, firstName, lastName)
userDao.insert(user)
Log.d("MyDebug", ":" + user.firstName + " " + user.lastName)
}
Log.d("MyDebug", "Hey. Second Line")
onNavigateToListUser
}
) {
Text(text = "Add")
}
</code></pre>
<p>What is onNavigate...:</p>
<pre><code>composable(route = DatabaseScreens.AddData.name) {
AddDataScreen(
userDao,
onNavigateToListUser = { navController.navigate(DatabaseScreens.UserList.name) }
)
}
</code></pre>
<p>Any help would be appreciated.</p>
| [
{
"answer_id": 74151505,
"author": "Gabriele Mariotti",
"author_id": 2016562,
"author_profile": "https://Stackoverflow.com/users/2016562",
"pm_score": 3,
"selected": true,
"text": "doSomething: () -> Unit"
},
{
"answer_id": 74151651,
"author": "FunnySaltyFish",
"author_id... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16938051/"
] |
74,151,419 | <p>I want the process exit when it receive an exit signal. So the main thread needs to wait for the exit signal, which I wrote like this before.</p>
<pre><code>int signal(int a) {
exit_flag = 0;
}
//wait in main thread
while(exit_flag){
sleep(1);
}
</code></pre>
<p>But it reacts a little slowly. So I find a new method like this,</p>
<pre><code>//signal function
int signal(int a) {
pthread_mutex_unlock(&mutex);
}
//main thread
pthread_mutex_lock(&lock);
pthread_mutex_lock(&lock);
</code></pre>
<p>I'm not sure if it's correct. My question is that if it's a propper way to wait for an exit signal or you can tell me a better way?</p>
<hr />
<p>Sincerely thank you all for your replies.
I know that it's undefined beahiver and unsafe to use the mutex in signal handler. But is the above code correct if I send the exit message through some other method, like a jrpc call or something like that?</p>
| [
{
"answer_id": 74153662,
"author": "Andrew Henle",
"author_id": 4756299,
"author_profile": "https://Stackoverflow.com/users/4756299",
"pm_score": 1,
"selected": false,
"text": "pthread_mutex_unlock()"
},
{
"answer_id": 74154259,
"author": "John Bollinger",
"author_id": 24... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8017196/"
] |
74,151,427 | <p>I just upgraded API platform to version 3.0.
After the few classical modifications linked to the version upgrade, and despite the use of: <code>php bin/console api:upgrade-resource</code></p>
<p>I notice that my entities are not exposed anymore when I go to the API documentation and if I try to access an endpoint, I get a route error:
No route found for "GET <a href="https://127.0.0.1:9000/api/XXX" rel="nofollow noreferrer">https://127.0.0.1:9000/api/XXX</a></p>
<p>I replaced all the ApiResource uses in my entities and rewrote my annotations.</p>
<p>example of an entity:</p>
<pre class="lang-php prettyprint-override"><code><?php
namespace App\Entity\Test;
use ApiPlatform\Metadata\ApiResource;
#[ApiResource(
collectionOperations: [
'get',
'post' => [
'denormalization_context' => ['groups' => ['create:xxx']]
]
],
itemOperations: [
'get' => [
'normalization_context' => ['groups' => ['read:fully:xxx']]
],
'put' => [
'denormalization_context' => ['groups' => ['update:xxx']]
],
'delete'
],
normalizationContext: ['groups' => ['read:xxx']]
)]
class Departement
{
....
}
</code></pre>
<p>Thanks in advance!</p>
<p>ok so, i update a little entity manually and now she is exposed !</p>
<pre><code><?php
namespace App\Entity\Agorha;
//use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use App\Entity\ChoixEcole;
use App\Repository\Agorha\EcoleRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
#[ORM\Entity(repositoryClass: EcoleRepository::class)]
#[ORM\Table(name: "agorha_ecole")]
#[ORM\HasLifecycleCallbacks()]
#[ApiResource(operations: [
new Get(),
new GetCollection()
])]
#[
UniqueEntity('code')
]
class Ecole
{
#[ORM\Id()]
#[ORM\GeneratedValue()]
#[ORM\Column(type: "integer")]
private $id;
</code></pre>
<p>i didn't see the results of the upgrade command, which ended up being an error and therefore did nothing.
in fact, it does not seem to exist</p>
<pre><code> Command "api:upgrade-resource" is not defined.
</code></pre>
<p>anyone would know why ?</p>
| [
{
"answer_id": 74158719,
"author": "MendelYev",
"author_id": 2933262,
"author_profile": "https://Stackoverflow.com/users/2933262",
"pm_score": 2,
"selected": true,
"text": "api:upgrade-resource"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299537/"
] |
74,151,437 | <p>I have the following <a href="https://www.edaplayground.com/x/ru_L" rel="nofollow noreferrer">Code</a>:</p>
<pre><code>`timescale 1ps / 1ps
module tb;
localparam t_CLOCK_PERIOD = 1000;
bit clk;
bit clk_del;
always #(t_CLOCK_PERIOD/2) clk = ~clk;
assign #490 clk_del = clk;// clk_del toggling normally
//assign #510 clk_del = clk;// clk_del not toggling
initial begin
clk =1'b1;
$display("waiting for Clock delayed");
@(posedge clk_del);
$display("Clock delayed");
$finish;
end
endmodule
</code></pre>
<p>I am trying to delay a clock signal, but when I do that by more of half a period, the signal stays unassigned (it does not toggle).</p>
<p>What am I doing wrong? How can I delay this signal more that the half period?</p>
| [
{
"answer_id": 74158719,
"author": "MendelYev",
"author_id": 2933262,
"author_profile": "https://Stackoverflow.com/users/2933262",
"pm_score": 2,
"selected": true,
"text": "api:upgrade-resource"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2591865/"
] |
74,151,442 | <p>I have a set of observations, <code>f_i=f(x_i)</code>, and I want to construct a probabilistic surrogate, <code>f(x) ~ N[mu(x), sigma(x)]</code>, where <code>N</code> is a normal distribution. Each observed output, <code>f_i</code>, is associated with a measurement uncertainty, <code>sigma_i</code>. I would like to incorporate these measurement uncertainties into my surrogate, <code>f_i</code>, so that <code>mu(x)</code> predicts the observations, <code>f_i(x_i)</code>, and that the predicted standard deviation, <code>sigma(x_i)</code>, envelops the uncertainty in the observed output, <code>epsilon_i</code>.</p>
<p>The only way I can think of to accomplish this is through a combination of Monte Carlo sampling and Gaussian Process modeling. It would be ideal to accomplish this with a single Gaussian process, without Monte Carlo samples, but I can not make this work.</p>
<p>I show three attempts to accomplish my goal. The first two avoid Monte Carlo sampling, but do not predict an average of <code>f(x_i)</code> with uncertainty bands that envelop <code>epsilon(x_i)</code>. The third approach uses Monte Carlo sampling and accomplishes what I want to do.</p>
<p>Is there a way to create a Gaussian Process that on average predicts the mean observed output, with uncertainty that will envelop uncertainty in the observed output, without using this Monte Carlo approach?</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
import matplotlib
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import RBF, Matern, ExpSineSquared, WhiteKernel
# given a set of inputs, x_i, and corresponding outputs, f_i, I want to make a surrogate f(x).
# each f_i is measured with a different instrument, that has a different uncertainty.
# measured inputs
xs = np.array([44, 77, 125])
# measured outputs
fs = [8.64, 10.73, 12.13]
# uncertainty in measured outputs
errs = np.array([0.1, 0.2, 0.3])
# inputs to predict
finex = np.linspace(20, 200, 200)
#############
### approach 1: uncertainty in kernel
# - the kernel is constant and cannot change as a function of the input
# - uncertainty in measurements can be incorporated using a whitenoisekernel
# - the white noise uncertainty can be specified as the average of the observation error
# RBF + whitenoise kernel
kernel = 1 * RBF(length_scale=9, length_scale_bounds=(10, 1e3)) + WhiteKernel(errs.mean(), noise_level_bounds=(errs.mean() - 1e-8, errs.mean() + 1e-8))
gaussian_process = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=9, normalize_y=True)
gaussian_process.fit((np.atleast_2d(xs).T), (fs))
mu, std = gaussian_process.predict((np.atleast_2d(finex).T), return_std=True)
plt.scatter(xs, fs, zorder=3, s=30)
plt.fill_between(finex, (mu - std), (mu + std), facecolor='grey')
plt.plot(finex, mu, c='w')
plt.errorbar(xs, fs, yerr=errs, ls='none')
plt.xlabel('input')
plt.ylabel('output')
plt.title('White Noise Kernel - assumes uniform sensor error')
plt.savefig('gp_whitenoise')
plt.clf()
####################
### Aproach 2: incorporate measurement uncertainty in the likelihood function
# - the likelihood function can be altered throught the alpha parameter
# - this assumes gaussian uncertainty in the measured input
kernel = 1 * RBF(length_scale=9, length_scale_bounds=(10, 1e3))
gaussian_process = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=9, normalize_y=True, alpha=errs)
gaussian_process.fit((np.atleast_2d(xs).T), (fs))
mu, std = gaussian_process.predict((np.atleast_2d(finex).T), return_std=True)
plt.scatter(xs, fs, zorder=3, s=30)
plt.fill_between(finex, (mu - std), (mu + std), facecolor='grey')
plt.plot(finex, mu, c='w')
plt.errorbar(xs, fs, yerr=errs, ls='none')
plt.xlabel('input')
plt.ylabel('output')
plt.title('uncertainty in likelihood - assumes measurements may be innacruate')
plt.savefig('gp_alpha')
plt.clf()
####################
### Aproach 3: Monte Carlo of measurement uncertainty + GP
# - The Gaussian process represents uncertainty in creating the surrogate f(x)
# - The uncertainty in observed inputs can be propogated using Monte Carlo
# - downside: less computationally efficient, no analytic solution for mean or uncertainty
kernel = 1 * RBF(length_scale=9, length_scale_bounds=(10, 1e3))
posterior_history = np.zeros((finex.size, 100 * 50))
for sample in range(100):
simulatedSamples = fs + np.random.normal(0, errs)
gaussian_process = GaussianProcessRegressor(kernel=kernel, n_restarts_optimizer=9, normalize_y=True)
gaussian_process.fit((np.atleast_2d(xs).T), (simulatedSamples))
posterior_sample = gaussian_process.sample_y((np.atleast_2d(finex).T), 50)
plt.plot(finex, posterior_sample, c='orange', alpha=0.005)
posterior_history[:, sample * 50 : (sample + 1) * 50] = posterior_sample
plt.plot(finex, posterior_history.mean(1), c='w')
plt.fill_between(finex, posterior_history.mean(1) - posterior_history.std(1), posterior_history.mean(1) + posterior_history.std(1), facecolor='grey', alpha=1, zorder=5)
plt.scatter(xs, fs, zorder=6, s=30)
plt.errorbar(xs, fs, yerr=errs, ls='none', zorder=6)
plt.xlabel('input')
plt.ylabel('output')
plt.title('Monte Carlo + RBF Gaussian Process. Accurate but expensive.')
plt.savefig('gp_monteCarlo')
plt.clf()
</code></pre>
<p><a href="https://i.stack.imgur.com/D8E5M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D8E5M.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/mEUj6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mEUj6.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/XW229.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XW229.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74225204,
"author": "amance",
"author_id": 17142551,
"author_profile": "https://Stackoverflow.com/users/17142551",
"pm_score": 2,
"selected": true,
"text": "kernel = 1 * RBF(length_scale=9, length_scale_bounds=(10, 1e3))\ngaussian_process = GaussianProcessRegressor(kernel=... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3474956/"
] |
74,151,472 | <p>I have an object like this:</p>
<pre><code>const obj = {a: [1,2,3], b: [4,5,6]}
</code></pre>
<p>I expect to get array: <code>[1, 2, 3, 4, 5, 6]</code></p>
<p>here is function that i used but it give me only the last array: <code>[4, 5, 6]</code></p>
<pre><code>for (const property in obj) {
var allData = []
allData.push(...obj[property])
}
</code></pre>
| [
{
"answer_id": 74151555,
"author": "Nicolas Tome",
"author_id": 14333874,
"author_profile": "https://Stackoverflow.com/users/14333874",
"pm_score": 3,
"selected": false,
"text": "const obj = {a: [1,2,3], b: [4,5,6]};\nvar allData = [];\nfor (const property in obj) { \n allData.push... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299501/"
] |
74,151,478 | <p>I write a program for DOSBox (using TASM). I need to output inputted string as characters line by line. I figured out how to input string, but I have wrong
<a href="https://i.stack.imgur.com/VKl7b.jpg" rel="nofollow noreferrer">output</a>.</p>
<p>There are <strong>2 problems</strong>:</p>
<ol>
<li>I do not know how to get <strong>length</strong> of the string, so there are too much blank lines.</li>
<li>There is <strong>not one character per line</strong> in the output.</li>
</ol>
<p>My code:</p>
<pre><code>.model small
.data
message db 'String: $'
string db 10 dup(' '), '$'
.stack 256h
.code
main:
mov ax, @data
mov ds, ax
lea dx, message ; load message to dx
mov ah, 09h ; output message
int 21h
xor dx, dx
lea dx, string ; input string
mov ah, 0Ah
int 21h
; crlf
mov dl, 10
mov ah, 02h
int 21h
mov dl, 13
mov ah, 02h
int 21h
; output string char by char
mov si, 0
mov cx, 10 ; a number of loops, but how to get the length of the string?
output:
lea dx, string[si]
mov ah, 09h
int 21h
mov dl, 10
mov ah, 02h
int 21h
mov dl, 13
mov ah, 02h
int 21h
inc si
loop output
mov ah,4ch
int 21h
end main
</code></pre>
| [
{
"answer_id": 74152148,
"author": "Özgür Güzeldereli",
"author_id": 12196664,
"author_profile": "https://Stackoverflow.com/users/12196664",
"pm_score": 1,
"selected": false,
"text": "str: db \"Hello, world!\", 0\n"
},
{
"answer_id": 74171719,
"author": "Sep Roland",
"aut... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,151,482 | <p>Using TypeScript, I want to create an Array of different generics.</p>
<p>My goal of my generic class is to represent table columns, and the T holds the type of the value the column will hold. This looks as follows:</p>
<pre><code>export class TableColumnConfig<T> { ... }
</code></pre>
<p>When I want to put multiple columns for a table into the array, I do this:</p>
<pre><code>const columns: TableColumnConfig<any>[] = [];
</code></pre>
<p>Then I would do something like this:</p>
<pre><code>columns.push(new TableColumnConfig<number>());
columns.push(new TableColumnConfig<string>());
</code></pre>
<p>This works, but the thing is that eslint tells me that I should not use any</p>
<blockquote>
<p>Unexpected any. Specify a different
type.eslint@typescript-eslint/no-explicit-any</p>
</blockquote>
<p>Eslint suggest to use unknown.</p>
<p>So I do this:</p>
<pre><code>const columns: TableColumnConfig<unknown>[] = [];
</code></pre>
<p>So of course, I get the following error:</p>
<blockquote>
<p>Argument of type 'TableColumnConfig<number>' is not assignable to
parameter of type 'TableColumnConfig<unknown>'. Type 'unknown' is
not assignable to type 'number'.ts(2345)</p>
</blockquote>
<p>Is there any way of satisfying eslint as well as getting no typescript syntax error?</p>
<p>Is it fine in this case to ignore the warning of eslint?</p>
<p>Some advice is much appreciated! :)</p>
<p>EDIT: This is how my class and the builder that I use for it looks like:</p>
<pre><code>export class TableColumnConfig<T> {
// lots of properties (that don't use T)
format?: (val: T) => string;
sort?: (val1: T, val2: T) => number;
constructor() {
// ...
}
}
export class TableColumnConfigBuilder<T> implements ITableColumnConfigBuilder<T> {
private tableColumnConfig: TableColumnConfig<T>;
constructor() /* some mandatory properties */
{
this.tableColumnConfig = new TableColumnConfig(
sourceAddress,
parameterAddress,
dataType,
mainLabel
);
}
// ...
setFormat(format: (val: T) => string): this {
this.tableColumnConfig.format = format;
return this;
}
setSort(sort: (val1: T, val2: T) => number): this {
this.tableColumnConfig.sort = sort;
return this;
}
get(): TableColumnConfig<T> {
return this.tableColumnConfig;
}
}
interface ITableColumnConfigBuilder<T> {
// ...
setFormat(format: (val: T) => string): this;
setSort(sort: (val1: T, val2: T) => number): this;
}
</code></pre>
| [
{
"answer_id": 74152148,
"author": "Özgür Güzeldereli",
"author_id": 12196664,
"author_profile": "https://Stackoverflow.com/users/12196664",
"pm_score": 1,
"selected": false,
"text": "str: db \"Hello, world!\", 0\n"
},
{
"answer_id": 74171719,
"author": "Sep Roland",
"aut... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10084505/"
] |
74,151,560 | <p>I'm right now learning more about C# and SQL connections and doing a challenge their I'm making a simple atm.</p>
<p>This atm will handle create account, check if its exist in database and if not then add to database, if it exist then close the program. Also it will handle rest of the parts an atm does once you have logged in to your card. With take outs and input.</p>
<p>This challenge are just for me to learn more of SQL and C#.</p>
<p>My issue:
I'm trying to check if the value exist already in my SQL table but I'm not sure what I'm doing wrong.</p>
<p>Thanks in advance!</p>
<pre><code> bool checkifExist(int number) {
bool itExist;
string queryString;
var cnn = new SqlConnection(connectionString);
DataTable dt = new DataTable();
try
{
cnn.Open();
queryString = "select Count(*) from dbo.User_Card_Information where [CardNumbers] = @cardnumbers";
SqlCommand check_cardnumber = new SqlCommand(queryString, cnn);
check_cardnumber.Parameters.AddWithValue("@cardnumbers", cardnumber);
int cardExist = (int)check_cardnumber.ExecuteScalar();
if(check_cardnumber.ExecuteNonQuery() != cardnumber)
{
Console.WriteLine("Create completed!");
cnn.Close();
return itExist = false;
}
else
{
Console.WriteLine("This Card Number already exist!");
itExist = true;
cnn.Close();
return itExist;
}
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Fetch Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
cnn.Close();
}
}
</code></pre>
| [
{
"answer_id": 74152148,
"author": "Özgür Güzeldereli",
"author_id": 12196664,
"author_profile": "https://Stackoverflow.com/users/12196664",
"pm_score": 1,
"selected": false,
"text": "str: db \"Hello, world!\", 0\n"
},
{
"answer_id": 74171719,
"author": "Sep Roland",
"aut... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13734896/"
] |
74,151,575 | <p>how can I send request to nearby drivers what is the algorithm can please anyone guide me I am making ridesharing app.</p>
| [
{
"answer_id": 74152148,
"author": "Özgür Güzeldereli",
"author_id": 12196664,
"author_profile": "https://Stackoverflow.com/users/12196664",
"pm_score": 1,
"selected": false,
"text": "str: db \"Hello, world!\", 0\n"
},
{
"answer_id": 74171719,
"author": "Sep Roland",
"aut... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19221726/"
] |
74,151,596 | <p>So i am working on a laravel project with multiple table's and pivot table's but i cant attach data to a specific pivot table because it wont accept the name.
as a user i want to be able to download files from the 'file' crud. That works. but after i downloaded i want to be able to see who downloaded what file as an admin, this does not work</p>
<p>the query i get is:INSERT INTO <code>file_user</code> (<code>file_id</code>, <code>user_id</code>) VALUES (7, 2)</p>
<p>i basically want to change the: <code>file_user</code> to <code>download</code>. but i have no idea how to do that without making a full query</p>
<p>table 'file'</p>
<ul>
<li>id
-name
-file (document)</li>
</ul>
<p>table 'user'
-id
-name
-username
-role</p>
<p>pivot table 'download'
-id
-file_id
-user_id</p>
<p>user model:</p>
<pre><code> public function role(){
return $this->belongsTo(Role::class,'role_id');
}
public function file(){
return $this->belongsToMany(File::class);
}
</code></pre>
<p>file model:</p>
<pre><code> public function user(){
return $this->belongsToMany(User::class);
}
protected $table = 'file';
</code></pre>
<p>download model (pivot)</p>
<pre><code> protected $table = 'download';
protected $fillable = [
'file_id',
'user_id',
];
public function file() {
return $this->belongsTo('file');
}
public function user() {
return $this->belongsTo('users');
}
</code></pre>
<p>controller:</p>
<pre><code> public function download(Request $request, int $fileId)
{
$id = Auth::user();
$fullfile = File::find($fileId);
$downloadfile = File::find($fullfile, ['file'])->pluck('file')->last();
// return response()->download($downloadfile);
dd($fullfile->user()->attach($id));
return back();
}
</code></pre>
| [
{
"answer_id": 74151686,
"author": "Ashutosh Jha",
"author_id": 13004581,
"author_profile": "https://Stackoverflow.com/users/13004581",
"pm_score": 2,
"selected": true,
"text": "public function file(){\n return $this->belongsToMany(File::class, 'download');\n}\n public function user... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19923550/"
] |
74,151,647 | <p>I want to print expected output values in two loop using map, Can you please help me.</p>
<pre><code>var data=[{'2021':['Q2 2021','Q3 2021','Q4 2021']},
{'2022':['Q1 2022','Q2 2022']}
]
data.map((obj,ind)=>{
console.log(Object.keys(obj));
Object.keys(obj).map((yearQuarter, i) => {
console.log(obj[yearQuarter]);
})
})
//getting output
//['2022']
//['Q1 2022', 'Q2 2022']
//Expected Output
//'2022'
//'Q1 2022`
//'Q2 2022`
</code></pre>
| [
{
"answer_id": 74151679,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 1,
"selected": false,
"text": "obj[yearQuarter]"
},
{
"answer_id": 74153699,
"author": "Rohìt Jíndal",
"author_id": 4116300,
... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8368511/"
] |
74,151,678 | <pre class="lang-java prettyprint-override"><code>Have char[] operator = // "+" or "<" or "<=" etc
if(op.length == 1) {
switch (op[0]) {
case '+':
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() + b.doubleValue();
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() + b.longValue();
}
break;
case '-':
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() - b.doubleValue();
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() - b.longValue();
}
break;
case '*':
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() * b.doubleValue();
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() * b.longValue();
}
break;
case '^':
if (a instanceof Double || b instanceof Double) {
result = Double.valueOf(Math.pow(a.doubleValue(), b.doubleValue()));
} else if (a instanceof Long && b instanceof Long) {
result = (long) Math.pow(a.longValue(), b.longValue());
}
break;
case '/':
if (b.doubleValue() == 0) {
throw new UnsupportedOperationException("Cannot divide by zero");
}
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() / b.doubleValue();
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() / b.longValue();
}
break;
case '>':
resultDecorator.setTypeOfexpresion(EvaluatorConstants.Boolean);
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() > b.doubleValue()?1:0;
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() > b.longValue()?1:0;
}
break;
case '<':
resultDecorator.setTypeOfexpresion(EvaluatorConstants.Boolean);
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() < b.doubleValue()?1:0;
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() < b.longValue()?1:0;
}
break;
}
} else if (op.length == 2) {
resultDecorator.setTypeOfexpresion(EvaluatorConstants.Boolean);
switch (op.toString()) {
case ">=":
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() >= b.doubleValue()?1:0;
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() >= b.longValue()?1:0;
}
break;
case "<=":
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() <= b.doubleValue()?1:0;
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() <= b.longValue()?1:0;
}
break;
case "==":
if (a instanceof Double || b instanceof Double) {
result = a.doubleValue() == b.doubleValue()?1:0;
} else if (a instanceof Long && b instanceof Long) {
result = a.longValue() == b.longValue()?1:0;
}
break;
}
}
</code></pre>
<p>Wanted to avoid many comparison operations.</p>
<p>I don't see a solution to covert string to literal I mean convert to working operator(single char operator or two char operator).</p>
<p>Can it be achieved without using any lib?</p>
| [
{
"answer_id": 74151881,
"author": "Torben",
"author_id": 1047418,
"author_profile": "https://Stackoverflow.com/users/1047418",
"pm_score": 3,
"selected": true,
"text": " if (a instanceof Double || b instanceof Double) {\n result = a.doubleValue() + b.doubleValue();\n } else i... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1523263/"
] |
74,151,703 | <p>Is it possible to build a capacitor app with a specific proxy file?</p>
<p>Until now I use inside <em>capacitor.config.json</em></p>
<pre><code>server: {
url: 'https://my-domain.com',
allowNavigation: ["some.stuffs.com"],
}
</code></pre>
<p>but if <em>my-domain.com</em> is down my mobile app will not show anything. So I'm searching a way to have my app completely on mobile device and seems work if I remove <em>server</em> from capacitor configuration</p>
<p>Here the problem:
If my app pointing to <em>my-domain.com</em> (started on a server with specific proxy-conf) all works well, but if I remove <em>server</em> from capacitor configuration capacitor doesn't start my app with proxy conf and my http request not working well</p>
<p>Is there a way to obtain request proxed correctly on my capacitor app without using <em>server</em> conf in capacitor.config?</p>
| [
{
"answer_id": 74234014,
"author": "gzn",
"author_id": 13642816,
"author_profile": "https://Stackoverflow.com/users/13642816",
"pm_score": 2,
"selected": true,
"text": "server configuration"
},
{
"answer_id": 74276418,
"author": "Kaushikkumar Parmar",
"author_id": 1283199... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13240452/"
] |
74,151,709 | <p>So I have a question that pertains to the scope of variables in functions in python, consider the following code:</p>
<pre><code>import numpy as np
def function(data, mask):
data *= mask
data = np.ones(5)
for x in range(2):
print(data)
mask = np.array([1, 0, 0, 0, 0])
function(data, mask)
</code></pre>
<p>And the output is the following:</p>
<pre><code>[1. 1. 1. 1. 1.]
[1. 0. 0. 0. 0.]
</code></pre>
<p>My question is why <code>data</code> changes after the first iteration? I always thought that the local variable of a function was... local, so any modification would remain confined within the scope of the function. Clearly I was wrong. Is this because <code>data</code> in the function is still referencing the same object as the <code>data</code> in the global scope?</p>
| [
{
"answer_id": 74151883,
"author": "JustLearning",
"author_id": 19962393,
"author_profile": "https://Stackoverflow.com/users/19962393",
"pm_score": 3,
"selected": true,
"text": "function"
},
{
"answer_id": 74151891,
"author": "Thomas",
"author_id": 14637,
"author_prof... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7631505/"
] |
74,151,721 | <p>Sorry if the title is not well written, but I didn't think of any way better to phrase it.</p>
<p>I have a table similar to the following one and I am using it in BigQuery:</p>
<p><a href="https://i.stack.imgur.com/Z5Sry.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z5Sry.png" alt="enter image description here" /></a></p>
<p>I can check how much each <code>failure_reason</code> represents of all the failed <code>status</code>:</p>
<p><a href="https://i.stack.imgur.com/fYMca.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fYMca.png" alt="enter image description here" /></a></p>
<p>I want to create a new table in which all the <code>failure_reason</code> that have 10% or less of the total failed <code>status</code> are replaced by the value <code>other</code>. In the end, my table would look like this:</p>
<p><a href="https://i.stack.imgur.com/zGlny.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zGlny.png" alt="enter image description here" /></a></p>
<p>How can I do this? I am trying to use a window with a partition by, but it doesn't work. The best that I have been able to build so far is the following:</p>
<pre><code>with
mytable as (
SELECT
*
FROM
UNNEST([
STRUCT("2022-08-01" AS month, "successful" AS status, "" as failure_reason, 1000 as qty),
("2022-08-01","failed", "reason A", 550),
("2022-08-01","failed", "reason B", 300),
("2022-08-01","failed", "reason C", 100),
("2022-08-01","failed", "reason D", 50),
("2022-09-01","successful", "", 1500),
("2022-09-01","failed", "reason A", 800),
("2022-09-01","failed", "reason B", 110),
("2022-09-01","failed", "reason C", 80),
("2022-09-01","failed", "reason D", 10),
("2022-10-01","successful", "", 1100),
("2022-10-01","failed", "reason A", 600),
("2022-10-01","failed", "reason B", 210),
("2022-10-01","failed", "reason C", 120),
("2022-10-01","failed", "reason D", 50),
("2022-10-01","failed", "reason E", 20) ])
),
mytable_share as (
select
failure_reason,
(sum(qty) / (sum(qty) over (partition by status))) as share
from
mytable
where
status = "failed"
group by
failure_reason
)
select
month,
status,
case when share <= 0.1 then "other"
else failure_reason
end as failure_reason,
qty
from
mytable
left join
mytable_share
using (failure_reason)
order by
1,
2,
3
</code></pre>
| [
{
"answer_id": 74156071,
"author": "gregor",
"author_id": 20198546,
"author_profile": "https://Stackoverflow.com/users/20198546",
"pm_score": 0,
"selected": false,
"text": "select month,\n \"0_successful\" as status,\n failure_reason,\n quantity\nfrom test\nwhere status... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8916408/"
] |
74,151,722 | <p>I have a pandas dataframe like this:</p>
<pre><code> df= pd.DataFrame({'year':['2020','2030','2040','2030','2040','2030','2040'],
'group':['a', 'a', 'a', 'b', 'b', 'c', 'c'],
'values':[10,20,30,45,60,12,36]})
year group value
2020 a 10
2030 a 20
2040 a 30
2030 b 45
2040 b 60
2030 c 12
2040 c 36
</code></pre>
<p>I want to check if the 2020 value in each group is missing, then add the relevant row and fill it with the value from group a, i.e, see the following result:</p>
<pre><code> year group value
2020 a 10
2030 a 20
2040 a 30
**2020 b 10**
2030 b 45
2040 b 60
**2020 c 10**
2030 c 12
2040 c 36
</code></pre>
| [
{
"answer_id": 74151741,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "DataFrame.pivot"
},
{
"answer_id": 74151788,
"author": "mozway",
"author_id": 16343464,
"author_p... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9528575/"
] |
74,151,748 | <p>I have table with two columns:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Index</th>
<th>Col_1</th>
<th>Key</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>3,5</td>
<td>1001</td>
</tr>
<tr>
<td>2</td>
<td>4,5,6</td>
<td>2004</td>
</tr>
<tr>
<td>3</td>
<td></td>
<td>7845</td>
</tr>
<tr>
<td>4</td>
<td>1,6</td>
<td>9658</td>
</tr>
<tr>
<td>5</td>
<td>2,3</td>
<td>5236</td>
</tr>
<tr>
<td>6</td>
<td></td>
<td>6066</td>
</tr>
</tbody>
</table>
</div>
<p>Need to check Col_1 and save the Key for each index number mentioned in the Col_1.</p>
<p>For Example: in Index 1, Col_1 has values 3,5 so need to save the Key of Index 3,5 in Key_Checked column. The Key saved will be 7845,5236</p>
<p>The output table should be:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Index</th>
<th>Col_1</th>
<th>Key</th>
<th>Key_Checked</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>3,5</td>
<td>1001</td>
<td>7845,5236</td>
</tr>
<tr>
<td>2</td>
<td>4,5,6</td>
<td>2004</td>
<td>9658,5236,6066</td>
</tr>
<tr>
<td>3</td>
<td></td>
<td>7845</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>1,6</td>
<td>9658</td>
<td>1001</td>
</tr>
<tr>
<td>5</td>
<td>2,3</td>
<td>5236</td>
<td>2004,7845</td>
</tr>
<tr>
<td>6</td>
<td></td>
<td>6066</td>
<td></td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74151840,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "# ensure we have strings everywhere\ndf = df.astype(str)\n\ndf['Key_Checked'] = (df['Col_1'].str.split(',').explode... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,151,751 | <p>How can I change the current folder name in Powershell? After cutting the basename I want to rename the current basename with $NewName2. But all tries don't work.
Are there any hints for me for the correct Rename-Item syntax.</p>
<p>Example:</p>
<p>current Basename: Ultralongfoldernametochange</p>
<p>after cutting:<br />
$NewName2: Ultralongf</p>
<pre><code>$AllDir = Get-ChildItem -LiteralPath E:\ -Recurse -Directory | Where-Object { $_.FullName.Length -ge 95 }
foreach($file in $AllDir)
{
if ($file.Basename.Length -ge 44)
{
$NewName2 = ($file.BaseName[0..9] -join '')
Rename-Item ???
}
}
</code></pre>
| [
{
"answer_id": 74151840,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "# ensure we have strings everywhere\ndf = df.astype(str)\n\ndf['Key_Checked'] = (df['Col_1'].str.split(',').explode... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9703548/"
] |
74,151,753 | <p>I have the following screen:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/header"
style="@style/CustomFont_Header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:text="@string/welcome_header"
android:textAlignment="center"
android:textColor="@color/text_header"
tools:text="Header Title"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.1" />
<ScrollView
android:id="@+id/scrollview"
android:layout_width="@dimen/subtext_width"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/subtext_margin_top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/header">
<TextView
android:id="@+id/subtext"
style="@style/CustomFont_Subheader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:text="@string/welcome_text"
android:textColor="@color/color_subtext"
tools:text="@string/testtext_short" />
</ScrollView>
<ImageView
android:id="@+id/logo"
android:layout_width="300dp"
android:layout_height="150dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:scaleType="fitCenter"
android:src="@drawable/logo_pic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/scrollview"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</code></pre>
<p>I want to make subtext scrollable, because it can sometimes be short sometimes long.
I can make it work if I change scrollView and add:</p>
<pre><code>android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/logo
</code></pre>
<p>But in this case, if the text is short, then the logo is pushed to the bottom:</p>
<p><a href="https://i.stack.imgur.com/8ND02.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ND02.png" alt="Logo at the bottom" /></a></p>
<p>I always need to have the logo in the middle between the subtext and parent bottom and at the same time subtext must be constraint to the bottom of header if it is short.</p>
<p>I can think of something programmatically, but I think it can be done in XML, right?</p>
| [
{
"answer_id": 74152361,
"author": "Afnan Khakwani",
"author_id": 19342348,
"author_profile": "https://Stackoverflow.com/users/19342348",
"pm_score": 0,
"selected": false,
"text": " android:layout_height=\"0dp\"\n app:layout_constraintBottom_toTopOf=\"@id/logo\n"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8655128/"
] |
74,151,754 | <p>When I run the solidity-coverage plugin in hardhat, I have this error message :</p>
<p><em>Error in plugin solidity-coverage: HardhatPluginError: Warning: 3 contracts exceed the size limit for mainnet deployment.</em></p>
<p>However, when I compile the contracts they do not exceed the size limit. This happens only when I run the plugin. The test suite runs perfectly with no error neither.</p>
<p>I added <code>allowUnlimitedContractSize: true</code> in the hardhat network config but still got the error. There is probably some more configuration needed.</p>
<p>I am using <code>solidity-coverage : 0.8.2</code></p>
<p>Is there a way to ignore this error and run the coverage correctly ?</p>
| [
{
"answer_id": 74152361,
"author": "Afnan Khakwani",
"author_id": 19342348,
"author_profile": "https://Stackoverflow.com/users/19342348",
"pm_score": 0,
"selected": false,
"text": " android:layout_height=\"0dp\"\n app:layout_constraintBottom_toTopOf=\"@id/logo\n"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8757751/"
] |
74,151,801 | <p>So I'm working on a website that has a lot of movies, and people can choose what movies are they favorite, and for that, I have a star image that can be clicked and when clicked that image will change to another one</p>
<p>Like this:
<a href="https://i.stack.imgur.com/rCAkA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rCAkA.png" alt="enter image description here" /></a></p>
<p>To this:
<a href="https://i.stack.imgur.com/gwMsL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gwMsL.png" alt="enter image description here" /></a></p>
<p>The problem I have is that the only image that change is the first one, When I click, for example on the star next to the Ratatouille movie, it will change the first star</p>
<p>This is the HTML:</p>
<pre><code>const getMovieHtml = (movie) => `<div class="movie">
<h2>${movie.title}</h2>
<img onclick="bottonclick()" id="estrelinhas" src="./icons/empty-star.png" alt="estrela vazia" width=40>
<div class="content">
<img src="${movie.posterUrl}" alt="${movie.title}" />
<div class="text">
<p>${movie.summary}</p>
<div class="year">${movie.year}</div>
<div><strong>Directors:</strong> ${movie.director}</div>
<div><strong>Actors:</strong> ${movie.actors}</div>
</div>
</div>
</div>`;
</code></pre>
<p>And this is the arrow function I used to make the star change:</p>
<pre><code>const bottonclick = () => {
if (document.getElementById("estrelinhas").src.includes("empty-star.png")) {
document.getElementById("estrelinhas").src = "./icons/filled-star.png";
} else {
document.getElementById("estrelinhas").src = "./icons/empty-star.png";
}
};
</code></pre>
| [
{
"answer_id": 74151918,
"author": "jakub",
"author_id": 20299742,
"author_profile": "https://Stackoverflow.com/users/20299742",
"pm_score": 0,
"selected": false,
"text": "buttonClick(e)\n"
},
{
"answer_id": 74151984,
"author": "david",
"author_id": 18567495,
"author_... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15682259/"
] |
74,151,805 | <p>how to remove first line in a super huge text file (min lines: 65536), using CMD (without any installing)?</p>
<p>example input file:</p>
<pre><code>line1
line2
line3
line4
</code></pre>
<p>output file after I run the CMD:</p>
<pre><code>line2
line3
line4
</code></pre>
<p>I have tried</p>
<pre><code>more +1 "input.txt" > "output.txt"
</code></pre>
<p>but the max limit line in text file is 65535.</p>
<p>thank you all in advanced.</p>
<p>ps: super newbie in coding scripting.</p>
| [
{
"answer_id": 74151918,
"author": "jakub",
"author_id": 20299742,
"author_profile": "https://Stackoverflow.com/users/20299742",
"pm_score": 0,
"selected": false,
"text": "buttonClick(e)\n"
},
{
"answer_id": 74151984,
"author": "david",
"author_id": 18567495,
"author_... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20041018/"
] |
74,151,807 | <p>Recently updated from Angular 12 to latest & updated respective package.json references to latest as well</p>
<p><strong>Error:</strong></p>
<pre><code> Module not found: Error: Can't resolve '@angular/platform-browser/animations' in 'C:\MySolution\AngApp\Client\AppName\src'
</code></pre>
<p>I'm using Yarn & Gulp with webpack in combination.</p>
<p>Update 1: Sample Test App everything works as expected but when i work on Real application i get the above error.</p>
<p>I suspect something to do with Gulp how it does things any advice would be helpful.</p>
<p>Happy to add more details if required.</p>
| [
{
"answer_id": 74151819,
"author": "Sachila Ranawaka",
"author_id": 6428638,
"author_profile": "https://Stackoverflow.com/users/6428638",
"pm_score": 0,
"selected": false,
"text": "import { BrowserAnimationsModule } from '@angular/platform-browser/animations';\n\nimports: [BrowserAnimati... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3460734/"
] |
74,151,870 | <p>If I have a 2D numpy array A:</p>
<pre><code>[[6 9 6]
[1 1 2]
[8 7 3]]
</code></pre>
<p>And I have access to array [1 1 2]. Clearly, [1 1 2] belongs to index 1 of array A. But how do I do this?</p>
| [
{
"answer_id": 74151932,
"author": "JustLearning",
"author_id": 19962393,
"author_profile": "https://Stackoverflow.com/users/19962393",
"pm_score": 2,
"selected": true,
"text": "import numpy as np \n ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16968265/"
] |
74,151,871 | <p>Im creating a program that will be used like a library, where you can for exampel look up a spesific book.. Let me run you through the code..</p>
<p>The problem im trying to solve is that the lookup function does NOT print out the books in my library list that contain that letters in question</p>
<p><strong>This class is used for creating the books in the library</strong></p>
<pre><code> class Bok
{
public string titel;
public string author;
public bool loaned;
public Bok(string titel, string author, bool loaned)
{
this.titel = titel;
this.author = author;
this.loaned = loaned;
}
}
</code></pre>
<p><strong>And with this I have created a new list, called library along with an example books</strong></p>
<pre><code> List<Bok> library = new List<Bok>() { };
Bok book = new Bok("alex bok", "alexander", false);
</code></pre>
<p><strong>Now I'm letting the user input a string, which will be used to search for a specific book located in that list, im making all the cases of the string answer to lower and then checking if any object in the list library has an object of which the values "author" or "title" contains the string that the user entered, and then prints it</strong></p>
<pre><code> void Print(Bok bok)
{
Console.WriteLine("hej");
Console.WriteLine($"{bok.titel}\n" +
$"{bok.author}\n" +
$"Lånad : {bok.loaned}");
}
void Lookup()
{
Console.WriteLine("Sök efter titel, eller författare");
string svar = (Console.ReadLine()).ToLower();
foreach(Bok bok in library)
{
if (bok.author.Contains(svar) || bok.titel.Contains(svar))
{
Print(bok);
}
else
{
Console.WriteLine("Boken finns inte i biblioteket.");
}
}
}
</code></pre>
| [
{
"answer_id": 74151932,
"author": "JustLearning",
"author_id": 19962393,
"author_profile": "https://Stackoverflow.com/users/19962393",
"pm_score": 2,
"selected": true,
"text": "import numpy as np \n ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20125200/"
] |
74,151,902 | <p>I'm using:</p>
<ol>
<li>React Typescript</li>
<li>Chakra UI</li>
</ol>
<p>I'm simply retrieving data from the api:</p>
<p><a href="https://i.stack.imgur.com/RIZmF.png" rel="nofollow noreferrer">line20-line37</a></p>
<ul>
<li>I use a useEffect to from from the api, and passing the response to a local array.</li>
<li>I then map through the array to give only the items I need.</li>
<li>I place this map within chakra components</li>
</ul>
<p>See code here:</p>
<pre><code>import React, { useEffect } from "react";
import { Box, Text } from "@chakra-ui/react";
import { useParams } from "react-router-dom";
import Header from "./BuyerHeader";
import instance from "../api/api";
import Orders from "../models/Orders.type";
function EditOrder() {
const { id } = useParams();
const userOrders: Orders[] = [];
useEffect(() => {
const controller = new AbortController();
let dataFetched = false;
async function getOrderById() {
if (!dataFetched) {
const response = await instance.get(`/api/v1/orders/${id}`);
console.log(response);
// setOrders(response.data.orders);
userOrders.push(response.data.orders);
}
}
getOrderById();
return () => {
dataFetched = true;
controller.abort();
};
}, []);
return (
<Box>
<Header />
<Box>Edit Order Page</Box>
<Box bgColor="pink" w={100} h={100}>
{/* <Text>{orders.productName}</Text> */}
<Text color="black" fontSize={20} fontWeight="bold">
Orders:
</Text>
{userOrders.map((orders) => (
<Text bgColor="black" fontSize={30} fontWeight="bold">
Item Name: {orders.productName}
</Text>
))}
</Box>
</Box>
);
}
export default EditOrder;
</code></pre>
<p>This is the response in console:</p>
<p><a href="https://i.stack.imgur.com/REuMQ.png" rel="nofollow noreferrer">console-in-browser/response-from-api</a></p>
<p>so it is returning the correct data I want from the api</p>
<p>but this is what is rendering:</p>
<p><a href="https://i.stack.imgur.com/x2UwP.png" rel="nofollow noreferrer">webpage-returned</a></p>
<p>can someone tell me why it's not rendering the <strong>{orders.productName}</strong>?</p>
| [
{
"answer_id": 74152050,
"author": "Simon Löfquist",
"author_id": 19748662,
"author_profile": "https://Stackoverflow.com/users/19748662",
"pm_score": 1,
"selected": true,
"text": "const [userOrders, setUserOrders] = useState<Orders[]>([])\n\nuseEffect(()=>{\ninstance.get(`/api/v1/orders/... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18882052/"
] |
74,151,903 | <h4>I can get the vscode tip with <code>number</code>:</h4>
<p><a href="https://i.stack.imgur.com/7SSe3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7SSe3.png" alt="enter image description here" /></a></p>
<h4>but when union with <code>string</code> failed:</h4>
<p><a href="https://i.stack.imgur.com/3O5Rm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3O5Rm.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74151962,
"author": "Sefa Şahinoğlu",
"author_id": 6658596,
"author_profile": "https://Stackoverflow.com/users/6658596",
"pm_score": -1,
"selected": false,
"text": "type color = 'white' | 'black' | String; \n"
},
{
"answer_id": 74152003,
"author": "Titian Cerni... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8035949/"
] |
74,151,904 | <p>I want to write a script which will take the output of a job submission script as a variable to be used for the same next for loop. I have written it as follows</p>
<pre><code>temp= (40 50)
for i in "${!temp[@]}"; do
cd ${temp[i]}-$((temp[i]+10))ns;
((counter++))
var="ID$((counter-1))"
var1=ID$counter
if [[ "$i" -eq 0]]; then
var1=$(qsub jobsubmission.sh);
else
var1=$(qsub -W depend=afterok:${var} jobsubmission.sh);
fi
cd ..;
done
</code></pre>
<p>The script goes into a directory, submits a job then goes into the next directory and submits a job based on dependancy of the job created in the first loop. The problem in this script is that the variable "var" is not taking the value of variable assigned in the before loop. Please suggest a way.</p>
| [
{
"answer_id": 74151962,
"author": "Sefa Şahinoğlu",
"author_id": 6658596,
"author_profile": "https://Stackoverflow.com/users/6658596",
"pm_score": -1,
"selected": false,
"text": "type color = 'white' | 'black' | String; \n"
},
{
"answer_id": 74152003,
"author": "Titian Cerni... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4729471/"
] |
74,151,925 | <p>I am trying to prove a property in Dafny, which makes use of powers.</p>
<p>Concretely, this one: <code>forall x,y in Reals : 2xy <= x^2+y^2</code>. I implemented this idea in the following lemma:</p>
<pre><code>lemma product2_lessEqual_powProduct (x:real, y:real)
requires 0.0<x<=1.0 && 0.0<y<=1.0
ensures 2.0*x*y <= (x*x)+(y*y)
{}
</code></pre>
<p>Which is verified with no problem (I guess some automatic induction is performed below).</p>
<p>However, I would like to use an own <code>power</code> function in order to make <code>power(x,2)</code> instead of <code>x*x</code>. Thus, I took a power function from <a href="https://github.com/bor0/dafny-tutorial/blob/master/pow.dfy" rel="nofollow noreferrer">https://github.com/bor0/dafny-tutorial/blob/master/pow.dfy</a>, which is as follows:</p>
<pre><code>function method power(A:int, N:nat):int
{
if (N==0) then 1 else A * power(A,N-1)
}
method pow(A:int, N:int) returns (x:int)
requires N >= 0
ensures x == power(A, N)
{
x := 1;
var i := N;
while i != 0
invariant x == power(A, (N-i))
{
x := x * A;
i := i - 1;
}
}
</code></pre>
<p>However, since I am using real values for the basis of the exponential, I modified it a bit so that it works for exponentials:</p>
<pre><code>function method power(A:real, N:nat):real
{
if (N==0) then 1.0 else A * power(A,N-1)
}
method pow(A:real, N:int) returns (x:real)
requires N >= 0
ensures x == power(A, N)
{
x := 1.0;
var i := N;
while i != 0
invariant x == power(A, (N-i))
{
x := x * A;
i := i - 1;
}
}
</code></pre>
<p>Thus, I wanted to test it with the previous lemma:</p>
<pre><code>lemma product2_lessEqual_powProduct (x:real, y:real)
requires 0.0<x<=1.0 && 0.0<y<=1.0
ensures 2.0*x*y <= power(x,2)+power(y,2)
{}
</code></pre>
<p>Surprisingly, it tells me the typical <code>A postcondition might not hold on this return path.Verifier</code>.</p>
<p>Can anyone explain why this happens? Why is it verifying with primitive operations of Dafny, but not when I define them functions? And how could I prove this lemma now?</p>
| [
{
"answer_id": 74151962,
"author": "Sefa Şahinoğlu",
"author_id": 6658596,
"author_profile": "https://Stackoverflow.com/users/6658596",
"pm_score": -1,
"selected": false,
"text": "type color = 'white' | 'black' | String; \n"
},
{
"answer_id": 74152003,
"author": "Titian Cerni... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14082385/"
] |
74,151,943 | <p>The data table has customers, products sales etc.
Based on a slicer selection products i want to count how many customers have sales in all selected products.
As below i only want to count customer B because he is the only one having all selected products</p>
<pre><code>Customer a Product a product b product c
A. 1 1
B. 1 1 1
C. 1
D. 1 1
E. 1 1
</code></pre>
| [
{
"answer_id": 74151962,
"author": "Sefa Şahinoğlu",
"author_id": 6658596,
"author_profile": "https://Stackoverflow.com/users/6658596",
"pm_score": -1,
"selected": false,
"text": "type color = 'white' | 'black' | String; \n"
},
{
"answer_id": 74152003,
"author": "Titian Cerni... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299811/"
] |
74,151,966 | <p>I just want to know that how we can pass multiple variable or parameter in the message body by using the Spring boot.</p>
<p>Want to pass more than two variable in the postman as a parameter.</p>
| [
{
"answer_id": 74151962,
"author": "Sefa Şahinoğlu",
"author_id": 6658596,
"author_profile": "https://Stackoverflow.com/users/6658596",
"pm_score": -1,
"selected": false,
"text": "type color = 'white' | 'black' | String; \n"
},
{
"answer_id": 74152003,
"author": "Titian Cerni... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13031185/"
] |
74,151,987 | <p>I receive JSON data from the service, but the keys change in the data with each request, below I will give an example in three versions.</p>
<p>Exmaple 1:</p>
<pre><code>{
"trackingPayloads": {
"Rltyn4gLRIWRKj9kS0YpWXytG81GZwcPWjEE7f31ALlq": "{"title":"Red Shoes","index":3,"id":"17777","type":"category"}',
"ywtA6OyM0hzVZZvnUjxoxJDI1Er9ArfNr8XKyi1D5Zzk": "{"title":"White Shoes","index":3,"id":"17777","type":"category"}',
}
}
</code></pre>
<p>Example 2:</p>
<pre><code>{
"trackingPayloads": {
"36tW7DqZ3H9KKBEAumZmowmUwmDRmVCjQgv5zi9GM3Kz": "{"title":"Red Shoes","index":3,"id":"17777","type":"category"}',
"OgtE51n3YtvrVXWLFjPmpnRt2k5DExF7ovxmBTZrZ6wV": "{"title":"White Shoes","index":3,"id":"17777","type":"category"}',
}
}
</code></pre>
<p>Example 3:</p>
<pre><code>{
"trackingPayloads": {
"k2toY29glt2JEp9Wi1X5M7ocno0E0mS4JQVyDuGyQ2rM": "{"title":"Red Shoes","index":3,"id":"17777","type":"category"}'",
"5ef2ec3c3573eebecc9690b69619ec7b9c93b609": "{"title":"White Shoes","index":3,"id":"17777","type":"category"}',
}
}
</code></pre>
<p>As you can see, the data included in the keys does not change since I am requesting the same information, but the key will change with each request.</p>
<p>Please help, what are the options to get the data Title, Index and any other content in these keys using node js?</p>
<p>Only one option came to my mind - to rename the keys upon receipt in 1,2,3 ... and then get data from them, but this needs to be done dynamically, since about 120 requests per minute are made, you need to get this data quickly, there are no options to save it to a file (I didn’t understand how)</p>
<p>UPDATE, added my code.</p>
<p>I am attaching an example of my code, the idea is to eventually get the data I need from the right keys from trackingPayloads, please help with the code <3</p>
<pre><code>const AwaitAPIResponse = await ProductAPI(product_sku);
const $ = cheerio.load(AwaitAPIResponse);
const JSONDATA = [];
$('pre').each(function() {
JSONDATA.push($(this).text());
});
const ProductJson = JSON.parse(JSONDATA[0]) // this is where I get all the data
const MainJson = ProductJson["trackingPayloads"] // here I go to the trackingPayloads you saw above
</code></pre>
<p>How can I get the data I need?</p>
| [
{
"answer_id": 74152063,
"author": "no_modules",
"author_id": 19835828,
"author_profile": "https://Stackoverflow.com/users/19835828",
"pm_score": 1,
"selected": false,
"text": "const convert = object => {\n const ret = []\n for (const key of Object.keys(object)) {\n ret.push... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74151987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299768/"
] |
74,152,000 | <p>I need to round prices for my client in a non-common way :</p>
<pre><code>120.28 => 120.2
130.23 => 130.2
150.64 => 150.6
</code></pre>
<p>The rule is to always keep the nearest lowest 1 precision.</p>
<p>I try to use the <code>round()</code> method but all my tries are useless since this method handle half which i have to ignore.</p>
<p><code>ceil()</code> and <code>floor()</code> will not work out of the box.</p>
<p>Is a combination of those 3 methods would work ?</p>
| [
{
"answer_id": 74152092,
"author": "KIKO Software",
"author_id": 3986005,
"author_profile": "https://Stackoverflow.com/users/3986005",
"pm_score": 2,
"selected": true,
"text": "0.1 * intval(10 * $price)"
},
{
"answer_id": 74153229,
"author": "jspit",
"author_id": 7271221,... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3333246/"
] |
74,152,013 | <p>I am trying to load the parquet file with row size group = 10 into duckdb table in chunks. I am not finding any documents to support this.</p>
<p>This is my work so on: see code</p>
<pre><code>import duckdb
import pandas as pd
import gc
import numpy as np
# connect to an in-memory database
con = duckdb.connect(database='database.duckdb', read_only=False)
df1 = pd.read_parquet("file1.parquet")
df2 = pd.read_parquet("file2.parquet")
# create the table "my_table" from the DataFrame "df1"
con.execute("CREATE TABLE table1 AS SELECT * FROM df1")
# create the table "my_table" from the DataFrame "df2"
con.execute("CREATE TABLE table2 AS SELECT * FROM df2")
con.close()
gc.collect()
</code></pre>
<p>Please help me load both the tables with parquet files with row group size or chunks. ALso, load the data to duckdb as chunks</p>
| [
{
"answer_id": 74163397,
"author": "shetty15",
"author_id": 6563567,
"author_profile": "https://Stackoverflow.com/users/6563567",
"pm_score": 1,
"selected": false,
"text": "df1 = pd.read_parquet(\"file1.parquet\")\n"
},
{
"answer_id": 74184230,
"author": "AlexMonahan",
"a... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20271577/"
] |
74,152,016 | <p>It is Category's Filter component develop</p>
<p>Need To Render Data from Nested Array and Render it with React Js</p>
<p>I Try To Do it As Below it is Showing but it is Rendering Nothing</p>
<p>Focus part is render part only</p>
<pre><code>var selectedCategory = {filter_name: "Category"}
</code></pre>
<p>Array With Object is :</p>
<pre><code> var selectedOptions = [
{
filter_name: "Category",
attribute_code: "category_id",
attribute_input_type: "",
filter_options: [
{
label: "Brands",
value: "465",
count: "10",
},
{
label: "Perfumes",
value: "789",
count: "1425",
},
],
selectedOptions: ["465"],
filter_min_price: null,
filter_max_price: null,
},
{
filter_name: "Price",
attribute_code: "price",
attribute_input_type: "price",
filter_options: [
{
label: "BHD 10,000 - BHD 0",
value: "0.00-10000-0",
count: "1",
},
{
label: "BHD 0 - BHD 10,000",
value: "0.00-10000",
count: "5953",
},
],
filter_min_price: "BHD -12",
filter_max_price: "BHD 24481",
selectedOptions: ["0.00-10000-0"],
},
];
</code></pre>
<p>I have Render It with this way by using too many map and i don't know is there any easy way to do it or not, code is given below</p>
<pre><code><div className="product-catres">
{selectedOptions &&
selectedOptions.length > 0 &&
selectedOptions.map((option) => {
{
option.filter_name === selectedCategory.filter_name &&
option.filter_options.map((option) => {
return (
<div key={option.value} className="pcoption">
<div className="form-check">
<label className="form-check-label">
<input
className="form-check-input"
type="checkbox"
onChange={() => handleSelectedFilterOptions(option.value)}
checked={
selectedOptions &&
selectedOptions.includes(option.value)
? true
: false
}
/>
{option.label}
</label>
</div>
</div>
);
});
}
})}
</div>;
</code></pre>
<p>Thanks in Advance For Helping Me out</p>
| [
{
"answer_id": 74152117,
"author": "Zein",
"author_id": 15161581,
"author_profile": "https://Stackoverflow.com/users/15161581",
"pm_score": 1,
"selected": false,
"text": "{selectedOptions &&\n selectedOptions.length > 0 &&\n selectedOptions.map((option) => \n option.fi... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10481624/"
] |
74,152,019 | <p>hey guys i have looked around for a solution and tried everything i can think of im new to pointers and dynamic strings and i could really do with some help with problem. im currently learning c and i need to get the user to input a dynamic size for the string length . i need to make it so the users input can not be bigger then 100 . here's where i am at currently . i have the code booting but if i try set the size to let's say 5 i can still input way more chars into the string. cheers really appreciate any help .</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
int maxSize = 100;
char *name = (char*) malloc (maxSize * sizeof (char));
int n;
char text1[]= ("input string size\n");
printf ("your string lenght is %d\n", strlen(name));
//getting size
n=intPrintScanner(text1);
printf ("your size is %d\n",n);
name = realloc (name, sizeof (char) * n);
//printing results
printf ("your string lenght is %d\n",strlen (name));
scanf("%s", name);
printf("your string is %s",name);
free(name);
fflush(stdin);
printf("press any key to close");
getchar();
return (0);
}
</code></pre>
| [
{
"answer_id": 74152792,
"author": "Martí Ferret Cedó",
"author_id": 20284153,
"author_profile": "https://Stackoverflow.com/users/20284153",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h>\n#include <ctype.h>\n#include <string.h>\n#include <stdlib.h>\n#include <unistd.h>\n\... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18014747/"
] |
74,152,022 | <p>So I got the latitude and longitude and successfully saved it on firebase, and now I was able to retrieve it and paste their values on a TextView.</p>
<p>I am planning to get the string value from the TextView and convert it to double and use that as a latitude and longitude to show a location on a map. I followed the format for converting string value to double value and it still wont work.</p>
<p>This is my code:</p>
<p>@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;</p>
<pre><code> String latitude = textViewLatt.getText().toString();
String longitude = textViewLong.getText().toString();
//Double latitude = Double.valueOf(textViewLatt.getText().toString());
//Double longitude = Double.valueOf(textViewLong.getText().toString());
double latt = Double.parseDouble(latitude);
double longi= Double.parseDouble(longitude);
//double latt = Double.valueOf(latitude);
//double longi = Double.valueOf(longitude);
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(latt, longi);
mMap.addMarker(new MarkerOptions()
.position(sydney)
.title("Marker"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
</code></pre>
<p>and these are the errors I got from debugging, I tried to search the problem and I couldnt find any solutions. Any help will be great.</p>
<p><a href="https://i.stack.imgur.com/PviBI.png" rel="nofollow noreferrer">enter image description here</a></p>
<p><a href="https://i.stack.imgur.com/eU9Ax.png" rel="nofollow noreferrer">enter image description here</a></p>
| [
{
"answer_id": 74152792,
"author": "Martí Ferret Cedó",
"author_id": 20284153,
"author_profile": "https://Stackoverflow.com/users/20284153",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h>\n#include <ctype.h>\n#include <string.h>\n#include <stdlib.h>\n#include <unistd.h>\n\... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19741271/"
] |
74,152,035 | <p>So i have a laravel project with multiple role's
(admin, partner, dealer)
as a dealer and partner i can download files that are assigned to me using a pivot table.</p>
<p>as a partner i can see 1 file that is assigned to my role to be able to be downloaded. but in my database i have multiple files that a dealer can download.
but i am also able to download all the files as a partner if i edit the link:
http://localhost:8000/partner/download/{file id i want to download}.</p>
<p>i want to secure this so i can only download files that are assigned to that specific role.</p>
<p>table file:</p>
<ul>
<li>Id</li>
<li>name</li>
<li>language</li>
<li>file(downloadable)</li>
</ul>
<p>table user:</p>
<ul>
<li>Id</li>
<li>name</li>
<li>role_id</li>
</ul>
<p>table role;</p>
<ul>
<li>id</li>
<li>name</li>
</ul>
<p>table download (pivot of file and user):</p>
<ul>
<li>id</li>
<li>file_id</li>
<li>user_id</li>
</ul>
<p>controller for the download:</p>
<pre><code> public function download(Request $request, int $fileId)
{
$id = Auth::user();
$fullfile = File::find($fileId);
$downloadfile = File::find($fullfile, ['file'])->pluck('file')->last();
return response()->download($downloadfile);
$fullfile->userfile()->attach($id);
return back();
}
</code></pre>
<p>web.php</p>
<pre><code>Route::group(['middleware' => 'role:partner', 'prefix' => 'partner', 'as' => 'partner.'], function(){
Route::resource('/dashboard', App\Http\Controllers\partner\PartnerController::class);
Route::resource('/profile', App\Http\Controllers\partner\ProfileController::class);
Route::resource('/file', App\Http\Controllers\partner\FileController::class);
Route::get('/download/{fileId}',[FileController::class, 'download'])->name('file.download');
});
</code></pre>
<p>index.blade.php</p>
<pre><code><tbody>
@foreach($files as $file)
<tr>
<td>{{$file->title}} </td>
<td>
<a class="btn btn-big btn-succes" style="background: orange;" href="{{ route('partner.file.show', $file->id) }}">View</a>
</td>
<td>
<a class="btn btn-big btn-succes" style="background: green;" href="{{ route('partner.file.download', $file->id) }}" >Download</a>
</td>
<td>{{@$file->language->name}} </td>
@foreach($file->tag as $tags)
<td style="background:{{$tags['color']}} ;">{{@$tags->name}} </td>
@endforeach
</tr>
@endforeach
</tbody>
```
</code></pre>
| [
{
"answer_id": 74152792,
"author": "Martí Ferret Cedó",
"author_id": 20284153,
"author_profile": "https://Stackoverflow.com/users/20284153",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h>\n#include <ctype.h>\n#include <string.h>\n#include <stdlib.h>\n#include <unistd.h>\n\... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19923550/"
] |
74,152,065 | <p>I have a dataframe <code>df1</code> like this:</p>
<p><a href="https://i.stack.imgur.com/HqICx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HqICx.png" alt="enter image description here" /></a></p>
<p>and another dataframe <code>df2</code> like this:</p>
<p><a href="https://i.stack.imgur.com/yAcsO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yAcsO.png" alt="enter image description here" /></a></p>
<p>How could I join <code>df2</code> with <code>df1</code> using left join so that my output would look like the following?</p>
<p><a href="https://i.stack.imgur.com/HK5Nb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HK5Nb.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74152337,
"author": "ZygD",
"author_id": 2753501,
"author_profile": "https://Stackoverflow.com/users/2753501",
"pm_score": 2,
"selected": true,
"text": "split"
},
{
"answer_id": 74153781,
"author": "stack0114106",
"author_id": 6867048,
"author_profile":... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4057692/"
] |
74,152,077 | <p>I have class for take values inside loop as this :</p>
<p><code>$db_user->take_phone[1];</code></p>
<p>Inside loop I need take different values for the class</p>
<pre class="lang-php prettyprint-override"><code>$a=array("phone","name","street");
foreach($a as $aa) {
echo $db_user->take_'$aa.'[1]
}
</code></pre>
<p>As you can see inside the loop I need to change the value inside <code>take_$string</code>, but it doesn't work. I suppose there is a syntax error but I'm not sure. How can I write this to work correctly.</p>
<p>I've tried different ways but haven't found a solution.</p>
| [
{
"answer_id": 74152337,
"author": "ZygD",
"author_id": 2753501,
"author_profile": "https://Stackoverflow.com/users/2753501",
"pm_score": 2,
"selected": true,
"text": "split"
},
{
"answer_id": 74153781,
"author": "stack0114106",
"author_id": 6867048,
"author_profile":... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18206958/"
] |
74,152,081 | <p>'So question was to find pytho triplet using the number inputted but number has to be greater than one and natural.</p>
<p>The error I am facing is that suppose I enter -4, then it runs method again and asks me to enter number again and I enter suppose 9 but while printing final statement, it prints triplets of both -4 and 9. How can I fix it as I only want triplet of 9 to be printed?</p>
<p><a href="https://i.stack.imgur.com/WHvTo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WHvTo.png" alt="" /></a></p>
<pre><code>import java.util.*;
public class Pythagorean_Triplet
{
private static int a;
public static void main(String[]args) //main method
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter number to find Pythagorean Triplet : ");
int a=sc.nextInt();
if(a<2) //our program only works on natural numbers greater than 1
{
System.out.println("");
System.out.println("Your number is not a natural number or is 1");
System.out.println();
main(args);
}
double p1= 2*a;
double p2=Math.pow(a,2) - 1;
double p3=Math.pow(a,2) + 1;
System.out.println("");
System.out.println(p1 + ", " + p2 + " and " + p3 + " form a 'Pythagorean Triplet'");
}
}
</code></pre>
| [
{
"answer_id": 74152180,
"author": "SimGel",
"author_id": 6300032,
"author_profile": "https://Stackoverflow.com/users/6300032",
"pm_score": 2,
"selected": false,
"text": "main(args);"
},
{
"answer_id": 74152262,
"author": "David",
"author_id": 328193,
"author_profile"... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20299966/"
] |
74,152,106 | <p><strong>I need to set the values while creating the inventory item form, I deployed the script in the corresponding form, and it is working as I tried to send an email. For this, it is working,
But I don't know when I tried but nothing happened.</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code> <!-- /**
*@NApiVersion 2.0
*@NScriptType UserEventScript
*/
define(["N/url", "N/record", "N/runtime"], function (url, record, runtime) {
function afterSubmit(context){
var recordobj = context.newRecord;
var Type=context.type;
if(Type== context.UserEventType.CREATE)
recordobj.setValue({
fieldId:'custitem27',
Value:'something',
});
}
return{
afterSubmit:afterSubmit
}
});
--></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74152180,
"author": "SimGel",
"author_id": 6300032,
"author_profile": "https://Stackoverflow.com/users/6300032",
"pm_score": 2,
"selected": false,
"text": "main(args);"
},
{
"answer_id": 74152262,
"author": "David",
"author_id": 328193,
"author_profile"... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19985030/"
] |
74,152,122 | <p>I am trying to make condition for data vlidation in Google Sheets but i am stuck that how it can be achieve.</p>
<p>Let me explain it. Data validation will be applied on Column <code>A</code> based on adjacent 4 columns value.</p>
<p>I have achieved one of them that if mentioned columns are not empty then you will be able to put a value in column <code>A</code> but i want that if that condition achieved then one can only put <code>Date</code> like <code>DD/MM/YYYY</code> in such format</p>
<pre><code>=AND($B$3:$B$700<>"",$C$3:$C$700<>"",$D$3:$D$700<>"",$E$3:$E$700<>"")
</code></pre>
<p>But i need to create one more condition that if Column <code>B</code> is not empty then we can add only <code>"P"</code> into Column <code>A</code>.</p>
<p>Any help will be much appreciated.</p>
<p><strong>Result Required like in columnA</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>columnA</th>
<th>columB</th>
<th>columC</th>
<th>columD</th>
<th>columE</th>
</tr>
</thead>
<tbody>
<tr>
<td>25/11/2022</td>
<td>256</td>
<td>MNO</td>
<td>256</td>
<td>POP</td>
</tr>
<tr>
<td>condition not met</td>
<td>JKL</td>
<td></td>
<td></td>
<td>POP</td>
</tr>
<tr>
<td>condition not met</td>
<td>POP</td>
<td>MNO</td>
<td>MNO</td>
<td></td>
</tr>
<tr>
<td>25/11/2022</td>
<td>JKL</td>
<td>POP</td>
<td>256</td>
<td>JKL</td>
</tr>
<tr>
<td>condition not met</td>
<td>257</td>
<td>MNO</td>
<td>257</td>
<td></td>
</tr>
<tr>
<td>condition not met</td>
<td>JKL</td>
<td></td>
<td></td>
<td>POP</td>
</tr>
<tr>
<td>P</td>
<td>POP</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>condition not met</td>
<td>JKL</td>
<td></td>
<td>257</td>
<td>JKL</td>
</tr>
<tr>
<td>P</td>
<td>258</td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p><a href="https://docs.google.com/spreadsheets/d/1qUU5rmkLe-JqmSAwi-5bTV5JoogiDLPavBGGy8GiEkw/edit?usp=sharing" rel="nofollow noreferrer">Link to Sheet</a></p>
| [
{
"answer_id": 74153012,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 3,
"selected": true,
"text": "=(ISDATE(A2)*(B2<>\"\")*(C2<>\"\")*(D2<>\"\")*(E2<>\"\"))+((A2=\"P\")*(B2<>\"\"))\n"
},
{
"answer_id": 741531... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16968735/"
] |
74,152,131 | <pre><code>Future<String> task2() async {
Duration three = const Duration(seconds: 3);
String result;
await Future.delayed(three, () {
result = 'task 2 data';
});
return result;
}
</code></pre>
<blockquote>
<p>The non nullable local variable 'result' must be assigned before it can be used.</p>
</blockquote>
<p>now if i assign it a value on initiation or add a null check, the function just returns that value and not the intended value <code>task 2 data</code></p>
<p>Can someone identify the problem and help me resolve it.</p>
| [
{
"answer_id": 74153012,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 3,
"selected": true,
"text": "=(ISDATE(A2)*(B2<>\"\")*(C2<>\"\")*(D2<>\"\")*(E2<>\"\"))+((A2=\"P\")*(B2<>\"\"))\n"
},
{
"answer_id": 741531... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19728013/"
] |
74,152,179 | <p>I have this elastic search function that match two conditions.
But now "type" is optional and I want return all cookies if type is not set and if type is set I want the same result as in the query below. Type is an enum (if that matters).</p>
<pre><code>export const searchCookies: HttpFunction = enrichCloudFunction(async (req, res) => {
const {
query: { type, cookies, from, size },
} = validateCookieQuery(req)
const {
hits: { hits },
} = await elastic.search<ExtendedStuff>({
from: from || 0,
index: cookieIndex({ prefix: config.prefix }),
query: {
bool: {
must: [
{
match: { 'cookie.id': cookie },
},
{
match: { type },
},
],
},
},
size: size || 20,
})
res.json(hits.map((x) => x._source))
})
</code></pre>
<p>This might be a super trivial thing but this is the first time I am using elastic search and I am super confused.</p>
| [
{
"answer_id": 74153012,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 3,
"selected": true,
"text": "=(ISDATE(A2)*(B2<>\"\")*(C2<>\"\")*(D2<>\"\")*(E2<>\"\"))+((A2=\"P\")*(B2<>\"\"))\n"
},
{
"answer_id": 741531... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300022/"
] |
74,152,227 | <p>I'm new to coding and I'm making a mini game that depends on different methods (that is the assignment).</p>
<p>In the game there are 3 piles of sticks with 5 sticks in each. I'm trying to make a method that prints the stacks of sticks.</p>
<p>I have made an array with <code>int[] sticks = new int[] = {5, 5, ,5};</code> (3 stacks of 5).</p>
<p>I want to make it visual in the console so the player can see amount of sticks etc.</p>
<p>If I use a method like this can I change the value in the array as they play or do I need to make another method and put it in this one?</p>
<pre class="lang-cs prettyprint-override"><code>static void Stickor(int[] array)
{
foreach (var item in array)
{
for (int i = 0; i <= array.Length; i++)
{
Console.Write(" | ");
}
}
}
</code></pre>
| [
{
"answer_id": 74153012,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 3,
"selected": true,
"text": "=(ISDATE(A2)*(B2<>\"\")*(C2<>\"\")*(D2<>\"\")*(E2<>\"\"))+((A2=\"P\")*(B2<>\"\"))\n"
},
{
"answer_id": 741531... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20265050/"
] |
74,152,230 | <p>I have a dataframe with consecutive values, is it possible to make = 0 the numbers after 1s?</p>
<pre><code>df <- data.frame(a = c(0,0,0,0,1,1,1,0,0,0),
b = c(0,0,1,1,1,1,0,0,0,0),
c = c(1,1,0,0,0,0,0,1,1,0))
</code></pre>
<p>like this:</p>
<p><a href="https://i.stack.imgur.com/RajKQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RajKQ.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74152348,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "library(dplyr)\ndf %>% \n mutate(across(everything(), ~ +(.x == 1 & lag(.x, default = 0) != 1)))\n"
},
{
"an... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20176942/"
] |
74,152,374 | <p>I tried other examples from stackoverflow but none of which worked out for me (idk if i'm allowed to share them in the description)</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code> var offerBTN = document.getElementsByClassName("button");
var title = document.getElementsById("button_title");
var subtitle = document.getElementsById("subtitle");
offerBTN.addEventListener('mouseenter', function () {
title.style.color = "rgb(170, 170, 170)";
subtitle.style.color = "rgb(170, 170, 170)";
})
offerBTN.addEventListener('mouseup', function () {
title.style.color = "rgb(170, 170, 170)";
subtitle.style.color = "rgb(0, 0, 0)";
})
offerBTN.addEventListener('mouseleave', function () {
title.style.color = "rgb(200, 100, 100)";//unselected
subtitle.style.color = "rgb(100, 200, 100)";
})
offerBTN.addEventListener('mousedown', function () {
title.style.color = "rgb(100, 200, 100)";
subtitle.style.color = "rgb(100, 100, 200)";//selected
})</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <button class="button">
<h3 id="button_title">Job Position 10 ></h3>
<p id="subtitle">City, Country | Department | Keyword</p>
</button>
</code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74152466,
"author": "Takkie253",
"author_id": 14461286,
"author_profile": "https://Stackoverflow.com/users/14461286",
"pm_score": 0,
"selected": false,
"text": ".button:hover {\n color: red;\n}\n"
},
{
"answer_id": 74152481,
"author": "aakk",
"author_id": ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14808884/"
] |
74,152,434 | <p>I have a table with several fields on which I need to do data quality checks.</p>
<p>The data quality checks are defined as rules in a second table.</p>
<p><strong>Data Table:</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">ID</th>
<th style="text-align: center;">Name1</th>
<th style="text-align: right;">Name2</th>
<th style="text-align: right;">Zip1</th>
<th style="text-align: right;">Zip2</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">001</td>
<td style="text-align: center;">John</td>
<td style="text-align: right;">John</td>
<td style="text-align: right;">123</td>
<td style="text-align: right;">123</td>
</tr>
<tr>
<td style="text-align: left;">002</td>
<td style="text-align: center;">Sara</td>
<td style="text-align: right;">Sarah</td>
<td style="text-align: right;">234</td>
<td style="text-align: right;">234</td>
</tr>
<tr>
<td style="text-align: left;">003</td>
<td style="text-align: center;">Bill</td>
<td style="text-align: right;">William</td>
<td style="text-align: right;">999</td>
<td style="text-align: right;">111</td>
</tr>
<tr>
<td style="text-align: left;">004</td>
<td style="text-align: center;">Lisa</td>
<td style="text-align: right;">Lisa</td>
<td style="text-align: right;">888</td>
<td style="text-align: right;">333</td>
</tr>
<tr>
<td style="text-align: left;">005</td>
<td style="text-align: center;">Martin</td>
<td style="text-align: right;">Martin</td>
<td style="text-align: right;">345</td>
<td style="text-align: right;">345</td>
</tr>
<tr>
<td style="text-align: left;">006</td>
<td style="text-align: center;">Margaret</td>
<td style="text-align: right;">Margaret</td>
<td style="text-align: right;">456</td>
<td style="text-align: right;">456</td>
</tr>
<tr>
<td style="text-align: left;">007</td>
<td style="text-align: center;">Oscar</td>
<td style="text-align: right;">Oscar</td>
<td style="text-align: right;">678</td>
<td style="text-align: right;">678</td>
</tr>
<tr>
<td style="text-align: left;">008</td>
<td style="text-align: center;">Peter</td>
<td style="text-align: right;">Peter</td>
<td style="text-align: right;">789</td>
<td style="text-align: right;">789</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Rule Table:</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">ID</th>
<th style="text-align: center;">FieldLeft</th>
<th style="text-align: right;">FieldRight</th>
<th style="text-align: right;">ComparisonOperation</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">R001</td>
<td style="text-align: center;">Name1</td>
<td style="text-align: right;">Name2</td>
<td style="text-align: right;">EQUALS</td>
</tr>
<tr>
<td style="text-align: left;">R002</td>
<td style="text-align: center;">Zip1</td>
<td style="text-align: right;">Zip2</td>
<td style="text-align: right;">EQUALS</td>
</tr>
</tbody>
</table>
</div>
<p>So the rules essentially are saying: Name1=Name2 and Zip1=Zip2</p>
<p>The expected output is the records that are non-compliant with the rules.
It should produce one row per rule violation (see for record 003, both the name and the zip are inconsistent -> so two lines are in the result for record 003).</p>
<p><strong>Output:</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Rule</th>
<th style="text-align: center;">ID</th>
<th style="text-align: right;">FieldLeft</th>
<th style="text-align: right;">FieldRight</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">R001</td>
<td style="text-align: center;">002</td>
<td style="text-align: right;">Sara</td>
<td style="text-align: right;">Sarah</td>
</tr>
<tr>
<td style="text-align: left;">R001</td>
<td style="text-align: center;">003</td>
<td style="text-align: right;">Bill</td>
<td style="text-align: right;">William</td>
</tr>
<tr>
<td style="text-align: left;">R002</td>
<td style="text-align: center;">003</td>
<td style="text-align: right;">999</td>
<td style="text-align: right;">111</td>
</tr>
<tr>
<td style="text-align: left;">R002</td>
<td style="text-align: center;">004</td>
<td style="text-align: right;">888</td>
<td style="text-align: right;">333</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74161066,
"author": "iambdot",
"author_id": 1415826,
"author_profile": "https://Stackoverflow.com/users/1415826",
"pm_score": 2,
"selected": true,
"text": "from pyspark.sql import functions as F\nfrom pyspark.sql.types import *\n\ndf = spark.createDataFrame(\n [\n ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/501810/"
] |
74,152,483 | <p>What would the php code be to change the add to cart text to something unique for each product category, on both the product archives and single product pages using one code snippet if possible? I have six product categories. I am using WooCommerce.</p>
<p>Basically, I have 6 categories, I'd like 5 of them to say "Order" and then 1 of them to say "Book Now"</p>
<p>The 6 categories are:</p>
<ol>
<li>Cakes</li>
<li>Cupcakes</li>
<li>Halloween</li>
<li>Sweet Treats</li>
<li>Petal and Post</li>
<li>Baking Class</li>
</ol>
<p>i.e. all of the categories except for "Baking Class" will say Order, while "Baking Class" will say "Book Now".</p>
<p>I'd like to apply to the buttons all over the website, no matter where they are displayed.</p>
<p>I am using Elementor to create custom Product Archives.</p>
<p>Update 25th October, 2022:</p>
<p>I have tried using the code from mujuonly's answer below. It works except for on the product archive for the Baking Classes category; which I designed using Elementor Pro: <a href="https://bunsbakery.co.za/product-category/baking-classes/" rel="nofollow noreferrer">https://bunsbakery.co.za/product-category/baking-classes/</a></p>
<p>Here is the code I used:</p>
<pre><code>add_filter('woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text', 10, 2);
add_filter('woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text', 10, 2);
function woocommerce_custom_product_add_to_cart_text($text, $product) {
if( has_term( array( 'Cakes', 'Cupcakes', 'Halloween', 'Sweet Treats', 'Petal and Post' ), 'product_cat', $product->get_id() ) ){
$text = __('Order', 'woocommerce');
}
if( has_term( array( 'baking-classes' ), 'product_cat', $product->get_id() ) ){
$text = __('Book Now', 'woocommerce');
}
return $text;
}
</code></pre>
| [
{
"answer_id": 74152810,
"author": "Stender",
"author_id": 4244684,
"author_profile": "https://Stackoverflow.com/users/4244684",
"pm_score": 0,
"selected": false,
"text": "// To change add to cart text on product archives(Collection) page\nadd_filter( 'woocommerce_product_add_to_cart_tex... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300092/"
] |
74,152,501 | <p>I want to add a simple row with two texts in one of the screens in JetpackCompose but I don't know why views are not showing.</p>
<p><strong>Note: Other screens are showing correctly but when I replace the below codes with that screen, I have the same issue</strong></p>
<pre><code> Box(modifier = Modifier.fillMaxSize()) {
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "test".convertToPersianDigits(),
fontFamily = shabnamFontFamily,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.secondary,
textAlign = TextAlign.End
)
Spacer(modifier = Modifier.width(16.dp))
Text(
text = "Test1",
fontFamily = shabnamFontFamily,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.secondary,
fontSize = 16.sp,
fontWeight = FontWeight.ExtraBold
)
}
}
}
</code></pre>
<p><a href="https://i.stack.imgur.com/WZPDx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WZPDx.png" alt="enter image description here" /></a></p>
<p><strong>If I add a padding modifier to <code>Box</code> or <code>Column</code>, Or change the <code>Text</code> <code>FontSize</code>, I can see a part of the text:</strong>
<a href="https://i.stack.imgur.com/WFETi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WFETi.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74152853,
"author": "Saeed Noshadi",
"author_id": 10635762,
"author_profile": "https://Stackoverflow.com/users/10635762",
"pm_score": 0,
"selected": false,
"text": "MainActivity"
},
{
"answer_id": 74153921,
"author": "Gabriele Mariotti",
"author_id": 201656... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10635762/"
] |
74,152,513 | <p>I am actuually writting unittests on a project.
While I am writting test functions, I am used to <em>mock</em> some function.</p>
<p>Recently, I am trying to mock a function that should write into a file.
Problem: This funct</p>
<p>Like below:</p>
<pre class="lang-py prettyprint-override"><code># file A.py
def write_to_file(message, file="test.txt"):
with open(file, "w") as fh:
fh.write(message)
# File B.py
from A import write_to_file
def part_of_a_big_feature():
# Do some things
write_to_file("bla")
# Do some things
# File feature.py
from B import part_of_a_big_feature
def feature():
# First part is for a specific feature
# Second: I called the part_of_a_big_feature
part_of_a_big_feature()
# Then another feature
# Then return
return 1
# file feature.py
import pytest
from C import feature
class TestException(Exception):
pass
class TestFeature:
@staticmethod
def setup_method():
pass
@staticmethod
def teardown_method():
pass
@staticmethod
def test_feature(mocker):
# Mocking
mocker.patch("path.to.A.Bwrite_to_file", return_value=None) # does not work here.
# Tests
assert feature() == 1
# run it with 'pytest -vv test_my_function.py'
</code></pre>
<p>I am looking for the right way to make <em>chain mocking works</em></p>
<p>For more details:</p>
<ul>
<li><p>Imagine a function called "test()" defined in <strong>A.py</strong>.</p>
</li>
<li><p>This function "test()" is imported and used in the file <strong>B.py</strong>, in a function called "function_that_use_test()".</p>
</li>
<li><p>Then, the function "function_that_use_test()" is imported and used in the file <strong>C.py</strong>, in a function called "function_that_use_function_that_use_test()"</p>
</li>
</ul>
<p>It <strong>could be done N times</strong>. How to mock this with pytest-mock?</p>
<p><a href="https://i.stack.imgur.com/y1VoY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y1VoY.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74152853,
"author": "Saeed Noshadi",
"author_id": 10635762,
"author_profile": "https://Stackoverflow.com/users/10635762",
"pm_score": 0,
"selected": false,
"text": "MainActivity"
},
{
"answer_id": 74153921,
"author": "Gabriele Mariotti",
"author_id": 201656... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9947412/"
] |
74,152,520 | <p>I have data that looks like this</p>
<pre><code> Cluster.x Cluster.y n
1 4 8
1 7 1
2 1 2
2 4 4
2 7 1
</code></pre>
<p>And i want to transform it to a crosstable that looks like this</p>
<pre><code> Cluster.y
Cluster.x 1 2 3 4 5 7
1 0 2 0 8 0 1
2 2 0 0 4 0 1
3 0 0 0 0 0 0
4 8 4 0 0 0 0
5 0 0 0 0 0 0
7 1 1 0 0 0 0
</code></pre>
<p>How can i do this transformation? It is important for me, that the table is symmetric and is readable as rows or columns with the same results.</p>
| [
{
"answer_id": 74152715,
"author": "Rui Barradas",
"author_id": 8245406,
"author_profile": "https://Stackoverflow.com/users/8245406",
"pm_score": 2,
"selected": false,
"text": "symMatrix"
},
{
"answer_id": 74152718,
"author": "maydin",
"author_id": 7224354,
"author_pr... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19989317/"
] |
74,152,524 | <p>everyone.
I have a dataset of 1000 rows (nodes and links) with two columns V1 and V2 in txt, which I imported with read.table.
There are rows in the dataset that are reversed, e.g:</p>
<pre><code>net <- read.table("DD242.txt", quote="\"", comment.char="")
V1 V2
4 5
5 4
6 7
7 8
and so on...
</code></pre>
<p>but I do not know which values repeat. How do I find these repeating rows and delete one of them? In this case i want to remove the second row inverted= 5 4. So that I only have:</p>
<pre><code>V1 V2
4 5
6 7
7 8
</code></pre>
<p>Thanks a lot!</p>
| [
{
"answer_id": 74152803,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": true,
"text": "filter"
},
{
"answer_id": 74153011,
"author": "Merijn van Tilborg",
"author_id": 10415749,
"author... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19205242/"
] |
74,152,526 | <p>I am using below commands:</p>
<blockquote>
<p>openssl req -new -newkey -keyout example.key</p>
</blockquote>
<blockquote>
<p>openssl dhparam -out example.pem</p>
</blockquote>
<p>I submit the csr (also generated by openssl not shown above) file to CA which reply with a text file named sighned certificate. This text file has 4 sections each section starts with ----BEGIN CERTIFICATE---- and ends with -----END CERTIFICATE------</p>
<p>Does the first section map to ROOT CERTIFICATE? Does the third section map to INTERMEDIATE CERTIFICATE? What the last section maps to?</p>
<p>I also use keytool to generate keystore.jks file. What is jks file and why it is needed?</p>
<p>Now in redis TLS <a href="https://redis.io/docs/manual/security/encryption/" rel="nofollow noreferrer">docs</a></p>
<pre><code>tls-cert-file /path/to/redis.crt
tls-key-file /path/to/redis.key
tls-ca-cert-file /path/to/ca.crt
tls-dh-params-file /path/to/redis.dh
</code></pre>
<p>What files I use to plugin in above settings?</p>
<p>What is the difference between tls-cert-file and tls-ca-cert-file?</p>
| [
{
"answer_id": 74176164,
"author": "for_stack",
"author_id": 5384363,
"author_profile": "https://Stackoverflow.com/users/5384363",
"pm_score": 0,
"selected": false,
"text": "#!/bin/bash\nmkdir -p tests/tls\nopenssl genrsa -out tests/tls/ca.key 4096\nopenssl req \\\n -x509 -new -nodes ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/574122/"
] |
74,152,585 | <p>I'm trying to put together playbook that works for both Windows and Linux. Now I'm trying to include roles in playbook that will be taken only if Windows or Linux, but it always complains about syntax. I'd appreciate any help on this as I've tried few different approaches and it always failed.</p>
<pre><code>---
- hosts: all
gather_facts: no
pre_tasks:
- name: (localhost) make sure the known_hosts file is cleared
lineinfile:
path: ~/.ssh/known_hosts
state: absent
regexp: "^{{ ansible_host | replace('.', '\\.') }}.*$"
delegate_to: 127.0.0.1
- hosts: all
serial: 1
pre_tasks:
- name: (debug) print out some debug message to confirm inventory is properly set up
debug:
msg: "System inventory_hostname:{{ inventory_hostname }} ansible_host:{{ ansible_host }}"
- hosts: all
tasks:
- name: Install CA Trust Certs Windows
include_tasks: tasks\install-certs-windows.yml
when: ansible_os_family == 'Windows'
- name: Install CA Trust Certs Linux
include_tasks: tasks/install-certs-linux.yml
when: ansible_os_family != 'Windows'
roles:
- { role: ansible-role-runnersbasics, tags: ["basics"] }
- { role: ansible-role-docker, tags: ["docker"] }
- { role: ansible-role-gitlab-runner }
when: ansible_os_family == 'Windows'
</code></pre>
<p>Error:</p>
<pre><code>ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
did not find expected key
The error appears to be in 'playbook.yml': line 33, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- { role: ansible-role-gitlab-runner }
when: ansible_os_family == 'Windows'
^ here
</code></pre>
<p>When removing curly braces from roles and moving when on the same level as roles</p>
<pre><code>ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
mapping values are not allowed in this context
The error appears to be in 'playbook.yml': line 30, column 43, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
roles:
role: ansible-role-runnersbasics, tags: ["basics"] }
^ here
</code></pre>
| [
{
"answer_id": 74176164,
"author": "for_stack",
"author_id": 5384363,
"author_profile": "https://Stackoverflow.com/users/5384363",
"pm_score": 0,
"selected": false,
"text": "#!/bin/bash\nmkdir -p tests/tls\nopenssl genrsa -out tests/tls/ca.key 4096\nopenssl req \\\n -x509 -new -nodes ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10767503/"
] |
74,152,587 | <p><strong>Odoo Server Error</strong></p>
<pre><code>Error while validating view near:
<tree>
<feild name="CustomerDetailIds">
</feild>
1. Tree child can only have one of field, button, control, groupby, widget, header tag (not feild)
</code></pre>
<p><strong>Code XML:</strong></p>
<pre><code> <record id="view_tailor_detail_form" model="ir.ui.view">
<field name="name">tailor detail form</field>
<field name="model">tailor.data.detail</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="name"/>
<field name="Phone"/>
</group>
<group>
<field name="table_no"/>
<field name="Catagory"/>
<field name="costumer_detail_id"/>
</group>
</group>
<notebook>
<page string="Customer detail">
<tree>
<feild name="CustomerDetailIds">
</feild>
<feild name="C_ids">
</feild>
<feild name="details">
</feild>
</tree>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
</code></pre>
<blockquote>
<p>But when I remove the tree tag it works fine but not find any output fields on UI side.</p>
</blockquote>
| [
{
"answer_id": 74241114,
"author": "Bhavesh Odedra",
"author_id": 2926754,
"author_profile": "https://Stackoverflow.com/users/2926754",
"pm_score": 1,
"selected": true,
"text": "<field name=\"one2many_field\">\n <tree>\n <field name=\"x\">\n <field name=\"y\">\n </tre... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19895624/"
] |
74,152,611 | <blockquote>
<p>given two arrays I'm trying to get all the different combinations of the arrays with no repeats of sequences and without using itertools. My problem comes when I try to combine a 2 dimensional array with a 1 dimensional array. given arrays [1,2],[1,3],[1,4],[2,3],[2,4] and [1,2,3,4] I want it to yield [1,2,3],[1,2,4],[1,3,4],[2,3,4]. currently it will produce [1,2,3], [1,2,4] and [1,3,4] but not [2,3,4] and I can't figure out why.</p>
</blockquote>
<pre><code>change_array = [1,2],[1,3],[1,4],[2,3],[2,4]
base_array = [1,2,3,4]
save_array = []
def candidate_generation2(change_array, base_array, save_array):
current_iteration = []
for x in range(0, len(change_array)):
d = []
for y in range(0, len(change_array[0])):
d.append(change_array[x][y])
for z in range(x + 1, len(base_array)):
e = d.copy()
tag = 0
for a in range(0, len(e)):
if e[a] == base_array[z]:
tag = 1
if tag == 0:
e.append(base_array[z])
save_array.append(e)
current_iteration.append(e)
chenge_array = current_iteration.copy()
candidate_generation2(change_array, base_array, save_array)
print(save_array)
</code></pre>
<blockquote>
<p>thanks in advance for any help</p>
</blockquote>
| [
{
"answer_id": 74241114,
"author": "Bhavesh Odedra",
"author_id": 2926754,
"author_profile": "https://Stackoverflow.com/users/2926754",
"pm_score": 1,
"selected": true,
"text": "<field name=\"one2many_field\">\n <tree>\n <field name=\"x\">\n <field name=\"y\">\n </tre... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282236/"
] |
74,152,616 | <p>So I am having many issues with Pysimplegui's event loops, I'm trying to disable a button based on the lack of input in another part of the code (in this case it's the lack of selection of at least one checkbox if the radio button above is pressed [but I should apply the same logic if a folder is not selected]).
I tried looking everywhere and either I can't find a solution or people apparently manage to get through based on the cookbook (which I tried and can't).</p>
<p>The code i tried is the following:</p>
<p>This is the part regarding the Radio buttons:</p>
<pre><code>layout_1 = [
# things before...
[sg.Radio('CSV/JSON:', "OUTPUT", default=False, key='-OutputFile-', enable_events=True)],
[sg.Checkbox('Output as CSV', key='-OutputCSV-', disabled=True)],
[sg.Checkbox('Output as JSON', key='-OutputJSON-', disabled=True)],
[sg.Text('Select a folder: ')], [sg.FolderBrowse(key='-Folder-')],
[sg.Push(), sg.Column([[sg.Button("Submit", disabled=False, key='-Submit-'), sg.Cancel()]], element_justification='c'), sg.Push()]
]
window_2 = sg.Window('Info', layout_1, finalize = True)
</code></pre>
<p>Then I have this while loop, which in theory, should basically disable the ability to select the output if '-OutputFile-' is False and, in case none of the two available outputs available (CSV or JSON) are selected, disable the Submit button as well. Thing is the disabling of the choices works but the Submit button is never disabled and can't be clicked.</p>
<pre><code>while True:
event_2, values_table = window_2.read()
if event_2 in (sg.WIN_CLOSE, 'Cancel', 'Submit', None):
break
elif event_2 == '-OutputFile-':
window_2['-OutputJSON-'].update(disabled = False)
window_2['-OutputCSV-'].update(disabled = False)
if window_2['-OutputFile-'] and not window_2['-OutputCSV-'] and not window_2['-OutputJSON-']:
window_2['-Submit-'].update(disabled=True)
sg.popup('Select an output', keep_on_top=True)
elif event_2 == '-OutputNone-':
window_2['-OutputJSON-'].update(disabled=True)
window_2['-OutputCSV-'].update(disabled=True)
window_2.close()
</code></pre>
<p>I should note that the code works without the part in the loop about the Submit button, but I need that part as well.</p>
<p>Another thing I tried is using is False instead of not in the part not working.</p>
<p>This is what the window looks like:
<img src="https://i.stack.imgur.com/vyqyE.jpg" alt="This is what the window looks like" /></p>
<p>PS: there might be grammatical errors in the code, unfortunately I had to copy it by and, even if I checked, there might be some error.</p>
| [
{
"answer_id": 74154110,
"author": "Jason Yang",
"author_id": 11936135,
"author_profile": "https://Stackoverflow.com/users/11936135",
"pm_score": 0,
"selected": false,
"text": "values[...]"
},
{
"answer_id": 74154118,
"author": "furas",
"author_id": 1832058,
"author_p... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17253905/"
] |
74,152,621 | <p>In <a href="https://gigamonkeys.com/book/the-special-operators.html" rel="nofollow noreferrer">Practical Common Lisp</a>, Peter Seibel write:</p>
<blockquote>
<p><strong>The mechanism by which multiple values are returned is implementation dependent</strong> just like the mechanism for passing arguments into functions is. Almost all language constructs that return the value of some subform will "pass through" multiple values, returning all the values returned by the subform. Thus, a function that returns the result of calling VALUES or VALUES-LIST will itself return multiple values--and so will another function whose result comes from calling the first function. And so on.</p>
</blockquote>
<p>The <strong>implementation dependent</strong> does worry me.
My understanding is that the following code might just return primary value:</p>
<pre><code>> (defun f ()
(values 'a 'b))
> (defun g ()
(f))
> (g) ; ==> a ? or a b ?
</code></pre>
<p>If so, does it mean that I should use this feature sparingly?</p>
<p>Any help is appreciated.</p>
| [
{
"answer_id": 74162180,
"author": "Rainer Joswig",
"author_id": 69545,
"author_profile": "https://Stackoverflow.com/users/69545",
"pm_score": 3,
"selected": false,
"text": "MULTIPLE-VALUES-LIMIT"
}
] | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20212483/"
] |
74,152,624 | <p>when I ran the code below I got exact same number in 2 different programs. is this just coincidence or there is some algorithm to make those additional garbage digits.</p>
<pre class="lang-cpp prettyprint-override"><code>std::cout<<std::setprecision(20);
std::cout<< 3.14f;
</code></pre>
<p><strong>Output:</strong><br />
<code>3.1400001049041748047</code></p>
| [
{
"answer_id": 74157696,
"author": "Eric Postpischil",
"author_id": 298225,
"author_profile": "https://Stackoverflow.com/users/298225",
"pm_score": 2,
"selected": false,
"text": "float"
},
{
"answer_id": 74176306,
"author": "Steve Summit",
"author_id": 3923896,
"autho... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20292818/"
] |
74,152,627 | <p>How to do a remapo for new objects like:</p>
<pre><code>...
const inputArr = [
{id: '1', name: "test1", routeName: "somethig/something"},
{id: '2', name: "something2", routeName: "foo/bar"},
{id: '3', name: "someanothrelement", routeName: "test/test"}
]
//to =>
const resultStructureArr = [
{ id: '1', value: 'somethig/something', label: 'test1' },
{ id: '2', value: 'foo/bar', label: 'something2' },
{ id: '3', value: 'test/test', label: 'someanothrelement' },
];
...
</code></pre>
<p><a href="https://jsfiddle.net/ruce97q0/" rel="nofollow noreferrer">Here is the jsfiddle</a></p>
| [
{
"answer_id": 74152651,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 2,
"selected": true,
"text": "map()"
},
{
"answer_id": 74152989,
"author": "Muhammad Hassan Javed",
"author_id": 7712565,
"au... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3918121/"
] |
74,152,652 | <p>I have 2 arrays where they have some common <code>id</code> values, but the keys for these <code>id</code> keys differ slightly.</p>
<pre><code>$comps = [
[
'c_id' => '123',
'status' => 'active'
],
[
'c_id' => '456',
'status' => 'destroyed'
],
[
'c_id' => '789',
'status' => 'active'
]
];
$rests = [
[
'r_id' => 123,
'extra' => 'some extra info for r_id 123'
],
[
'r_id' => 456,
'extra' => 'some extra info for r_id 456'
]
];
</code></pre>
<p>My objective here is to return all entries of the <code>$rests</code> array that have corresponding entries within the <code>$comps</code> array that have both matching ID values and a <code>status => active</code>.</p>
<p>How can one achieve this?</p>
<p>I have seen and used <code>array_uintersect()</code> in the past, however I can't seem to get this to work in the desired way.</p>
| [
{
"answer_id": 74152940,
"author": "Markus Zeller",
"author_id": 2645713,
"author_profile": "https://Stackoverflow.com/users/2645713",
"pm_score": 2,
"selected": true,
"text": "$matches = [];\nforeach ($rests as $rest) {\n foreach ($comps as $comp) {\n if ($rest['r_id'] === $co... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3061047/"
] |
74,152,668 | <p>I have <strong>products</strong> model like this</p>
<pre><code>const productSchema = new mongoose.Schema({
categories:{
type: mongoose.Schema.Types.ObjectId,
ref: 'Category'
}
})
</code></pre>
<p>and <strong>category</strong> model</p>
<pre><code>const productSchema = new mongoose.Schema({
title: { type: String, required: true }
})
</code></pre>
<p>now</p>
<p>I wanna Filter Products by array of categories id</p>
<p>I send array of categories id <code>[_1234464 , _987654321]</code> in request body</p>
<p><strong>controller/products</strong></p>
<pre><code>exports.get = async (req, res, next) => {
categories=req.body.categories // is like [_1234464 , _987654321] ;
const filteredProducts= productModel.find({ /* i dont know what to write here*/ })
})
</code></pre>
| [
{
"answer_id": 74152940,
"author": "Markus Zeller",
"author_id": 2645713,
"author_profile": "https://Stackoverflow.com/users/2645713",
"pm_score": 2,
"selected": true,
"text": "$matches = [];\nforeach ($rests as $rest) {\n foreach ($comps as $comp) {\n if ($rest['r_id'] === $co... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14952975/"
] |
74,152,671 | <p>Why Am I unable to map through a list and create routes with this code </p>
<pre><code>import { useEffect } from "react";
import { Route, Routes } from "react-router-dom";
import "./App.css";
function App() {
const array1 = [];
const array2 = [];
useEffect(() => {
array1.push({ name: "dev", bio: "yeah" });
array1.push({ name: "kirath", bio: 'yeah it"s big brain time' });
console.log(array1);
array1.map((object) => {
array2.push(object.name);
});
}, []);
return (
<div className="App">
<Routes>
{array2.map((name) => {
return <Route path={`/${name}`} element={<h1>hello {name}</h1>} />;
})}
</Routes>
</div>
);
}
export default App;
</code></pre>
<p>i have tried to look at a lot of different ways but unable to do so...My actual motive is to connect this to firebase realtime database but i just hard coded the data for now because i was unable to create routes with this type of data why?</p>
| [
{
"answer_id": 74152751,
"author": "Avetik Nersisyan",
"author_id": 14938670,
"author_profile": "https://Stackoverflow.com/users/14938670",
"pm_score": 1,
"selected": false,
"text": "array2"
},
{
"answer_id": 74152846,
"author": "Salman Nasir",
"author_id": 12283001,
... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16814937/"
] |
74,152,684 | <p>How can i make it so after watching 2 rewarded ads all the levels in my game are unlocked and playable.
Currently i have it so you have to complete the level in order to unlock that level and be able to play it at any given time.</p>
<p>public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)</p>
<pre><code>{
if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
{
Debug.Log("Unity Ads Rewarded Ad Completed");
// Grant a reward.
// Load another ad:
Advertisement.Load(_adUnitId, this);
}
}
</code></pre>
| [
{
"answer_id": 74152751,
"author": "Avetik Nersisyan",
"author_id": 14938670,
"author_profile": "https://Stackoverflow.com/users/14938670",
"pm_score": 1,
"selected": false,
"text": "array2"
},
{
"answer_id": 74152846,
"author": "Salman Nasir",
"author_id": 12283001,
... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20285501/"
] |
74,152,724 | <p>i want to run a scheduler which run a trigger that it should be automatically wipe out the data which is more than 30days.so we already have a trigger as below and we need something to schedule that trigger automatically once it reaches 30 days. and here the days should be configurable</p>
<p>The below trigger i have created for this</p>
<pre><code>CREATE TRIGGER sampleTrigger
ON database1.dbo.table1
FOR DELETE
AS
DELETE FROM database1.dbo.table1
WHERE date < DATEADD(day, -30, GETDATE())
GO
</code></pre>
<p>and also here something went wrong with the above trigger because now i am getting following error</p>
<blockquote>
<p>ORA-04071 :missing BEFORE,AFTER or INSTEAD OF.</p>
</blockquote>
<p>can some one please help me on this what wrong with the above trigger and how can i make this automatic using a scheduler that will clean up 30 days older data from a table</p>
| [
{
"answer_id": 74153327,
"author": "Littlefoot",
"author_id": 9097906,
"author_profile": "https://Stackoverflow.com/users/9097906",
"pm_score": 2,
"selected": false,
"text": "SQL> SELECT *\n 2 FROM test\n 3 ORDER BY datum DESC;\n \n ID DATUM\n---------- ----------\n ... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300353/"
] |
74,152,747 | <p>I am trying to use the available phone number API in order to claim and attach a contact flow. I tried following the documentation provided by AWS for python.</p>
<p><a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/connect.html#Connect.Client.search_available_phone_numbers" rel="nofollow noreferrer">https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/connect.html#Connect.Client.search_available_phone_numbers</a></p>
<p>when I try to use it, it gives the following error</p>
<p><strong>Exception thrown: 'Connect' object has no attribute 'search_available_phone_numbers'"</strong></p>
<pre><code>client = boto3.client('connect')
response = client.search_available_phone_numbers(
TargetArn='arn:aws:connect:us-east-1:**********:instance/**********/contact-flow/....',
PhoneNumberCountryCode='US',
PhoneNumberType='TOLL_FREE'
)
</code></pre>
<p>NOTE: I tried using other APIs like create user, Associate lambda, and Associate LEX. All those worked except the one I .</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 74157973,
"author": "ledge",
"author_id": 15371153,
"author_profile": "https://Stackoverflow.com/users/15371153",
"pm_score": 0,
"selected": false,
"text": "pip install boto3"
},
{
"answer_id": 74248080,
"author": "George Anton",
"author_id": 17900210,
... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11746609/"
] |
74,152,750 | <p>I'm using Winston in my Node.js application on GCP as described here: <a href="https://cloud.google.com/logging/docs/samples/logging-winston-quickstart" rel="nofollow noreferrer">https://cloud.google.com/logging/docs/samples/logging-winston-quickstart</a>
That works in a sense that I see the logs I expect in the log explorer.</p>
<p>I now want to that all errors appear in the "Error Reporting" dashboard (<a href="https://console.cloud.google.com/errors?project=..." rel="nofollow noreferrer">https://console.cloud.google.com/errors?project=...</a>).
However, only some errors are listed there. I am not 100% sure which errors make it to the error reporting dashboard, but my suspicion is that <code>logger.error</code> calls only appear in the error dashboard if there's a proper error stack trace.</p>
<p>But that's not what I want. I want that whenever <code>logger.error</code> in my application is triggered, an error group on the error reporting dashboard should be created - regardless of the string I pass to <code>logger.error</code>.
How do I do that?</p>
| [
{
"answer_id": 74187298,
"author": "sshevlyagin",
"author_id": 305466,
"author_profile": "https://Stackoverflow.com/users/305466",
"pm_score": 1,
"selected": false,
"text": "@type"
},
{
"answer_id": 74284872,
"author": "cis",
"author_id": 2710714,
"author_profile": "h... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2710714/"
] |
74,152,757 | <p>How can I format the output of $info, $warning, etc. of Verilog code?</p>
<p>By default (at least Questa) shows messages on two lines, and I need to get rid of line changes, file paths, and other stuff that is basically just causing noise in my logs.</p>
<p>Questa's modelsim.ini offers these:</p>
<pre><code>MessageFormatNote = "%S: %R\n Time: %T Iteration: %D%I\n"
MessageFormatWarning = "%S: %R\n Time: %T Iteration: %D%I\n"
MessageFormatError = "%S: %R\n Time: %T Iteration: %D %K: %i File: %F\n"
MessageFormatFail = "%S: %R\n Time: %T Iteration: %D %K: %i File: %F\n"
MessageFormatFatal = "%S: %R\n Time: %T Iteration: %D %K: %i File: %F\n"
MessageFormatBreakLine = "%S: %R\n Time: %T Iteration: %D %K: %i File: %F Line: %L\n"
MessageFormatBreak = "%S: %R\n Time: %T Iteration: %D %K: %i File: %F\n"
MessageFormat = "%S: %R\n Time: %T Iteration: %D%I\n"
</code></pre>
<p>..but they don't seem to affect the prints.</p>
<p><strong>Edit:</strong> Currently the default message style is something like this::</p>
<pre><code># ** Info: @ 0.000us <message>
# Time: 0000000 ps Scope: /path/to/file.sv Line: 666
# ** Info: @ 0.000us <message>
# Time: 0000000 ps Scope: /path/to/file.sv Line: 666
# ** Info: @ 0.000us <message>
# Time: 0000000 ps Scope: /path/to/file.sv Line: 666
</code></pre>
<p>The goal would be to get it into:</p>
<pre><code># ** Info: 0.000us - <message>
# ** Info: 0.000us - <message>
# ** Info: 0.000us - <message>
</code></pre>
| [
{
"answer_id": 74187298,
"author": "sshevlyagin",
"author_id": 305466,
"author_profile": "https://Stackoverflow.com/users/305466",
"pm_score": 1,
"selected": false,
"text": "@type"
},
{
"answer_id": 74284872,
"author": "cis",
"author_id": 2710714,
"author_profile": "h... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5889861/"
] |
74,152,789 | <p>is there some kind of best practise in async pipe error handling? Is it preferable to handle errors in service(but that means we have to use some kind of global error handling) or it is better in component? What do you guys prefer?</p>
<p>For example in my service i have getter which is then consumed in component:</p>
<pre><code>//service
get loadedEvents(){
//appStatus emits when selectedMonth is changed
return this.statusService.appStatus.pipe(
switchMap(status=>this.getOffers(status.selectedMonth)),
shareReplay({refCount:true})); }
getOffers(date:Date){
return this.httpClient.get(...);
}
//component
events$=this.service.loadedEvents;
</code></pre>
<p>Where is it better to catch error? In component or service?</p>
| [
{
"answer_id": 74153497,
"author": "MGX",
"author_id": 20059754,
"author_profile": "https://Stackoverflow.com/users/20059754",
"pm_score": 2,
"selected": true,
"text": "loadedEvents = this.statusService\n .appStatus\n .pipe( \n switchMap(s... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13005762/"
] |
74,152,797 | <p>Lets say I have a list:</p>
<pre><code>navigation: [
{
title: "Überblick",
icon: "mdi-view-dashboard",
active: false,
id: 0,
},
{
title: "Persönliche Daten",
icon: "mdi-clipboard-account-outline",
active: false,
id: 1,
},
{
title: "Adressen",
icon: "mdi-map-marker",
active: true,
id: 2,
},
{
title: "Letzte Bestellungen",
icon: "mdi-clipboard-text-multiple",
active: false,
id: 3,
},
{
title: "Merkliste",
icon: "mdi-playlist-star",
active: false,
id: 4,
},
],
</code></pre>
<p>From that list I would like to only get the element with <code>active: true</code></p>
<p>How can I do that, without many if statementy after each other?</p>
| [
{
"answer_id": 74152825,
"author": "bbbbbbbboat",
"author_id": 8428405,
"author_profile": "https://Stackoverflow.com/users/8428405",
"pm_score": 3,
"selected": true,
"text": "const activeList = navigation.filter(n => n.active)\n"
},
{
"answer_id": 74152838,
"author": "exphoen... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15635029/"
] |
74,152,802 | <p>i am a newbie that tries to learn HTML + CSS</p>
<p>I would like this border to be in full gray color and as we can see its half / half - i do not understand why, thanks <a href="https://i.stack.imgur.com/TWBkV.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>my console and image below:</p>
| [
{
"answer_id": 74152825,
"author": "bbbbbbbboat",
"author_id": 8428405,
"author_profile": "https://Stackoverflow.com/users/8428405",
"pm_score": 3,
"selected": true,
"text": "const activeList = navigation.filter(n => n.active)\n"
},
{
"answer_id": 74152838,
"author": "exphoen... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300424/"
] |
74,152,809 | <p>I am trying to ingest several tables incrementally in a pipeline on Azure Synapse using a ForEach Activity.</p>
<p>I have defined a variable as an array of strings. Each string corresponds to the name of a table that I want to query inside the ForEach and copy data from it.</p>
<p>My basic problem is how to pass as the table name at a SELECT query at the source of the Copy Activity, the @item that iterates in the ForEach.</p>
<p>*My connection to the MySQL database is established via ODBC.</p>
| [
{
"answer_id": 74152825,
"author": "bbbbbbbboat",
"author_id": 8428405,
"author_profile": "https://Stackoverflow.com/users/8428405",
"pm_score": 3,
"selected": true,
"text": "const activeList = navigation.filter(n => n.active)\n"
},
{
"answer_id": 74152838,
"author": "exphoen... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5897548/"
] |
74,152,826 | <p>I have this string and for example i need to get the the word <strong>green eyes</strong> from specific string that is sperated by a comma like this example</p>
<pre><code>young lady , beautiful , green eyes , wearing shirt , wearing necklace
</code></pre>
<p>I want to get for example green eyes using the word <strong>eyes</strong> for example</p>
<p>how can I achieve this ?</p>
| [
{
"answer_id": 74152825,
"author": "bbbbbbbboat",
"author_id": 8428405,
"author_profile": "https://Stackoverflow.com/users/8428405",
"pm_score": 3,
"selected": true,
"text": "const activeList = navigation.filter(n => n.active)\n"
},
{
"answer_id": 74152838,
"author": "exphoen... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300450/"
] |
74,152,833 | <p>I want to use CSS animation to move these divs upwards as shown in the GIF attached below.</p>
<p>All the divs move upwards at the same speed.</p>
<p>I tried the marquee tag but from what I heard, it's depreciated or will be depreciated soon. So I can't use it.</p>
<p>I have never done CSS animation. So would really appreciate your help.</p>
<p>Each column has 6 items. When the entire 6 items are finished, it starts from item 1 again. Elements that overflow remain hidden, till all other items are displayed and then appear from the bottom again after the 6th element.</p>
<p><a href="https://i.stack.imgur.com/3Nk7v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Nk7v.png" alt="enter image description here" /></a></p>
<p><img src="https://media.giphy.com/media/sdxPw0UlQ1bqPFl7F8/giphy.gif" alt="Video demo here" /></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.gridcontainer{
background: black;
width: 100%;
padding: 20px;
margin: 5px;
color: white;
border-radius: 10px;
}
.grid{
display:grid;
justify-items: center
}
.grid--1x3{
grid-template-columns: 1fr 1fr 1fr;
justify-items: "center"
}
.flexcolumn {
display:flex;
flex-direction: column;
}
</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <div class='grid grid--1x3'>
<div class='flexcolumn'>
<span class='gridcontainer'>Element A</span>
<span class='gridcontainer'>Element B</span>
<span class='gridcontainer'>Element C</span>
<span class='gridcontainer'>Element D</span>
<span class='gridcontainer'>Element E</span>
<span class='gridcontainer'>Element F</span>
</div>
<div class='flexcolumn'>
<span class='gridcontainer'>Element A</span>
<span class='gridcontainer'>Element B</span>
<span class='gridcontainer'>Element C</span>
<span class='gridcontainer'>Element D</span>
<span class='gridcontainer'>Element E</span>
<span class='gridcontainer'>Element F</span>
</div>
<div class='flexcolumn'>
<span class='gridcontainer'>Element A</span>
<span class='gridcontainer'>Element B</span>
<span class='gridcontainer'>Element C</span>
<span class='gridcontainer'>Element D</span>
<span class='gridcontainer'>Element E</span>
<span class='gridcontainer'>Element F</span>
</div>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74154080,
"author": "shamal iroshan",
"author_id": 12289913,
"author_profile": "https://Stackoverflow.com/users/12289913",
"pm_score": 1,
"selected": false,
"text": ".container {\n position: absolute;\n bottom: 0;\n display: flex;\n animation-name: move;\n animation-d... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18040461/"
] |
74,152,843 | <p>I am currently working on a PWA store, which has a nodeJS SSR (server side rendering) and using React.</p>
<p>So I am using dotenv and created a .env file inside the project, which is injected into nodejs server.</p>
<p>Then, I have configured the webpack to also inject those variables into frontend bundle.</p>
<p>My questions:</p>
<ol>
<li>How safe is using .env file with a nodeJS and in the context of a server side rendering app? Can the file be accessed somehow?</li>
<li>How safe is injecting those variables in frontend? I am currently doing that by modifying the plugins like this:</li>
</ol>
<pre><code>new _webpack.default.DefinePlugin({
'process.env': JSON.stringify(process.env)})
</code></pre>
| [
{
"answer_id": 74154080,
"author": "shamal iroshan",
"author_id": 12289913,
"author_profile": "https://Stackoverflow.com/users/12289913",
"pm_score": 1,
"selected": false,
"text": ".container {\n position: absolute;\n bottom: 0;\n display: flex;\n animation-name: move;\n animation-d... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300471/"
] |
74,152,910 | <p>Have got a dataframe
<strong>input_df</strong></p>
<pre><code>Item Space Size Max
Apple 0.375 0.375 0.375
Lemon 0.625 0.375 0.75
Melon 0.5 0.375 0.625
</code></pre>
<p>'<em>Space</em>' column value need to be the nearest multiple of '<em>Size</em>' column. Also, final <code>input_df['Space'] <= input_df['Max']</code>. '<em>extra</em>' column to be generated which gives how much space value added/reduced.</p>
<p><strong>Expected output_df</strong></p>
<pre><code>Item Space Size Max extra
Apple 0.375 0.375 0.375 0
Lemon 0.75 0.375 0.75 0.125 #Space value changed to nearest
Melon 0.375 0.375 0.625 -0.125 #Space value changed to nearest
</code></pre>
| [
{
"answer_id": 74153185,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "# get max multiple\nMAX = input_df['Max'].div(input_df['Size'])\n\nNEW = (input_df['Space']\n .div(input_df['... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7818560/"
] |
74,152,944 | <p>This is my data structure</p>
<pre><code>struct SPPWorkout: Codable {
static let setKey = "Sets"
static let exerciseID = "id"
var id: Double? = 0.0
var duration: String?
var calories: Int?
var date: String?
var exercises: [ExerciseSet]
[...]
}
struct ExerciseSet: Codable {
let id: String
let name: String
var reps: Int
var weight: Double
[...]
}
extension ExerciseSet: Equatable {
static func ==(lhs: ExerciseSet, rhs: ExerciseSet) -> Bool {
return lhs.id == rhs.id
}
}
</code></pre>
<p>and in a SwiftUI view I'm trying to modify an <code>ExerciseSet</code> from user input</p>
<pre><code>@State private var sppWorkout: SPPWorkout!
EditSetPopup(isShowingOverlay: $isShowingOverlay,
update: { reps, weight in
guard let editingIndex = editingIndex else { return }
sppWorkout.exercises[editingIndex].reps = Int(reps) ?? 0
sppWorkout.exercises[editingIndex].weight = Double(weight) ?? 0.0
self.editingIndex = nil
})
}
</code></pre>
<p>The issue is here</p>
<pre><code>sppWorkout.exercises[editingIndex].reps = Int(reps) ?? 0
sppWorkout.exercises[editingIndex].weight = Double(weight) ??
</code></pre>
<p>and I've tried in all ways to update it, both from the view and with a func in SPPWorkout. I've also tried to replace the object at index</p>
<pre><code>var newSet = ExerciseSet(id: [...], newValues)
self.exercises[editingIndex] = newSet
</code></pre>
<p>but in no way it wants to update. I'm sure that somewhere it creates a copy that it edits but I have no idea why and how to set the new values.</p>
<p><strong>Edit</strong>: if I try to delete something, it's fine</p>
<pre><code>sppWorkout.exercises.removeAll(where: { $0 == sppWorkout.exercises[index]})
</code></pre>
<p><strong>Edit 2:</strong>
It passes the guard statement and it does not change the values in the array.</p>
<p><a href="https://i.stack.imgur.com/3BfC7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3BfC7.png" alt="enter image description here" /></a></p>
<p><strong>Edit 3:</strong>
At the suggestion below from Jared, I've copied the existing array into a new one, set the new values then tried to assign the new one over to the original one but still, it does not overwrite.</p>
<pre><code>EditSetPopup(isShowingOverlay: $isShowingOverlay,
update: { reps, weight in
print(sppWorkout.exercises)
guard let editingIndex = editingIndex else { return }
var copyOfTheArray = sppWorkout.exercises
copyOfTheArray[editingIndex].reps = Int(reps) ?? 0
copyOfTheArray[editingIndex].weight = Double(weight) ?? 0.0
//Copy of the array is updated correctly, it has the new values
sppWorkout.exercises = copyOfTheArray
//Original array doesn't get overwritten. It still has old values
self.editingIndex = nil
</code></pre>
<p><strong>Edit 4:</strong> I've managed to make progress by extracting the model into a view model and updating the values there. Now the values get updated in sppWorkout, but even though I call <code>objectWillChange.send()</code>, the UI Update doesn't trigger.</p>
<p>full code:</p>
<pre><code>class WorkoutDetailsViewModel: ObservableObject {
var workoutID: String!
@Published var sppWorkout: SPPWorkout!
func setupData(with workoutID: String) {
sppWorkout = FileIOManager.readWorkout(with: workoutID)
}
func update(_ index: Int, newReps: Int, newWeight: Double) {
let oldOne = sppWorkout.exercises[index]
let update = ExerciseSet(id: oldOne.id, name: oldOne.name, reps: newReps, weight: newWeight)
sppWorkout.exercises[index] = update
self.objectWillChange.send()
}
}
struct WorkoutDetailsView: View {
var workoutID: String!
@StateObject private var viewModel = WorkoutDetailsViewModel()
var workout: HKWorkout
var dateFormatter: DateFormatter
@State private var offset = 0
@State private var isShowingOverlay = false
@State private var editingIndex: Int?
@EnvironmentObject var settingsManager: SettingsManager
@Environment(\.dismiss) private var dismiss
var body: some View {
if viewModel.sppWorkout != nil {
VStack {
ListWorkoutItem(workout: workout, dateFormatter: dateFormatter)
.padding([.leading, .trailing], 10.0)
List(viewModel.sppWorkout.exercises, id: \.id) { exercise in
let index = viewModel.sppWorkout.exercises.firstIndex(of: exercise) ?? 0
DetailListSetItem(exerciseSet: viewModel.sppWorkout.exercises[index], set: index + 1)
.environmentObject(settingsManager)
.swipeActions {
Button(role: .destructive, action: {
viewModel.sppWorkout.exercises.removeAll(where: { $0 == viewModel.sppWorkout.exercises[index]})
} ) {
Label("Delete", systemImage: "trash")
}
Button(role: .none, action: {
isShowingOverlay = true
editingIndex = index
} ) {
Label("Edit", systemImage: "pencil")
}.tint(.blue)
}
}
.padding([.leading, .trailing], -30)
//iOS 16 .scrollContentBackground(.hidden)
}
.overlay(alignment: .bottom, content: {
editOverlay
.animation(.easeInOut (duration: 0.5), value: isShowingOverlay)
})
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: Button(action : {
do {
try FileIOManager.write(viewModel.sppWorkout, toDocumentNamed: "\(viewModel.sppWorkout.id ?? 0).json")
} catch {
Debugger.log(error: error.localizedDescription)
}
dismiss()
}){
Image(systemName: "arrow.left")
})
} else {
Text("No workout details found")
.italic()
.fontWeight(.bold)
.font(.system(size: 35))
.onAppear(perform: {
viewModel.setupData(with: workoutID)
})
}
}
@ViewBuilder private var editOverlay: some View {
if isShowingOverlay {
ZStack {
Button {
isShowingOverlay = false
} label: {
Color.clear
}
.edgesIgnoringSafeArea(.all)
VStack{
Spacer()
EditSetPopup(isShowingOverlay: $isShowingOverlay,
update: { reps, weight in
guard let editingIndex = editingIndex else { return }
print(viewModel.sppWorkout.exercises)
print("dupa aia:\n")
viewModel.update(editingIndex, newReps: Int(reps) ?? 0, newWeight: Double(weight) ?? 0.0)
print(viewModel.sppWorkout.exercises)
self.editingIndex = nil
})
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color("popupBackground"),
lineWidth: 3)
)
}
}
}
}
}
</code></pre>
| [
{
"answer_id": 74153185,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "# get max multiple\nMAX = input_df['Max'].div(input_df['Size'])\n\nNEW = (input_df['Space']\n .div(input_df['... | 2022/10/21 | [
"https://Stackoverflow.com/questions/74152944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2984775/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.