qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,344,819 | <p>How do I set a variable to None or null when the file doesn't exist
for example:</p>
<pre><code>lastModified = os.path.getmtime("/xyz.csv") if os.path.getmtime("/xyz.csv") is not None else null
</code></pre>
<p>So I would like <code>lastModified</code> variable to be the time the file was last modified when the file exists else to be null when it doesn't exist.</p>
<p>Any</p>
| [
{
"answer_id": 74344906,
"author": "bwilk315",
"author_id": 20438342,
"author_profile": "https://Stackoverflow.com/users/20438342",
"pm_score": 4,
"selected": true,
"text": "from os.path import getmtime, exists\n\nfile_path = './file.txt'\nlast_mod = getmtime(file_path) if exists(file_path) else None\nprint(last_mod)\n"
},
{
"answer_id": 74344930,
"author": "Will",
"author_id": 12829151,
"author_profile": "https://Stackoverflow.com/users/12829151",
"pm_score": 2,
"selected": false,
"text": "from os.path import exists\n\nfile_exists = exists(path_to_file)\nif file_exists:\n lastModified = os.path.getmtime(\"/xyz.csv\")\nelse:\n lastModified = None\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19399320/"
] |
74,344,825 | <p>I really need some help with a homework problem I have been given. I don't want answers to the question, but I would like some help with knowing what methods to use.</p>
<p>My problem is:</p>
<p>The product owner on your development team believes they've seen a pattern as to which customers purchase the most socks. To verify, you've been asked to write a function that processes an array of customer objects and return a new array that contains only customers that match ANY of the following criteria:</p>
<ol>
<li>name starts with a 'C' (upper or lowercase)</li>
<li>address contains no undefined fields</li>
<li>the city is Peoria and the state is AZ</li>
<li>membership level is GOLD or PLATINUM unless the customer is younger than 29, then SILVER is okay too</li>
</ol>
<p>The array of customer objects will have the following schema:</p>
<pre><code>const customers = [
{
name: 'Sam',
address: {
street: '1234 W Bell Rd',
city: 'Phoenix',
zip: '85308',
state: 'AZ'
},
membershipLevel: 'GOLD',
age: 32
},
//more customers with the same schema
];
</code></pre>
<p>Note: The solution to this problem does not require the use of callbacks. You will also need to use dot notation to access the properties. For example, customers[0].name would return "Sam".</p>
<p>As you can see, I have to sort this array by a few different parameters involving strings and part of strings. However, I have tried and failed to use the typical Array.sort() method as I'm actually sorting the objects, and I can't find a method to sort objects by parts of a string. Additionally, I will need help keeping it all within a separate array.</p>
<p>The thing that I think would help me the most would be to give me the method I should use for each of the criteria in the problem above. If so, I can look up and hopefully learn the methods myself. I am willing to accept any and all advice. Thank you for your time in reading this and helping me.</p>
| [
{
"answer_id": 74345017,
"author": "Lain",
"author_id": 4728913,
"author_profile": "https://Stackoverflow.com/users/4728913",
"pm_score": 1,
"selected": false,
"text": "true"
},
{
"answer_id": 74346991,
"author": "Rohìt Jíndal",
"author_id": 4116300,
"author_profile": "https://Stackoverflow.com/users/4116300",
"pm_score": 2,
"selected": false,
"text": "Array.filter()"
},
{
"answer_id": 74347925,
"author": "eelpcik",
"author_id": 20094864,
"author_profile": "https://Stackoverflow.com/users/20094864",
"pm_score": 1,
"selected": false,
"text": "const customers = [\n {\n name: \"Sam\",\n address: {\n street: \"1234 W Bell Rd\",\n city: \"Phoenix\",\n zip: \"85308\",\n state: \"AZ\",\n },\n membershipLevel: \"GOLD\",\n age: 32,\n },\n {\n name: \"Cindy\",\n address: {\n street: \"1286834 E Bull Rd\",\n city: \"Peoria\",\n zip: \"85308\",\n state: \"AZ\",\n },\n membershipLevel: \"GOLD\",\n age: 32,\n },\n {\n name: \"Chloe\",\n address: {\n street: \"1234 S Dull Rd\",\n city: \"Peoria\",\n zip: \"85308\",\n state: \"AZ\",\n },\n membershipLevel: \"SILVER\", \n age: 25, \n },\n {\n name: \"Charlie\",\n address: {\n street: \"1234 N Dell Rd\", \n city: \"Peoria\",\n zip: \"85308\",\n state: \"VA\",\n },\n membershipLevel: \"SILVER\", \n age: 20,\n },\n];\n\n// check if a customer satisfies all conditions\nfunction checkCustomer(customerObject) { \n\n // object destructuring\n const {\n name,\n address: { city, state },\n membershipLevel,\n age,\n } = customerObject;\n\n if (\n (name.startsWith(\"c\") || name.startsWith(\"C\")) &&\n city === \"Peoria\" &&\n state === \"AZ\" &&\n ((age >= 29 &&\n (membershipLevel === \"GOLD\" || membershipLevel === \"PLATINUM\")) ||\n (age < 29 && membershipLevel === \"SILVER\"))\n ) {\n return true;\n }\n\n return false;\n}\n\n// write names of customers that satisfy conditions \ncustomers.filter(checkCustomer).forEach(customer => {\n console.log(customer.name); \n})"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20438904/"
] |
74,344,827 | <p>I have an application which requieres tls-client-authentication for all its routes except for one path, lets call it "/some-path".</p>
<p>Now I tried to setup two routes with the same host like:</p>
<pre><code>apiVersion: route.openshift.io/v1
kind: Route
name: route-path
spec:
host: example.com
path: "/some-path"
to:
kind: Service
name: my-service
weight: 100
port:
targetPort: http
tls:
termination: edge
insecureEdgeTerminationPolicy: None
---
apiVersion: route.openshift.io/v1
kind: Route
name: route
spec:
host: example.com
path: ""
to:
kind: Service
name: my-service
weight: 100
port:
targetPort: https
tls:
termination: passthrough
insecureEdgeTerminationPolicy: None
</code></pre>
<p>The problem is, that I can't access the http port of my application, since the route "route" also catches the traffic for that path. Is there any solution to this except change the host or path of the rest of the application?</p>
| [
{
"answer_id": 74345017,
"author": "Lain",
"author_id": 4728913,
"author_profile": "https://Stackoverflow.com/users/4728913",
"pm_score": 1,
"selected": false,
"text": "true"
},
{
"answer_id": 74346991,
"author": "Rohìt Jíndal",
"author_id": 4116300,
"author_profile": "https://Stackoverflow.com/users/4116300",
"pm_score": 2,
"selected": false,
"text": "Array.filter()"
},
{
"answer_id": 74347925,
"author": "eelpcik",
"author_id": 20094864,
"author_profile": "https://Stackoverflow.com/users/20094864",
"pm_score": 1,
"selected": false,
"text": "const customers = [\n {\n name: \"Sam\",\n address: {\n street: \"1234 W Bell Rd\",\n city: \"Phoenix\",\n zip: \"85308\",\n state: \"AZ\",\n },\n membershipLevel: \"GOLD\",\n age: 32,\n },\n {\n name: \"Cindy\",\n address: {\n street: \"1286834 E Bull Rd\",\n city: \"Peoria\",\n zip: \"85308\",\n state: \"AZ\",\n },\n membershipLevel: \"GOLD\",\n age: 32,\n },\n {\n name: \"Chloe\",\n address: {\n street: \"1234 S Dull Rd\",\n city: \"Peoria\",\n zip: \"85308\",\n state: \"AZ\",\n },\n membershipLevel: \"SILVER\", \n age: 25, \n },\n {\n name: \"Charlie\",\n address: {\n street: \"1234 N Dell Rd\", \n city: \"Peoria\",\n zip: \"85308\",\n state: \"VA\",\n },\n membershipLevel: \"SILVER\", \n age: 20,\n },\n];\n\n// check if a customer satisfies all conditions\nfunction checkCustomer(customerObject) { \n\n // object destructuring\n const {\n name,\n address: { city, state },\n membershipLevel,\n age,\n } = customerObject;\n\n if (\n (name.startsWith(\"c\") || name.startsWith(\"C\")) &&\n city === \"Peoria\" &&\n state === \"AZ\" &&\n ((age >= 29 &&\n (membershipLevel === \"GOLD\" || membershipLevel === \"PLATINUM\")) ||\n (age < 29 && membershipLevel === \"SILVER\"))\n ) {\n return true;\n }\n\n return false;\n}\n\n// write names of customers that satisfy conditions \ncustomers.filter(checkCustomer).forEach(customer => {\n console.log(customer.name); \n})"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7435186/"
] |
74,344,829 | <p>I have two CSV files<br />
csv1:</p>
<pre><code>header
a
b
c
</code></pre>
<p>csv2:\</p>
<pre><code>header
e
f
g
</code></pre>
<p>I want to merge these two files to another CSV in alternate rows like<br />
output.csv:</p>
<pre><code>header
a
e
b
f
c
g
</code></pre>
<p>Can this be done? Thanks in advance</p>
| [
{
"answer_id": 74344935,
"author": "Achille G",
"author_id": 10687907,
"author_profile": "https://Stackoverflow.com/users/10687907",
"pm_score": 1,
"selected": true,
"text": "import pandas as pd\nfrom itertools import chain, zip_longest\n\nx = pd.DataFrame()\nx[\"header\"] = [1, 3, 5, 7]\n\ny = pd.DataFrame()\ny[\"header\"] = [2, 4, 6, 8, 10, 21]\n\nchained = list(chain.from_iterable(zip_longest(x[\"header\"].to_list(), y[\"header\"].to_list())))\ndf = pd.DataFrame()\ndf[\"header\"] = chained\ndf = df.dropna()\n"
},
{
"answer_id": 74345092,
"author": "Bhargav",
"author_id": 15358800,
"author_profile": "https://Stackoverflow.com/users/15358800",
"pm_score": 1,
"selected": false,
"text": "df1"
},
{
"answer_id": 74345758,
"author": "0x0fba",
"author_id": 20339407,
"author_profile": "https://Stackoverflow.com/users/20339407",
"pm_score": 0,
"selected": false,
"text": "with open(\"csv1.txt\") as f1, open(\"csv2.txt\") as f2, open(\"output.txt\", \"w\") as fo:\n csv1, csv2 = f1.readlines(), f2.readlines()\n header, _ = csv1.pop(0), csv2.pop(0)\n output = [header]\n for i in range(min(len(csv1),len(csv2))):\n output.extend([csv1[i], csv2[i]])\n fo.writelines(output)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10726514/"
] |
74,344,838 | <pre><code>def get_users():
url = "https://blablabla/api/users"
headers = {"Authorization": accessToken, "Content-Type": "application/json", "Accept": "application/json"}
r = requests.get(url, headers=headers)
r_dict = r.json()
return r_dict
get_user_function = get_users()
</code></pre>
<p>I get a JSON list with given request. I store the list in a global variable.
I mostlikely can not store it to a file, so I have to work with the list, which contains several thousand JSON items looking like this:</p>
<pre><code>[
{
"created": "2021-01-1 09:02:35.112 +0000 UTC",
"id": "123456",
"clientID": "client_client",
"name": "name_name",
"old": true,
"config": {
"config_option_1": false,
"config_option_2": true,
"config_option_3": false,
"config_option_4": false,
"config_option_5": false,
"config_option_6": false,
"config_option_7": false,
"config_option_8": "123",
"config_option_9": "456",
"config_option_10": "",
"config_option_11": {},
"config_option_12": {
"config_option_12.1": {
"config_option_12.1.1": true,
"config_option_12.1.2": true,
"config_option_12.1.3": false,
"config_option_12.1.4": true,
"config_option_12.1.5": false,
"config_option_12.1.6": false,
"config_option_12.1.7": false,
"config_option_12.1.8": false
}}}}]
</code></pre>
<p>This is about half of the very first item.
No I iterate through that list, to store the "name" to an empty dict with several "config_options" attached to that name.
Problem is: not all of them items are the same, so sometimes there is "created" missing, or "config_option_12" is empty or located at a different spot.
This leads to a KeyError. I used exceptions to just ignore those cases, but I can't just ignore them. I need to either find the "config_option" that is located unter antother parent or in case something is missing, just leave it empty.</p>
<p>I did it like this:</p>
<pre><code>my_dict = {}
for i in range(len(get_user_function)):
try:
item = get_user_function[i]
my_dict[i] = {item["name"]: [item["id"], item["created"], item["config"]["config_option_12"]] for item in get_user_function}
except KeyError:
continue
print(my_dict)
</code></pre>
| [
{
"answer_id": 74344952,
"author": "treuss",
"author_id": 19838568,
"author_profile": "https://Stackoverflow.com/users/19838568",
"pm_score": 1,
"selected": false,
"text": "dict.get"
},
{
"answer_id": 74347156,
"author": "c8999c 3f964f64",
"author_id": 11803687,
"author_profile": "https://Stackoverflow.com/users/11803687",
"pm_score": 0,
"selected": false,
"text": "json.get(\"optional\").get(\"maybe\")"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339924/"
] |
74,344,888 | <p>so i've been working on problem and i found the solution but I would like please someone to explain me further why this works actually</p>
<pre><code>const game = {
team1: 'Bayern Munich',
team2: 'Borrussia Dortmund',
score: '4:0',
scored: ['Lewandowski', 'Gnarby', 'Lewandowski', 'Hummels'],
date: 'Nov 9th, 2037',
odds: {
team1: 1.33,
x: 3.25,
team2: 6.5,
},
};
</code></pre>
<p>So, having the above object I was trying to : create an object called 'scorers' which contains the names of the
players who scored as properties, and the number of goals as the value. In this
game.
I came with this solution :</p>
<pre><code>const scorers = {};
for (const player of game.scored) {
scorers[player] ? scorers[player]++ : (scorers[player] = 1);
};
console.log(scorers);
</code></pre>
| [
{
"answer_id": 74344952,
"author": "treuss",
"author_id": 19838568,
"author_profile": "https://Stackoverflow.com/users/19838568",
"pm_score": 1,
"selected": false,
"text": "dict.get"
},
{
"answer_id": 74347156,
"author": "c8999c 3f964f64",
"author_id": 11803687,
"author_profile": "https://Stackoverflow.com/users/11803687",
"pm_score": 0,
"selected": false,
"text": "json.get(\"optional\").get(\"maybe\")"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16703892/"
] |
74,344,911 | <p>I have a nested object that looks like:</p>
<pre><code>public record Options
{
public BatterySettings BatterySettings { get; init; } = new();
public LogSettings LogSettings { get; init; } = new();
}
public record LogSettings
{
public string SourceName { get; init; } = "Default";
}
public record BatterySettings
{
public int BatteryLevel { get; init; } = 5;
public string BatteryHealth { get; init; } = "Normal";
public BatteryLocations BatteryLocation { get; init; } = BatteryLocations.North;
}
public enum BatteryLocations
{
North,
South
}
</code></pre>
<p>After initializing the object and setting some properties i.e.:</p>
<pre><code>var opt = new Options
{
BatterySettings = new BatterySettings {
BatteryLevel = 10,
BatteryHealth = "Low"
}
}
</code></pre>
<p>I would like to get a JSON string that represents this object <code>opt</code> <strong>while having all the default value set to null</strong> i.e. in this above example, the resulting <code>opt</code> JSON string would look like:</p>
<pre class="lang-json prettyprint-override"><code>{
"BatterySettings":{
"BatteryLevel":10,
"BatteryHealth":"Low",
"BatteryLocation":null
},
"LogSettings":{
"SourceName":null
}
}
</code></pre>
<p>Is there a built-in way in .NET to do such a thing?</p>
<p><strong>Edit 1</strong>: the built-in way of utilizing the null serialization settings would not work since the object <code>Options</code> has non-null default values for its properties and sub-object properties.
It seems that a custom converter would need to be implemented here though I have trouble figuring out the correct approach to this due to having to compare default values with the object's current value for every given nodes</p>
| [
{
"answer_id": 74344952,
"author": "treuss",
"author_id": 19838568,
"author_profile": "https://Stackoverflow.com/users/19838568",
"pm_score": 1,
"selected": false,
"text": "dict.get"
},
{
"answer_id": 74347156,
"author": "c8999c 3f964f64",
"author_id": 11803687,
"author_profile": "https://Stackoverflow.com/users/11803687",
"pm_score": 0,
"selected": false,
"text": "json.get(\"optional\").get(\"maybe\")"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7096815/"
] |
74,344,912 | <p>I have been trying to wrap my head around this problem which probably has a very easy solution.
I am running a bioinformatics workflow where I have one file as input and I want to run a program on it. However I want that program to be run with multiple parameters. Let me explain.</p>
<p>I have <code>file.fastq</code> and I want to run <code>cutadapt</code> (in the shell) with two flags: <code>--trim</code> and <code>-e</code>. I want to run trim with values <code>--trim 0</code> and <code>--trim 5</code>. Also I want <code>-e</code> with values <code>-e 0.1</code> and <code>-e 0.5</code></p>
<p>Thererfore I want to run the following:<br>
<code>cutadapt file.fastq --trim0 -e0.5 --output ./outputs/trim0_error0.5/trimmed_file.fastq</code><br>
<code>cutadapt file.fastq --trim5 -e0.5 --output ./outputs/trim5_error0.5/trimmed_file.fastq</code><br>
<code>cutadapt file.fastq --trim0 -e0.1 --output ./outputs/trim0_error0.1/trimmed_file.fastq</code><br>
<code>cutadapt file.fastq --trim5 -e0.1 --output ./outputs/trim5_error0.1/trimmed_file.fastq</code><br></p>
<p>I thought snakemake would be perfect for this. So far I tried:</p>
<pre><code>E = [0.1, 0.5]
TRIM = [5, 0]
rule cutadapt:
input:
"file.fastq"
output:
expand("../outputs/trim{TRIM}_error{E}/trimmed_file.fastq", E=E, TRIM=TRIM)
params:
trim = TRIM,
e = E
shell:
"cutadapt {input} -e{params.e} --trim{params.trim} --output {output}"
</code></pre>
<p>However I get an error like this:</p>
<pre><code>shell:
cutadapt file.fastq -e0.1 0.5 --trim0 5 --output {output}
(one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)
</code></pre>
<p>So, as you can see, snakemake is not taking each argument of the TRIM and E variables, but putting them together like a string. How could I solve this problem? Thank you in advance</p>
| [
{
"answer_id": 74345029,
"author": "SultanOrazbayev",
"author_id": 10693596,
"author_profile": "https://Stackoverflow.com/users/10693596",
"pm_score": 2,
"selected": true,
"text": "params"
},
{
"answer_id": 74348339,
"author": "JavierBurgoa",
"author_id": 17523613,
"author_profile": "https://Stackoverflow.com/users/17523613",
"pm_score": 0,
"selected": false,
"text": "rule all"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17523613/"
] |
74,344,955 | <p>I'm doing an API from a existing database (which means it's not an option to change de DB schema) with Django and rest_framework. I have 2 tables, Foos and Bars.</p>
<pre><code>foo_id
1
2
</code></pre>
<pre><code>bar_id | foo_id (FK)
1 |1
2 |2
</code></pre>
<p>Bars model:
<code>foo = models.ForeignKey('Foos', on_delete=models.CASCADE)</code><br>
The Django Model changes de 'foo_id' FK into 'foo' only. There is a way to keep the FK with the '_id' suffix?</p>
| [
{
"answer_id": 74345172,
"author": "mbofos01",
"author_id": 17790231,
"author_profile": "https://Stackoverflow.com/users/17790231",
"pm_score": 0,
"selected": false,
"text": "models.ForeignKey(\n Foos,\n on_delete=models.CASCADE,\n to_field='id'\n)\n"
},
{
"answer_id": 74345658,
"author": "null92",
"author_id": 19504779,
"author_profile": "https://Stackoverflow.com/users/19504779",
"pm_score": 0,
"selected": false,
"text": "foo_id = models.ForeignKey('Foos', on_delete=models.CASCADE, db_column='foo_id')"
},
{
"answer_id": 74345708,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 1,
"selected": false,
"text": "from rest_framework import serializers\n\n\nclass BarSerializer(serializers.ModelSerializer):\n foo_id = serializers.PrimaryKeyRelatedField(source='foo')\n\n class Meta:\n model = Bar\n fields = ['foo_id']"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19504779/"
] |
74,344,993 | <p>I am trying to check if the value entered in the text box matches the content of the combobox or not.
But the condition is not met with me.</p>
<pre><code>string Dnaam = tbAnimal.Text;
for (int i = 0; i < cmbAnimals.Items.Count; i++)
{
if (Dnaam == (cmbAnimals.Items.GetItemAt(i).ToString()))
{
MessageBox.Show("Het Animal is gevonden, het is de " + i + "item");
}
}
MessageBox.Show("Het Animal is not gevonden");`
</code></pre>
| [
{
"answer_id": 74345172,
"author": "mbofos01",
"author_id": 17790231,
"author_profile": "https://Stackoverflow.com/users/17790231",
"pm_score": 0,
"selected": false,
"text": "models.ForeignKey(\n Foos,\n on_delete=models.CASCADE,\n to_field='id'\n)\n"
},
{
"answer_id": 74345658,
"author": "null92",
"author_id": 19504779,
"author_profile": "https://Stackoverflow.com/users/19504779",
"pm_score": 0,
"selected": false,
"text": "foo_id = models.ForeignKey('Foos', on_delete=models.CASCADE, db_column='foo_id')"
},
{
"answer_id": 74345708,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 1,
"selected": false,
"text": "from rest_framework import serializers\n\n\nclass BarSerializer(serializers.ModelSerializer):\n foo_id = serializers.PrimaryKeyRelatedField(source='foo')\n\n class Meta:\n model = Bar\n fields = ['foo_id']"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20337469/"
] |
74,344,996 | <p>In an Angular 11 app, I have a simle service that mekes a <code>get</code> request and reads a JSON.</p>
<p>The service:</p>
<pre><code>import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Promo } from '../models/promo';
@Injectable({
providedIn: 'root'
})
export class PromoService {
public apiURL: string;
constructor(private http: HttpClient) {
this.apiURL = `https://api.url.com/`;
}
public getPromoData(){
return this.http.get<Promo>(`${this.apiURL}/promo`);
}
}
</code></pre>
<p>In the the component, I need to compare the array of <em>products</em> with the array of <em>campaign products</em> (included in the JSON mantioned above) and <em>higlight the promoted products</em>:</p>
<pre><code>export class ProductCardComponent extends DestroyableComponent implements OnInit, OnChanges
{
public promoData: any;
public promoProducts: any;
public isPromoProduct: boolean = false;
public ngOnInit() {
this.getCampaignData();
}
public ngOnChanges(changes: SimpleChanges): void {
this.getCampaignData();
}
public getPromoData() {
this.promoService.getPromoData().pipe(takeUntil(this.destroyed$)).subscribe(data => {
this.promoData = data;
this.promoProducts = this.promoData.products;
let promoProduct = this.promoProducts.find((product:any) => {
return this.product.unique_identifier == product.unique_identifier;
});
if (promoProduct) {
// Update boolean
this.isPromoProduct = true;
}
});
}
}
</code></pre>
<p>In the component's html file (template), I have:</p>
<pre><code><span *ngIf="isPromoProduct" class="promo">Promo</span>
</code></pre>
<p>There are <strong>no compilation errors</strong>.</p>
<h3>The problem</h3>
<p>For a reason I have been unable to understand, the template does not react to the change of the variable <code>isPromoProduct</code> and the template is not updated, despite the fact that I call the function inside <code>ngOnInit</code> <em>and</em> <code>ngOnChanges</code>.</p>
<h5>Questions:</h5>
<ol>
<li>Where is my mistake?</li>
<li>What is a reliable way to update the template?</li>
</ol>
| [
{
"answer_id": 74345167,
"author": "Octavian Mărculescu",
"author_id": 1440005,
"author_profile": "https://Stackoverflow.com/users/1440005",
"pm_score": 1,
"selected": false,
"text": "isPromoProduct"
},
{
"answer_id": 74345263,
"author": "Eli Porush",
"author_id": 14598976,
"author_profile": "https://Stackoverflow.com/users/14598976",
"pm_score": 3,
"selected": true,
"text": "subscribing"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74344996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4512005/"
] |
74,345,019 | <p>I have this program with me. Where I am trying to concatenate a user input to a command, inorder to execute it in a wsl environment.</p>
<pre><code>#include<stdio.h>
#include<stdlib.h>
int main(){
char cmd[100];
char usr_in[50];
fgets(usr_in, sizeof(usr_in), stdin);
cmd = snprintf(cmd, sizeof(cmd), "ping %s", usr_in);
system(cmd);
return 0;
}
</code></pre>
<p>But this gives me the following error during compilation.</p>
<pre><code>error: incompatible types in assignment of ‘int’ to ‘char [100]’
cmd = snprintf(cmd, sizeof(cmd), "ping %s", usr_in);
</code></pre>
<p>I am not able to figure out which integer assignment it is talking about. The <strong>sizeof(cmd)</strong> is the only integer there and it is a valid argument to the <strong>snprintf</strong>.</p>
| [
{
"answer_id": 74345167,
"author": "Octavian Mărculescu",
"author_id": 1440005,
"author_profile": "https://Stackoverflow.com/users/1440005",
"pm_score": 1,
"selected": false,
"text": "isPromoProduct"
},
{
"answer_id": 74345263,
"author": "Eli Porush",
"author_id": 14598976,
"author_profile": "https://Stackoverflow.com/users/14598976",
"pm_score": 3,
"selected": true,
"text": "subscribing"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17872702/"
] |
74,345,036 | <p>I have parallel API calls. How to continue getting data from one of them if second one failed?</p>
<pre><code>forkJoin([a,b])
.subscribe({
next: ((data) => {
const [first, second] = data;
})
</code></pre>
| [
{
"answer_id": 74345177,
"author": "Meddah Abdallah",
"author_id": 8208547,
"author_profile": "https://Stackoverflow.com/users/8208547",
"pm_score": 3,
"selected": true,
"text": "combineLatest([\n obs1$.pipe(catchError(() => of(null)),\n obs2$.pipe(catchError(() => of(null)),\n]).subscribe(([first, second]) => { console.log(first,second); });\n"
},
{
"answer_id": 74345231,
"author": "Boris Adamyan",
"author_id": 10263768,
"author_profile": "https://Stackoverflow.com/users/10263768",
"pm_score": 0,
"selected": false,
"text": "catchError(() => of([]))\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10263768/"
] |
74,345,084 | <p><a href="https://i.stack.imgur.com/nEjBo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nEjBo.png" alt="enter image description here" /></a></p>
<p>How do I create a column in my dataframe called 'Yes Or No', where a '1' is input into each row where the "Date" column is between 01/01/2022 and 31/03/2022 and the "Datefield 2" column cannot be empty. I have started with the code below, but it doesn't produce the right output.</p>
<p><code>df['Yes Or No'] = (df['Datefield 2'] != [''] & pd.to_datetime(df['Date'], dayfirst=True).between(pd.Timestamp('2022-03-31'), pd.Timestamp('2023-01-01'))).astype(int) </code></p>
| [
{
"answer_id": 74345136,
"author": "Bushmaster",
"author_id": 15415267,
"author_profile": "https://Stackoverflow.com/users/15415267",
"pm_score": 0,
"selected": false,
"text": "import numpy as np\ndf['Date']=pd.to_datetime(df['Date'])\ndf['yes_or_no']=np.where((df['Date'] >= '01/01/2022') & (df['Date'] <= '31/03/2022') & (df['Date2']!= ''),1,0)\n"
},
{
"answer_id": 74345137,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "d1 = pd.to_datetime(df['Date'], dayfirst=True)\nd2 = pd.to_datetime(df['Datefield 2'], dayfirst=True)\n\ndf['Yes Or No'] = (d2.notna() & d1.between('2022-03-31', '2023-01-01')).astype(int)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10094736/"
] |
74,345,088 | <p>I am getting an unexpected ItemGroup entry for each rename.</p>
<p>If I start with interface <code>public interface IDoStuff</code> and rename it to <code>IDoStuffRename</code> I get this in my csproj on save:</p>
<pre><code><ItemGroup>
<NativeLibs Remove="IDoStuffRename.cs" />
</ItemGroup>
</code></pre>
<p>It does not happen on delete or move. This heavily pollutes the csproj file over time after continuous refactoring.</p>
<blockquote>
<p>Any idea why this is happening and how I can avoid that extra entry?</p>
</blockquote>
<p><em>I currently undo it manually.</em></p>
| [
{
"answer_id": 74345136,
"author": "Bushmaster",
"author_id": 15415267,
"author_profile": "https://Stackoverflow.com/users/15415267",
"pm_score": 0,
"selected": false,
"text": "import numpy as np\ndf['Date']=pd.to_datetime(df['Date'])\ndf['yes_or_no']=np.where((df['Date'] >= '01/01/2022') & (df['Date'] <= '31/03/2022') & (df['Date2']!= ''),1,0)\n"
},
{
"answer_id": 74345137,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "d1 = pd.to_datetime(df['Date'], dayfirst=True)\nd2 = pd.to_datetime(df['Datefield 2'], dayfirst=True)\n\ndf['Yes Or No'] = (d2.notna() & d1.between('2022-03-31', '2023-01-01')).astype(int)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5159468/"
] |
74,345,109 | <p>I need to extract the string between <code>CAKE_FROSTING("</code> and <code>",</code>. If the string extends over multiple lines, the quotation marks and newline at the line changes must be removed. I have a command (thanks stackoverflow) that does something in that direction, but not exactly. How can I fix it (and can you shortly explain the fixes)? I am using Linux bash.</p>
<pre><code>sed -En ':a;N;s/.*CAKE_FROSTING\(\n?\s*?"([^,]*).*/\1/p;ba' filesToCheck/* > result.txt
</code></pre>
<p>filesToCheck/file.h</p>
<pre><code>something
CAKE_FROSTING(
"is supreme",
"[i][agree]") something else
something more
something else
CAKE_FROSTING(
"is."kinda" neat"
"in fact",
"[i][agree]") something else
something more
</code></pre>
<p>result.txt current</p>
<pre><code>is supreme"
is."kinda" neat"
</code></pre>
<p>result.txt desired</p>
<pre><code>is supreme
is."kinda" neat in fact
</code></pre>
<p>Edit: With help from @D_action I now have</p>
<pre><code>sed -En ':a;N;s/.*CAKE_FROSTING\(\n?\s*?"([^,]*).*,/\1/p;ba' filesToCheck/* > result.txt
</code></pre>
<p>this produces almost the correct output, but there are unnecessary quotation marks and one too many newline in the output:</p>
<p>result.txt current</p>
<pre><code>is supreme"
is."kinda" neat"
"in fact"
</code></pre>
| [
{
"answer_id": 74345730,
"author": "HatLess",
"author_id": 16372109,
"author_profile": "https://Stackoverflow.com/users/16372109",
"pm_score": 4,
"selected": true,
"text": "sed"
},
{
"answer_id": 74345998,
"author": "Wiktor Stribiżew",
"author_id": 3832970,
"author_profile": "https://Stackoverflow.com/users/3832970",
"pm_score": 1,
"selected": false,
"text": "perl"
},
{
"answer_id": 74371334,
"author": "potong",
"author_id": 967492,
"author_profile": "https://Stackoverflow.com/users/967492",
"pm_score": 2,
"selected": false,
"text": "sed '/^CAKE_FROSTING($/!d;z;:a;N;s/^\"\\([^[].*\\)\".*/\\1/mg;ta;s/^.\\(.*\\)\\n.*/\\1/;y/\\n/ /' file\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19017877/"
] |
74,345,131 | <p>My App.js file code</p>
<pre><code>import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import {NavigationContainer} from '@react-navigation/native'
import {createNativeStackNavigator} from '@react-navigation/native-stack'
import HomeScreen from './components/HomeScreen'
import Details from './components/Details'
const Stack = createNativeStackNavigator();
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name = 'Home' component={HomeScreen}/>
<Stack.Screen name = 'Details' component={Details}/>
</Stack.Navigator>
</NavigationContainer>
);
}
</code></pre>
<p>HomeScreen.js Code</p>
<pre><code>import React, {useState,useEffect} from 'react'
import {Text,
View,
StyleSheet,
TextInput,
TouchableOpacity,
SafeAreaView,
} from 'react-native'
const HomeScreen = () => {
const [recipes, setRecipes] = useState();
const [searchQuery, setSearchQuery] = useState('');
const [numberOfRecipes, setNumberOfRecipes] = useState('');
const [loading, setLoading] = useState(false);
const apiId = '30f0071b'
const apiKey = '23e828ea96641c06655aa2f585757d1d'
const apiUrl = `https://api.edamam.com/searh?q=${searchQuery}&app_id=${apiId}&app_key=${apiKey}&from=0&to=${numberOfRecipes}&calories=591-722&health=alcohol-free`;
async function apiCall() {
setLoading(true);
let resp = await fetch(apiUrl);
let respJson = await resp.json();
setRecipes(respJson.hits);
setLoading(false);
Keyboard.dismiss();
setSearchQuery('');
}
useEffect(() =>{
setLoading(true);
apiCall()
});
return (
<View style={styles.container}>
<Text style={{fontSize:18, fontWeight:'bold', color:'#008080'}}>
What Recipe Would You Like to Search?
</Text>
<View sytle = {{display: 'flex', flexDirection: 'row'}}>
<TextInput placeholder = 'Search Recipe...'
style={styles.inputField}
onChangeText={ text => setSearchQuery(text)}
/>
<TextInput
style={[styles.inputField, {width: '20%', paddingLeft:20, paddingRight:20, fontSize:18, marginLeft:10,color:'#008080', fontWeight:'bold'}]}
value={numberOfRecipes}
keyboardType='number-pad'
onChangeText={ text => setNumberOfRecipes(text)}
/>
<TouchableOpacity style={styles.button}
onPress={apiCall}
title='submit'>
<Text style={styles.buttonText}>Search</Text>
</TouchableOpacity>
<SafeAreaView style={{flex:1}}>
{loading ? <ActivityIndicator size='large' color='#008080'/> :
<FlatList
style={styles.recipes}
data={recipes}
renderItem={({item}) => (
<View style={styles.recipe}>
<Image style={styles.image}
source={{url: `${item.recipe.image}`}}
/>
<View style={{padding:20,flexDirection:'row'}}>
<Text style={styles.label}>{item.recipe.label}</Text>
<TouchableOpacity onPress={() =>{}}>
<Text style={{marginLeft:50, fontSize:20, color: '#008080'}}>
Details
</Text>
</TouchableOpacity>
</View>
</View>
)}
keyExtractor={(item, index ) => index.toString()} />
}
</SafeAreaView>
</View>
)}
const styles = StyleSheet.create({
container: {
flex:1,
justifyContent:'center',
alignItems:'center',
padding:10,
},
inputField:{
backgroundColor:'white',
borderRadius:20,
marginTop:10,
paddingLeft:15,
},
buttons:{
flexDirection:'row'
},
button:{
backgroundColor:'#008080',
width:'90%',
alignItems: 'center',
margin:15,
height:45,
borderRadius:15,
justifyContent: 'center',
marginTop:25,
paddingLeft:20,
paddingRight:20
},
buttonText:{
color:'white'
}
})
export default HomeScreen
</code></pre>
<p>I am facing below Error but after reviewing many times i am unable to find what exactly is issue. styles code is perfectly fine. I would appreciate any help provided.</p>
<p>SyntaxError: D:\react\native\recipe-search-app\components\HomeScreen.js: Unexpected token, expected "}" (102:9)</p>
<p>100 |
101 | const styles = StyleSheet.create({</p>
<blockquote>
<p>102 | container: {
| ^
103 | flex:1,
104 | justifyContent:'center',
105 | alignItems:'center',</p>
</blockquote>
| [
{
"answer_id": 74345730,
"author": "HatLess",
"author_id": 16372109,
"author_profile": "https://Stackoverflow.com/users/16372109",
"pm_score": 4,
"selected": true,
"text": "sed"
},
{
"answer_id": 74345998,
"author": "Wiktor Stribiżew",
"author_id": 3832970,
"author_profile": "https://Stackoverflow.com/users/3832970",
"pm_score": 1,
"selected": false,
"text": "perl"
},
{
"answer_id": 74371334,
"author": "potong",
"author_id": 967492,
"author_profile": "https://Stackoverflow.com/users/967492",
"pm_score": 2,
"selected": false,
"text": "sed '/^CAKE_FROSTING($/!d;z;:a;N;s/^\"\\([^[].*\\)\".*/\\1/mg;ta;s/^.\\(.*\\)\\n.*/\\1/;y/\\n/ /' file\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3305642/"
] |
74,345,170 | <p>I have a table, it has these columns:</p>
<pre><code> id | tx_hash | tx_status | created_at
----------+---------+-----------+---------------------------
15000000 | 0x0011 | 0 | 2021-07-30 06:42:00.267694
15000001 | 0x0011 | 0 | 2021-07-30 06:42:00.267694
15000002 | 0x0011 | 0 | 2021-07-30 06:42:00.267694
...
16000000 | 0x0011 | 0 | 2021-07-30 06:42:00.267694
</code></pre>
<p>I want to query by 2 columns: <code>tx_status</code> by <code>equal</code> and <code>id</code> by "greater than". My SQL query is:</p>
<pre><code>select id, tx_hash, tx_status, created_at
from pool_transaction_entries
where tx_status = 0 and id > 15006000
order by id desc
limit 1;
</code></pre>
<p>and I found it very slow !</p>
<p>and this is the analysis result:</p>
<pre><code>postgres=> explain analyze verbose select id, tx_hash, tx_status, created_at from pool_transaction_entries where tx_status = 0 and id > 15006000 order by id desc limit 1;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.43..133.80 rows=1 width=87) (actual time=21415.241..21415.242 rows=0 loops=1)
Output: id, tx_hash, tx_status, created_at
-> Index Scan Backward using pool_transaction_entries_pkey on public.pool_transaction_entries (cost=0.43..3868.12 rows=29 width=87) (actual time=21415.238..21415.239 rows=0 loops=1)
Output: id, tx_hash, tx_status, created_at
Index Cond: (pool_transaction_entries.id > 15006000)
Filter: (pool_transaction_entries.tx_status = 0)
Rows Removed by Filter: 3556
Query Identifier: 3330758434230110582
Planning Time: 54.206 ms
Execution Time: 21415.281 ms
(10 rows)
</code></pre>
<p>could you please give me a clue how to create index or optimize for this? thanks a lot!</p>
| [
{
"answer_id": 74351078,
"author": "SQLpro",
"author_id": 12659872,
"author_profile": "https://Stackoverflow.com/users/12659872",
"pm_score": 0,
"selected": false,
"text": "CREATE INDEX X \n ON pool_transaction_entries (tx_status, id) \n INCLUDE (tx_hash, created_at);\n"
},
{
"answer_id": 74355591,
"author": "Siwei",
"author_id": 445908,
"author_profile": "https://Stackoverflow.com/users/445908",
"pm_score": -1,
"selected": false,
"text": "just create an index on (tx_status, id)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445908/"
] |
74,345,176 | <p>I wanted to execute a simple Instruction from the click event of the button but it indicates a lot of errors to me and I cannot understand the problem. I have tried to do as explained in the React site guide but it's not good anyway. Here is the code.
Could you help me? Is the syntax actually wrong?</p>
<p>The error is(it is written in Italian which would be my language):
[{
"resource": "/c:/Users/Alberto/Desktop/MeteorProject/myApp/imports/ui/App.jsx",
"owner": "typescript",
"code": "1005",
"severity": 8,
"message": "È previsto ','.",
"source": "ts",
"startLineNumber": 5,
"startColumn": 9,
"endLineNumber": 5,
"endColumn": 14
}]</p>
<pre><code>export const App = () => (
const click = () => (
let message = 'Ciao come stai?',
return(
<b>{message}</b>
)
),
<div>
<h1>Welcome to Meteor!</h1>
<button onClick={click}>Clicca</button>
</div>
);
</code></pre>
| [
{
"answer_id": 74345267,
"author": "T.J. Crowder",
"author_id": 157247,
"author_profile": "https://Stackoverflow.com/users/157247",
"pm_score": 2,
"selected": false,
"text": "click"
},
{
"answer_id": 74345454,
"author": "Tania12",
"author_id": 18058025,
"author_profile": "https://Stackoverflow.com/users/18058025",
"pm_score": 0,
"selected": false,
"text": "export const App = () => {\nconst [btnClicked,setIsBtnClicked] = useState(false)\nlet message = 'Ciao come stai?'\nreturn (\n <div>\n <h1>Welcome to Meteor!</h1>\n <button onClick={() =>setIsBtnClicked(!btnClicked) }>Clicca</button>\n {btnClicked && <b>{message}</b>}\n </div>\n )\n}\n "
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439107/"
] |
74,345,187 | <p>How can I disable the developer tools for a Maui WebView control ? With Xamarin WebView2 it is quite easy with CoreWebView2.Settings.AreDevToolsEnabled.</p>
<p>In fact, I believe at least on Windows, the Maui WebView is based on CoreWebView2. Is there a way to access the CoreWebView2.Settings directly ?</p>
<p>Thanks,</p>
| [
{
"answer_id": 74354933,
"author": "Liyun Zhang - MSFT",
"author_id": 17455524,
"author_profile": "https://Stackoverflow.com/users/17455524",
"pm_score": 1,
"selected": false,
"text": "WebView"
},
{
"answer_id": 74460212,
"author": "mlg",
"author_id": 7324528,
"author_profile": "https://Stackoverflow.com/users/7324528",
"pm_score": 1,
"selected": true,
"text": " WebView wv = new WebView();\n wv.Navigating += Wv_Navigating ;\n\nprivate void Wv_Navigating(object sender, WebNavigatingEventArgs e)\n{\n WebView webview = (WebView)sender;\n CoreWebView2 coreWebView2 = (webview.Handler.PlatformView as Microsoft.UI.Xaml.Controls.WebView2).CoreWebView2;\n coreWebView2.Settings.AreDevToolsEnabled = false;\n webview.Navigating -= Wv_Navigating;\n}\n\n \n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7324528/"
] |
74,345,214 | <p>I'm trying to add some div containers to an html file. I figure there are two sets of logic.<br />
<strong>First</strong> is to look for a string at position X, then insert <code><div ...></code> at the end of the line. I have this working.<br />
<strong>Second</strong> set of logic is to look for string at position X after the above condition is satisfied, then insert the container closure <code></div></code>.</p>
<p>At the moment I can look for the <code>button</code> string at position 2 and insert <code><div ...></code>, I'm using a while loop for this. If you have any ideas on how to tackle the second bit of logic that'd be much appreciated.</p>
<p><strong>Here is a snippet of the html file:</strong></p>
<pre><code>...
<p>test.txt</p>
<button type="button" class="collapsible">tmp</button>
<p>example1.txt</p>
<p>example2.txt</p>
<p>example3.txt</p>
<p>example.txt</p>
...
</code></pre>
<p><strong>The end result I need is:</strong></p>
<pre><code>...
<p>test.txt</p>
<button type="button" class="collapsible">tmp</button>
<div>
<p>example1.txt</p>
<p>example2.txt</p>
<p>example3.txt</p>
</div>
<p>example.txt</p>
...
</code></pre>
| [
{
"answer_id": 74354933,
"author": "Liyun Zhang - MSFT",
"author_id": 17455524,
"author_profile": "https://Stackoverflow.com/users/17455524",
"pm_score": 1,
"selected": false,
"text": "WebView"
},
{
"answer_id": 74460212,
"author": "mlg",
"author_id": 7324528,
"author_profile": "https://Stackoverflow.com/users/7324528",
"pm_score": 1,
"selected": true,
"text": " WebView wv = new WebView();\n wv.Navigating += Wv_Navigating ;\n\nprivate void Wv_Navigating(object sender, WebNavigatingEventArgs e)\n{\n WebView webview = (WebView)sender;\n CoreWebView2 coreWebView2 = (webview.Handler.PlatformView as Microsoft.UI.Xaml.Controls.WebView2).CoreWebView2;\n coreWebView2.Settings.AreDevToolsEnabled = false;\n webview.Navigating -= Wv_Navigating;\n}\n\n \n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6071696/"
] |
74,345,227 | <p>I updated MVC3 to MVC4, since then I get lots of problems when I try to upload new version on iis servers
<a href="https://i.stack.imgur.com/FDugx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FDugx.png" alt="this is what I get on server when I run it locally" /></a></p>
<p>if for example I will change reference to dll in web.config to be the previous one for example System.Web.Helpers
from 2.0.0.0 to 1.0.0.0 I will get Server Error in '/' Application. if I have a look in event viewer I can see that the problem is Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. which is right. but when I fix it I get 404 and I totally not understand why. The resource I'm looking for has not been removed, had its name was not changed, and is available.</p>
<p>this is my web.config</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="EasyCard.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
<CipherValue>AQAAANT1OEUHcgVx7wrYZXhCjSKB9RRz8ouQvSmWwnB3pW/JeEJQ0DDkL3BtUdxkAAAAAJftXTnsZMcS59nUna7Ft55reLlyuHVy+WAQUF4ZEotg1pJT84MUPsmXbDg+2Z1L+Ene/W8kHzEV5O6omJLR2d</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="AutoEncyptConfig" value="True" />
<add key="EnsureBackDaysCountToView" value="30" />
</appSettings>
<enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source">
<sources>
<add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="File-based Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" filePath="C:\EasyCard\Web\PublicWeb\entlib.config" />
</sources>
<redirectSections>
<add sourceName="File-based Configuration Source" name="loggingConfiguration" />
</redirectSections>
</enterpriseLibrary.ConfigurationSource>
<system.web>
<sessionState timeout="15" />
<globalization uiCulture="he-IL" culture="he-IL" />
<customErrors mode="On" defaultRedirect="~/Errors">
<error statusCode="404" redirect="~/Errors/E404" />
</customErrors>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
</httpHandlers>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
</compilation>
<roleManager enabled="true" defaultProvider="BasicRoleProvider">
<providers>
<add name="BasicRoleProvider" type="EasyCard.Membership.BasicRoleProvider" />
</providers>
</roleManager>
<authentication mode="Forms">
<forms loginUrl="~/Accounts/Login" timeout="15" requireSSL="true" slidingExpiration="true" defaultUrl="~/" protection="All" cookieless="UseCookies" />
</authentication>
<authorization>
<allow users="*" />
</authorization>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<httpRuntime shutdownTimeout="108000" requestPathInvalidCharacters="" encoderType="Common.AntiXssEncoder, Common" targetFramework="4.6" />
<machineKey decryptionKey="A3CC7D1756C4EB8CC4D2DFA7A3A202475F6ABAC8D0D08411" validationKey="8CB42DE40D168E41DA9FE8AF798446ED8951D0719CF241F5311946B708E7BFE2F98C72B73B55C66E011EF8CA57457637B74B42409500133A4E41E587ECEAB465" />
</system.web>
<location path="BillingSystem/CreateCustomerFormRequest">
<system.web>
<authorization>
<allow users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Home/CalculateUpayCommission">
<system.web>
<authorization>
<allow users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Home/GetUpayCommissionsTable">
<system.web>
<authorization>
<allow users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="BillingForm/RedirectWithShovar">
<system.web>
<authorization>
<allow users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="BillingSystem/CreateCustomerForm">
<system.web>
<authorization>
<allow users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Content">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Scripts">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Accounts/PreLoginChange">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="easycard/cardexp.asp">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="easycard/cardexpurl.asp">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="BillingForm/FillForm">
<system.web>
<authorization>
<allow users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</runtime>
<applicationSettings>
<EasyCard.Properties.Settings>
<setting name="EasyCard_Shva_ABSRequest" serializeAs="String">
<value>https://www.shva-online.co.il/ash/abscheck/absrequest.asmx</value>
</setting>
</EasyCard.Properties.Settings>
</applicationSettings>
<system.net>
<mailSettings>
<smtp>
<network host="10.0.0.20" port="25" />
</smtp>
</mailSettings>
</system.net>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SendMessageSoap" />
<binding name="CurrencyConvertorSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="CurrencyConvertorSoap12">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://www.webservicex.net/CurrencyConvertor.asmx" binding="basicHttpBinding" bindingConfiguration="CurrencyConvertorSoap" contract="CurrencyServiceReference.CurrencyConvertorSoap" name="CurrencyConvertorSoap" />
<endpoint address="http://www.webservicex.net/CurrencyConvertor.asmx" binding="customBinding" bindingConfiguration="CurrencyConvertorSoap12" contract="CurrencyServiceReference.CurrencyConvertorSoap" name="CurrencyConvertorSoap12" />
<endpoint address="http://api.inforu.co.il/SendMessage.asmx" binding="basicHttpBinding" bindingConfiguration="SendMessageSoap" contract="InforUMobileService.SendMessageSoap" name="SendMessageSoap" />
</client>
</system.serviceModel>
</configuration>
</code></pre>
<p>when I try to change version of MVC4 dll in web.config to the previous version of MVC3 i get an error regarding it that it couldn't find assembly with version x and it's right. when I fixe it I expect to get successfully run, but eventually I get 404 not found</p>
| [
{
"answer_id": 74354933,
"author": "Liyun Zhang - MSFT",
"author_id": 17455524,
"author_profile": "https://Stackoverflow.com/users/17455524",
"pm_score": 1,
"selected": false,
"text": "WebView"
},
{
"answer_id": 74460212,
"author": "mlg",
"author_id": 7324528,
"author_profile": "https://Stackoverflow.com/users/7324528",
"pm_score": 1,
"selected": true,
"text": " WebView wv = new WebView();\n wv.Navigating += Wv_Navigating ;\n\nprivate void Wv_Navigating(object sender, WebNavigatingEventArgs e)\n{\n WebView webview = (WebView)sender;\n CoreWebView2 coreWebView2 = (webview.Handler.PlatformView as Microsoft.UI.Xaml.Controls.WebView2).CoreWebView2;\n coreWebView2.Settings.AreDevToolsEnabled = false;\n webview.Navigating -= Wv_Navigating;\n}\n\n \n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20438983/"
] |
74,345,242 | <p>I'm trying to calculate the total price of my cart. It works when I only select the same product but when I chose another product it just multiplies the number of clicks to the total price. How can I rewrite this so it doesn't multiply the amount of clicks?
GIF of my problem: <a href="https://gyazo.com/c273f1d8a3caa3cded6debef52cfadaf" rel="nofollow noreferrer">https://gyazo.com/c273f1d8a3caa3cded6debef52cfadaf</a></p>
<pre><code>const shopContainer = document.querySelector(".shop-content");
let productTitle;
let productDescription;
let productImage;
let productPrice;
let productCategory;
let productId;
let productKey = [];
let productArray = [];
let output = "";
const url = "https://fakestoreapi.com/products";
let data = fetch(url)
.then((res) => res.json())
.then((data) => {
for (let i = 0; i < data.length; i++) {
productTitle = data[i].title;
productDescription = data[i].description;
productImage = data[i].image;
productPrice = data[i].price;
productCategory = data[i].category;
productId = data[i].id;
productArray[i] = [
productTitle,
productDescription,
productImage,
productPrice,
productCategory,
productId,
];
productKey[i] = data[i].id;
localStorage.setItem(productKey[i], JSON.stringify(productArray[i]));
}
showApi();
})
.catch((error) => {
console.error("Error message:", error);
});
function showApi() {
for (let i = 0; i < productArray.length; i++) {
productId = productArray[i][5];
output += `
<div class="product-box">
<img class="product" src="${productArray[i][2]}" alt="product image">
<h2 class="product-title">${productArray[i][0]}</h2>
<div class="bottom-box">
<span class="price">${productArray[i][3]}$</span>
<i class='bx bx-shopping-bag add-cart' "data-id="${productId}" onclick="returnKey(${productArray[i][5]})"></i>
</div>
</div>
`;
}
shopContainer.innerHTML = output;
}
let inputCart = document.querySelector(".inputCart");
function returnKey(clickedId) {
cart.classList.add("active");
console.log(clickedId);
if (localStorage.length !== 0) {
let sum = 0;
Object.keys(localStorage).forEach(function (key) {
productObject = JSON.parse(localStorage.getItem(key));
completeProduct = productObject;
sum += completeProduct[3];
if (completeProduct[5] == clickedId) {
let cartPrice = document.createElement("p");
let cartTitle = document.createElement("p");
let cartImage = document.createElement("img");
inputCart.appendChild(cartPrice);
inputCart.appendChild(cartImage);
inputCart.appendChild(cartTitle);
cartPrice.setAttribute("class", "cart-price")
cartTitle.setAttribute("class", "cart-title");
cartImage.setAttribute("src", completeProduct[2]);
cartImage.setAttribute("width", "75");
cartImage.setAttribute("height", "75");
cartTitle.innerHTML = completeProduct[0];
cartPrice.innerHTML = "$" + completeProduct[3];
console.log(cartPrice);
console.log(cartTitle);
document.getElementById('priceTotal').innerHTML = "Total: " + sum + "$";
console.log(sum)
}
})
}
};
// function totalSum(cartPrice) {
// sum = 0;
// cartPrice = document.querySelectorAll(".cart-price");
// for (let i = 0; i < cartPrice.length; i++) {
// sum = sum + completeProduct[3];
// console.log("Product price " + sum);
// document.getElementById('priceTotal').innerHTML = "Total: " + sum + "$";
// }
// }
let removeBtn = document.getElementById("removeBtn").addEventListener("click", clearCart);
let buyBtn = document.getElementById("buyBtn").addEventListener("click", buyCart);
function clearCart() {
removeCart = window.confirm("Are you sure you want to clear your cart?");
if (removeCart) {
inputCart.innerHTML = "";
document.getElementById('priceTotal').innerHTML = "Total: " + "0" + "$";;
console.clear();
}
};
function buyCart() {
shopMore = window.confirm("Do you want to checkout?");
if (shopMore) {
alert("Thank your for shopping at CatchShop!");
window.location.reload();
}
};
let cartIcon = document.querySelector("#cart-icon");
let cart = document.querySelector(".cart");
let closeCart = document.querySelector("#close-cart");
cartIcon.onclick = () => {
cart.classList.add("active");
};
closeCart.onclick = () => {
cart.classList.remove("active");
};
</code></pre>
<p>Thanks in advance! :)</p>
| [
{
"answer_id": 74345690,
"author": "Skip",
"author_id": 13149335,
"author_profile": "https://Stackoverflow.com/users/13149335",
"pm_score": 3,
"selected": true,
"text": "totalSum()"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20240192/"
] |
74,345,261 | <p>How to count how many times even numbers in row?
For example: 3, 6, 8, 1, 4, 7, 3, 7, 4, 2 (should be '2' = two times even numbers in row - 6,8 and 4,2.</p>
<pre><code>s = [3, 6, 8, 1, 4, 7, 3, 7, 4, 2]
print(len([i for i in s if i % 2 == 0]))
</code></pre>
<p>This one gives how many times (5) even numbers in general. But need how many times even numbers in row. Could anyone please help with solution to get the point.</p>
<p>If you have 3 even numbers in a row. eg: 2,6,4 should be 2(two times)</p>
| [
{
"answer_id": 74345348,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
"author_profile": "https://Stackoverflow.com/users/11622508",
"pm_score": -1,
"selected": false,
"text": "itertools.groupby"
},
{
"answer_id": 74345580,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 0,
"selected": false,
"text": "s = [3, 6, 8, 1, 4, 7, 3, 7, 4, 2]\n\ncount = sum(x % 2 + y % 2 == 0 for x, y in zip(s, s[1:]))\n\nprint(count)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20280838/"
] |
74,345,265 | <p>When I include an external library using Qt Creator, it adds something like the following to my <code>.pro</code> file:</p>
<pre><code>win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../build-mylibrary-Desktop_Qt_5_15_1_MSVC2019_64bit-Release/mylibrary/release/ -lmylibrary
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../build-mylibrary-Desktop_Qt_5_15_1_MSVC2019_64bit-Debug/mylibrary/debug/ -lmylibrary
else:unix: LIBS += -L$$PWD/../../../build-mylibrary-Desktop_Qt_5_15_1_MSVC2019_64bit-Release/mylibrary/ -lmylibrary
INCLUDEPATH += $$PWD/../../../mylibrary
DEPENDPATH += $$PWD/../../../mylibrary
</code></pre>
<p>The path to the library is specific to the compiler and Qt version. I have several libraries that I would like to distribute. There are various dependencies between them. The libraries can be build by different compilers and different Qt versions. So I don't want to distribute the code with a <code>.pro</code> file that assumes MSVC2019 and Qt 5.15.1 (as in the example above). Is there a standard solution to this problem? Or do I just need to expect people who download the code to change the folder names?</p>
| [
{
"answer_id": 74345348,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
"author_profile": "https://Stackoverflow.com/users/11622508",
"pm_score": -1,
"selected": false,
"text": "itertools.groupby"
},
{
"answer_id": 74345580,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 0,
"selected": false,
"text": "s = [3, 6, 8, 1, 4, 7, 3, 7, 4, 2]\n\ncount = sum(x % 2 + y % 2 == 0 for x, y in zip(s, s[1:]))\n\nprint(count)\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1447002/"
] |
74,345,298 | <p>I've tried so many different solutions, but cannot find the one that would work. I have an array of anecdotes and an array of votes that coincide with each anecdote. I can display the selected matching anecdote and vote, but have been unable to increase by 1 the selected/displayed vote for its respective anecdote. How would I code the button to increase the selected/displayed vote by 1 and update the array to display that change?</p>
<pre><code>import { useState } from 'react'
const App = () => {
const anecdotes = [
'If it hurts, do it more often.',
'Adding manpower to a late software project makes it later!',
'The first 90 percent of the code accounts for the first 10 percent of the development time...The remaining 10 percent of the code accounts for the other 90 percent of the development time.',
'Any fool can write code that a computer can understand. Good programmers write code that humans can understand.',
'Premature optimization is the root of all evil.',
'Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.',
'Programming without an extremely heavy use of console.log is same as if a doctor would refuse to use x-rays or blood tests when diagnosing patients.',
]
const [selected, setSelected] = useState(0)
const points = { 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6 }
const copy = {...points}
const [votes, setVotes] = useState(copy)
const voteClick = () => setVotes(votes[selected]+=1)
const randAnecdote = e => {
const len = anecdotes.length;
setSelected(Math.floor(Math.random() * len));
};
return (
<div>
<div>{anecdotes[selected]}</div><br />
This anecdote {copy[selected]} votes<br />
<button onClick={voteClick}>Vote</button><button onClick={randAnecdote}> Next Anecdote</button>
</div>
)
}
export default App
</code></pre>
<pre><code>
I have tried useState, I have tried a more basic form of incrementing, I have tried many different solutions. I want the selected/displayed vote value in the copy array to increase by 1 and when switching to a new, random anecdote and vote, I want the button to increase that selected/displayed vote value by 1. Nothing has worked.
</code></pre>
| [
{
"answer_id": 74345574,
"author": "ncpa0cpl",
"author_id": 8907391,
"author_profile": "https://Stackoverflow.com/users/8907391",
"pm_score": 0,
"selected": false,
"text": "setVotes"
},
{
"answer_id": 74345636,
"author": "Raphael Escrig",
"author_id": 9163798,
"author_profile": "https://Stackoverflow.com/users/9163798",
"pm_score": 1,
"selected": false,
"text": "import { useState, useEffect } from \"react\";\nimport \"./styles.css\";\n\n/** NANOID */\nimport { nanoid } from \"nanoid\";\n\nexport default function App() {\n const [anecdotes, setAnecdotes] = useState([]);\n const [selected, setSelected] = useState(null);\n\n useEffect(() => {\n /** HERE YOU SHOULD DO AN API CALL.\n * THE RETURN SHOULD BE EQUAL TO FORMATTED VARIABLE\n */\n const data = [\n \"If it hurts, do it more often.\",\n \"Adding manpower to a late software project makes it later!\",\n \"The first 90 percent of the code accounts for the first 10 percent of the development time...The remaining 10 percent of the code accounts for the other 90 percent of the development time.\",\n \"Any fool can write code that a computer can understand. Good programmers write code that humans can understand.\",\n \"Premature optimization is the root of all evil.\",\n \"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.\",\n \"Programming without an extremely heavy use of console.log is same as if a doctor would refuse to use x-rays or blood tests when diagnosing patients.\"\n ];\n const points = [0, 1, 2, 3, 4, 5, 6];\n const formatted = data.map((anecdote, index) => ({\n id: nanoid(),\n sentence: anecdote,\n points: points[index] ?? 0\n }));\n\n setAnecdotes(formatted);\n\n formatted.length > 0 && setSelected(formatted[0]);\n }, []);\n\n const handleVote = () => {\n if (selected === null) return;\n\n /** CREATE A NEW COPY */\n const tmp = JSON.parse(JSON.stringify(anecdotes));\n const index = anecdotes.findIndex(\n (anecdote) => anecdote.id === selected.id\n );\n\n if (index === -1) return;\n\n tmp[index].points += 1;\n\n setSelected((current) => ({ ...selected, points: current.points + 1 }));\n setAnecdotes(tmp);\n };\n\n const handleNext = () => {\n const index = anecdotes.findIndex(\n (anecdote) => anecdote.id === selected.id\n );\n\n if (index === anecdotes.length - 1) {\n setSelected(anecdotes.at(0));\n } else {\n setSelected(anecdotes.at(index + 1));\n }\n\n };\n\n if (selected === null) {\n return <p>Loading</p>;\n }\n\n return (\n <div>\n <div>{selected.sentence}</div>\n <br />\n This anecdote has {selected.points} votes\n <br />\n <button onClick={handleVote}>Vote</button>\n <button onClick={handleNext}> Next Anecdote</button>\n </div>\n );\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439240/"
] |
74,345,301 | <p>How to get Element ID in schedules with c# and revit API? similar to this video with Dynamo - <a href="https://youtu.be/U-tVoCYilxo" rel="nofollow noreferrer">https://youtu.be/U-tVoCYilxo</a> - but with c# and revit api.</p>
<p>When I execute my code, the third column doesn't appear and I get only two columns with width and height.</p>
<p>(I don't know what to write more - StackOverflow doesn't let me to post my issue without writing more text...)</p>
<p>here is my try:</p>
<pre><code>using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nice3point.Revit.Toolkit.External;
using Ecoworx.Core.Elements;
namespace Ecoworx
{
[Transaction(TransactionMode.Manual)]
public class CreateScheduleCommandHandler : ExternalEventHandler
{
public override void Execute(UIApplication uiapp)
{
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
CreateSchedule(uiapp);
}
public static void CreateSchedule(UIApplication uiapp)
{
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
using (Transaction t = new Transaction(doc, "Create single-category"))
{
t.Start();
// Create schedule
ViewSchedule vs = ViewSchedule.CreateSchedule(doc, new ElementId(BuiltInCategory.OST_Windows));
ElementId someId = new ElementId(BuiltInCategory.OST_Windows);
BuiltInParameter bip = (BuiltInParameter)(someId.IntegerValue);
doc.Regenerate();
// Add fields to the schedule
AddRegularFieldToSchedule(vs, new ElementId(BuiltInParameter.CASEWORK_WIDTH));
AddRegularFieldToSchedule(vs, new ElementId(BuiltInParameter.CASEWORK_HEIGHT));
AddRegularFieldToSchedule(vs, new ElementId(bip));
t.Commit();
}
}
public static void AddRegularFieldToSchedule(ViewSchedule schedule, ElementId paramId)
{
ScheduleDefinition definition = schedule.Definition;
// Find a matching SchedulableField
SchedulableField schedulableField =
definition.GetSchedulableFields().FirstOrDefault(sf => sf.ParameterId == paramId);
if (schedulableField != null)
{
// Add the found field
definition.AddField(schedulableField);
}
}
}
}
</code></pre>
| [
{
"answer_id": 74345574,
"author": "ncpa0cpl",
"author_id": 8907391,
"author_profile": "https://Stackoverflow.com/users/8907391",
"pm_score": 0,
"selected": false,
"text": "setVotes"
},
{
"answer_id": 74345636,
"author": "Raphael Escrig",
"author_id": 9163798,
"author_profile": "https://Stackoverflow.com/users/9163798",
"pm_score": 1,
"selected": false,
"text": "import { useState, useEffect } from \"react\";\nimport \"./styles.css\";\n\n/** NANOID */\nimport { nanoid } from \"nanoid\";\n\nexport default function App() {\n const [anecdotes, setAnecdotes] = useState([]);\n const [selected, setSelected] = useState(null);\n\n useEffect(() => {\n /** HERE YOU SHOULD DO AN API CALL.\n * THE RETURN SHOULD BE EQUAL TO FORMATTED VARIABLE\n */\n const data = [\n \"If it hurts, do it more often.\",\n \"Adding manpower to a late software project makes it later!\",\n \"The first 90 percent of the code accounts for the first 10 percent of the development time...The remaining 10 percent of the code accounts for the other 90 percent of the development time.\",\n \"Any fool can write code that a computer can understand. Good programmers write code that humans can understand.\",\n \"Premature optimization is the root of all evil.\",\n \"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.\",\n \"Programming without an extremely heavy use of console.log is same as if a doctor would refuse to use x-rays or blood tests when diagnosing patients.\"\n ];\n const points = [0, 1, 2, 3, 4, 5, 6];\n const formatted = data.map((anecdote, index) => ({\n id: nanoid(),\n sentence: anecdote,\n points: points[index] ?? 0\n }));\n\n setAnecdotes(formatted);\n\n formatted.length > 0 && setSelected(formatted[0]);\n }, []);\n\n const handleVote = () => {\n if (selected === null) return;\n\n /** CREATE A NEW COPY */\n const tmp = JSON.parse(JSON.stringify(anecdotes));\n const index = anecdotes.findIndex(\n (anecdote) => anecdote.id === selected.id\n );\n\n if (index === -1) return;\n\n tmp[index].points += 1;\n\n setSelected((current) => ({ ...selected, points: current.points + 1 }));\n setAnecdotes(tmp);\n };\n\n const handleNext = () => {\n const index = anecdotes.findIndex(\n (anecdote) => anecdote.id === selected.id\n );\n\n if (index === anecdotes.length - 1) {\n setSelected(anecdotes.at(0));\n } else {\n setSelected(anecdotes.at(index + 1));\n }\n\n };\n\n if (selected === null) {\n return <p>Loading</p>;\n }\n\n return (\n <div>\n <div>{selected.sentence}</div>\n <br />\n This anecdote has {selected.points} votes\n <br />\n <button onClick={handleVote}>Vote</button>\n <button onClick={handleNext}> Next Anecdote</button>\n </div>\n );\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439266/"
] |
74,345,328 | <p>We are seeing the NPE in the LinuxNetworkParams.getDomainName call in oshi version 6.1.6. Although I am not able to see any reason for this. Can anyone help me when with the reasons why this can throw NPE?</p>
<pre><code>Caused by: java.lang.NullPointerException
at oshi.software.os.linux.LinuxNetworkParams.getDomainName(LinuxNetworkParams.java:80) ~[oshi-core-6.1.6.jar!/:6.1.6]
at com.airwatch.common.diagnostics.DiagnosticCollector.fetchSystemConfiguration(DiagnosticCollector.java:148) ~[diagnostic-library-2.0.3.jar!/:?]
</code></pre>
<p>Here is the code for the method :
<a href="https://github.com/oshi/oshi/blob/oshi-parent-6.1.6/oshi-core/src/main/java/oshi/software/os/linux/LinuxNetworkParams.java#L79-L80" rel="nofollow noreferrer">https://github.com/oshi/oshi/blob/oshi-parent-6.1.6/oshi-core/src/main/java/oshi/software/os/linux/LinuxNetworkParams.java#L79-L80</a></p>
| [
{
"answer_id": 74345574,
"author": "ncpa0cpl",
"author_id": 8907391,
"author_profile": "https://Stackoverflow.com/users/8907391",
"pm_score": 0,
"selected": false,
"text": "setVotes"
},
{
"answer_id": 74345636,
"author": "Raphael Escrig",
"author_id": 9163798,
"author_profile": "https://Stackoverflow.com/users/9163798",
"pm_score": 1,
"selected": false,
"text": "import { useState, useEffect } from \"react\";\nimport \"./styles.css\";\n\n/** NANOID */\nimport { nanoid } from \"nanoid\";\n\nexport default function App() {\n const [anecdotes, setAnecdotes] = useState([]);\n const [selected, setSelected] = useState(null);\n\n useEffect(() => {\n /** HERE YOU SHOULD DO AN API CALL.\n * THE RETURN SHOULD BE EQUAL TO FORMATTED VARIABLE\n */\n const data = [\n \"If it hurts, do it more often.\",\n \"Adding manpower to a late software project makes it later!\",\n \"The first 90 percent of the code accounts for the first 10 percent of the development time...The remaining 10 percent of the code accounts for the other 90 percent of the development time.\",\n \"Any fool can write code that a computer can understand. Good programmers write code that humans can understand.\",\n \"Premature optimization is the root of all evil.\",\n \"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.\",\n \"Programming without an extremely heavy use of console.log is same as if a doctor would refuse to use x-rays or blood tests when diagnosing patients.\"\n ];\n const points = [0, 1, 2, 3, 4, 5, 6];\n const formatted = data.map((anecdote, index) => ({\n id: nanoid(),\n sentence: anecdote,\n points: points[index] ?? 0\n }));\n\n setAnecdotes(formatted);\n\n formatted.length > 0 && setSelected(formatted[0]);\n }, []);\n\n const handleVote = () => {\n if (selected === null) return;\n\n /** CREATE A NEW COPY */\n const tmp = JSON.parse(JSON.stringify(anecdotes));\n const index = anecdotes.findIndex(\n (anecdote) => anecdote.id === selected.id\n );\n\n if (index === -1) return;\n\n tmp[index].points += 1;\n\n setSelected((current) => ({ ...selected, points: current.points + 1 }));\n setAnecdotes(tmp);\n };\n\n const handleNext = () => {\n const index = anecdotes.findIndex(\n (anecdote) => anecdote.id === selected.id\n );\n\n if (index === anecdotes.length - 1) {\n setSelected(anecdotes.at(0));\n } else {\n setSelected(anecdotes.at(index + 1));\n }\n\n };\n\n if (selected === null) {\n return <p>Loading</p>;\n }\n\n return (\n <div>\n <div>{selected.sentence}</div>\n <br />\n This anecdote has {selected.points} votes\n <br />\n <button onClick={handleVote}>Vote</button>\n <button onClick={handleNext}> Next Anecdote</button>\n </div>\n );\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6552317/"
] |
74,345,359 | <p>What is current Toolversion for MS Build ToolVerions for VS2022 and what would be Framework version for .NetFramework. what is the version i can see in CsProj in project</p>
<p>Visual Studio 2022 ToolVersion in Csproj for .NetFrameWork</p>
| [
{
"answer_id": 74345574,
"author": "ncpa0cpl",
"author_id": 8907391,
"author_profile": "https://Stackoverflow.com/users/8907391",
"pm_score": 0,
"selected": false,
"text": "setVotes"
},
{
"answer_id": 74345636,
"author": "Raphael Escrig",
"author_id": 9163798,
"author_profile": "https://Stackoverflow.com/users/9163798",
"pm_score": 1,
"selected": false,
"text": "import { useState, useEffect } from \"react\";\nimport \"./styles.css\";\n\n/** NANOID */\nimport { nanoid } from \"nanoid\";\n\nexport default function App() {\n const [anecdotes, setAnecdotes] = useState([]);\n const [selected, setSelected] = useState(null);\n\n useEffect(() => {\n /** HERE YOU SHOULD DO AN API CALL.\n * THE RETURN SHOULD BE EQUAL TO FORMATTED VARIABLE\n */\n const data = [\n \"If it hurts, do it more often.\",\n \"Adding manpower to a late software project makes it later!\",\n \"The first 90 percent of the code accounts for the first 10 percent of the development time...The remaining 10 percent of the code accounts for the other 90 percent of the development time.\",\n \"Any fool can write code that a computer can understand. Good programmers write code that humans can understand.\",\n \"Premature optimization is the root of all evil.\",\n \"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.\",\n \"Programming without an extremely heavy use of console.log is same as if a doctor would refuse to use x-rays or blood tests when diagnosing patients.\"\n ];\n const points = [0, 1, 2, 3, 4, 5, 6];\n const formatted = data.map((anecdote, index) => ({\n id: nanoid(),\n sentence: anecdote,\n points: points[index] ?? 0\n }));\n\n setAnecdotes(formatted);\n\n formatted.length > 0 && setSelected(formatted[0]);\n }, []);\n\n const handleVote = () => {\n if (selected === null) return;\n\n /** CREATE A NEW COPY */\n const tmp = JSON.parse(JSON.stringify(anecdotes));\n const index = anecdotes.findIndex(\n (anecdote) => anecdote.id === selected.id\n );\n\n if (index === -1) return;\n\n tmp[index].points += 1;\n\n setSelected((current) => ({ ...selected, points: current.points + 1 }));\n setAnecdotes(tmp);\n };\n\n const handleNext = () => {\n const index = anecdotes.findIndex(\n (anecdote) => anecdote.id === selected.id\n );\n\n if (index === anecdotes.length - 1) {\n setSelected(anecdotes.at(0));\n } else {\n setSelected(anecdotes.at(index + 1));\n }\n\n };\n\n if (selected === null) {\n return <p>Loading</p>;\n }\n\n return (\n <div>\n <div>{selected.sentence}</div>\n <br />\n This anecdote has {selected.points} votes\n <br />\n <button onClick={handleVote}>Vote</button>\n <button onClick={handleNext}> Next Anecdote</button>\n </div>\n );\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15914005/"
] |
74,345,371 | <p>I start to use the R package <a href="https://klmr.me/box/index.html" rel="nofollow noreferrer">box</a>, but struggle during development of nested dependencies.</p>
<h2>Setup</h2>
<p>Usually I develop a first function <code>helper.R</code>:</p>
<pre><code># helper.R
helper <- function(i) {
return(paste("help", i))
}
</code></pre>
<p>Then a I use it in a wrapper:</p>
<pre><code># wrapper.R
box::use(./helper[helper])
lapply(1:3, helper)
</code></pre>
<p>Returning:</p>
<pre><code>r$> lapply(1:3, helper)
[[1]]
[1] "help 1"
[[2]]
[1] "help 2"
[[3]]
[1] "help 3"
</code></pre>
<p>So far so good :-)</p>
<h2>Problem</h2>
<p>Do not restart the R-session! Now, I change my helper:</p>
<pre><code># helper.R
helper <- function(i) {
return(paste("Please help", i))
}
</code></pre>
<p>I would like to do <code>box::reload(./helper[helper])</code> or <code>box::reload("helper")</code> to use the update helper function, but I get this Error:</p>
<pre><code>"reload" expects a module object, got "helper", which is not a module alias variable
</code></pre>
<p>I was expecting that <code>box::name()</code> would return this "module alias variable", but it does not :-( It returns <code>"helper"</code> which does not work with <code>box::reload()</code>.</p>
<p>I am clearly missing some terminology AND/OR syntax here? Can you please clarify how I can reload a local module without restarting the R session?</p>
<p>Thanks!</p>
| [
{
"answer_id": 74358076,
"author": "Daniel M Bader",
"author_id": 19135561,
"author_profile": "https://Stackoverflow.com/users/19135561",
"pm_score": 0,
"selected": false,
"text": "box::use()"
},
{
"answer_id": 74360058,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": true,
"text": "box::reload"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19135561/"
] |
74,345,442 | <p><strong>This is my code</strong></p>
<pre><code>from tkinter import *
import random
import time
def create_circles():
for i in range(10):
x0 = random.randint(50, 550)
y0 = random.randint(50, 550)
i=40
colors = ["red", "blue", "purple", "green", "violet", "black"]
for o in range(5):
canvas.delete('circle')
x0 = x0 + 10
y0 = y0 + 10
x1 = x0 + i
y1 = y0 + i
canvas.create_oval(x0, y0, x1, y1, fill=random.choice(colors), tag="circle")
canvas.pack()
i=i+8
canvas.update() # Here you need to update the canvas for the new circle to show
time.sleep(0.1) # Here you can put a delay between the appearence of the individual circles
colors = ["red", "blue", "purple", "green", "violet", "black"]
tk = Tk()
tk.title("Random balls")
canvas = Canvas(tk, width = 600, height = 600, bg = "white")
canvas.pack()
master = Canvas(tk, width = 600, height = 600, bg = "white")
master.pack()
b=Button(master, text="Quit", command=canvas.destroy).pack()
tk.after(1000, create_circles)
tk.mainloop()
</code></pre>
<p><strong>And these are the errors i get when i "kil the program while its running"</strong></p>
<pre><code>Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\vitya\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "C:\Users\vitya\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 839, in callit
func(*args)
File "C:\Users\vitya\AppData\Local\Programs\Python\Python310\balls.py", line 15, in create_circles
canvas.delete('circle')
File "C:\Users\vitya\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 2852, in delete
self.tk.call((self._w, 'delete') + args)
_tkinter.TclError: invalid command name ".!canvas"
</code></pre>
<p>I tried it with a break function too and get the same errors, when i "kill" the program by myself, i also get the same result, but when i "kill the program after it finished draw the circles, it doesnt print any errors"
What should i do to not get this error even if i closed the window while the program is running</p>
| [
{
"answer_id": 74358076,
"author": "Daniel M Bader",
"author_id": 19135561,
"author_profile": "https://Stackoverflow.com/users/19135561",
"pm_score": 0,
"selected": false,
"text": "box::use()"
},
{
"answer_id": 74360058,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": true,
"text": "box::reload"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20438474/"
] |
74,345,451 | <p>I am having some issues with the textfield not moving up with the view.</p>
<p>I am using a textfield with Vertical axis (iOS 16) to create the multiline. This works correctly and stays above the keyboard as expected when it is not embedded in a scrollview. But as soon as the textfield is embedded in the scrollview the multiline just goes below the keyboard and you have to manually scroll to see the last line.</p>
<p>Please see code below. This should work correctly. But if you remove the scrollview you will notice the issue when typing.</p>
<pre><code>struct ContentView: View {
@State private var text = "Lorem ipsum dolor sit amet. Nam voluptatem necessitatibus aut quis odio rem error repudiandae id aliquam perferendis et quidem quaerat et enim harum! Cum nesciunt animi rem quia vero aut omnis eligendi in ducimus eaque sit mollitia fugit est animi nesciunt. Ut exercitationem nulla qui dolor nihil ad autem vero quo internos sapiente eum dicta nihil qui exercitationem cumque et consectetur dolore. Et fugiat officiis non harum voluptas et modi repellendus ut repellat dolorem 33 eveniet quidem qui galisum veritatis. Id consequatur tenetur et eaque voluptas in assumenda delectus et fuga praesentium rem provident delectus est necessitatibus sunt quo dignissimos dolorum. Et reiciendis error et rerum eligendi qui illum error? In soluta ipsum est molestiae pariatur hic voluptas animi qui cupiditate amet."
var body: some View {
ScrollView {
VStack() {
TextField("Enter something", text: $text, axis: .vertical)
.textFieldStyle(RoundedBorderTextFieldStyle())
}
}
}
}
</code></pre>
<p>If there are any GitHub repos you know that would also be great.</p>
<p><strong>Update:</strong>
I have found a solution and will be posting it in the coming days.</p>
| [
{
"answer_id": 74393272,
"author": "Allan Garcia",
"author_id": 1636456,
"author_profile": "https://Stackoverflow.com/users/1636456",
"pm_score": 1,
"selected": false,
"text": "import SwiftUI\n\nstruct ContentView: View {\n \n @State private var text = \"Lorem ipsum dolor sit amet. Nam voluptatem necessitatibus aut quis odio rem error repudiandae id aliquam perferendis et quidem quaerat et enim harum! Cum nesciunt animi rem quia vero aut omnis eligendi in ducimus eaque sit mollitia fugit est animi nesciunt. Ut exercitationem nulla qui dolor nihil ad autem vero quo internos sapiente eum dicta nihil qui exercitationem cumque et consectetur dolore. Et fugiat officiis non harum voluptas et modi repellendus ut repellat dolorem 33 eveniet quidem qui galisum veritatis. Id consequatur tenetur et eaque voluptas in assumenda delectus et fuga praesentium rem provident delectus est necessitatibus sunt quo dignissimos dolorum. Et reiciendis error et rerum eligendi qui illum error? In soluta ipsum est molestiae pariatur hic voluptas animi qui cupiditate amet.\"\n \n @Namespace var bottomText\n \n var body: some View {\n ScrollViewReader { proxy in\n ScrollView {\n Text(\"Title\")\n .font(.largeTitle)\n TextField(\"Enter something\", text: $text, axis: .vertical)\n .textFieldStyle(RoundedBorderTextFieldStyle())\n .onChange(of: text) { newValue in\n print(\"Fired.\")\n withAnimation {\n proxy.scrollTo(bottomText, anchor: .center)\n }\n }\n Color.red.frame(height: 50).id(bottomText)\n }\n \n }\n }\n}\n"
},
{
"answer_id": 74509051,
"author": "Will",
"author_id": 5171317,
"author_profile": "https://Stackoverflow.com/users/5171317",
"pm_score": 0,
"selected": false,
"text": "VStack {\n // ... other code\n\n .onSubmit {\n // update state here !!\n if (i + 1) < inputsValues.count {\n focusedInput = i + 1\n } else {\n focusedInput = nil\n }\n }\n}\n.onChange(of: focusedInput) {\n // When TextField axis is .vertical, anchor must be .top\n proxy.scrollTo($0, anchor: .top)\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11388224/"
] |
74,345,464 | <p>I don't have any errors, nor on client or server. To give you more context I'm creating a login form, I'm trying to prevent the user from authenticate himself if the text he typed on the input fields are corrects. If it's not correct, the user should not be redirected to the route (which has the name "authenticate").
there are 3 routes: login and home which are pages, and authenticate that's redirecting to a controller which got all the functions related to the login.</p>
<p>AuthController</p>
<pre><code> <?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AuthController extends Controller
{
public function login() {
return view('auth.login');
}
public function authenticate(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required'
]);
}
}
</code></pre>
<p>Login view</p>
<pre><code> <form action="{{ route('authenticate') }}" method="post">
@csrf
<input type="email" name="email">
<input type="password" name="password">
<button class="submit">Log</button>
</form>
</code></pre>
<p>All the routes</p>
<pre><code> Route::get('home', HomeController::class)
->name('home');
Route::get('login', [AuthController::class, 'login'])
->name('login');
Route::get('authenticate', [AuthController::class, 'authenticate'])
->name('authenticate');
</code></pre>
<p>So basically what I'm trying to do is to check if the text the user has typed into the email field is an email, and if all the fields have text in it, because everything is required. But it seems like it's not the case, even if the fields are empty the log in button redirects to the authenticate page. Did I do something wrong? If I didn't provide enough information I would be glad to provide more, thanks for reading :) have a nice day</p>
| [
{
"answer_id": 74393272,
"author": "Allan Garcia",
"author_id": 1636456,
"author_profile": "https://Stackoverflow.com/users/1636456",
"pm_score": 1,
"selected": false,
"text": "import SwiftUI\n\nstruct ContentView: View {\n \n @State private var text = \"Lorem ipsum dolor sit amet. Nam voluptatem necessitatibus aut quis odio rem error repudiandae id aliquam perferendis et quidem quaerat et enim harum! Cum nesciunt animi rem quia vero aut omnis eligendi in ducimus eaque sit mollitia fugit est animi nesciunt. Ut exercitationem nulla qui dolor nihil ad autem vero quo internos sapiente eum dicta nihil qui exercitationem cumque et consectetur dolore. Et fugiat officiis non harum voluptas et modi repellendus ut repellat dolorem 33 eveniet quidem qui galisum veritatis. Id consequatur tenetur et eaque voluptas in assumenda delectus et fuga praesentium rem provident delectus est necessitatibus sunt quo dignissimos dolorum. Et reiciendis error et rerum eligendi qui illum error? In soluta ipsum est molestiae pariatur hic voluptas animi qui cupiditate amet.\"\n \n @Namespace var bottomText\n \n var body: some View {\n ScrollViewReader { proxy in\n ScrollView {\n Text(\"Title\")\n .font(.largeTitle)\n TextField(\"Enter something\", text: $text, axis: .vertical)\n .textFieldStyle(RoundedBorderTextFieldStyle())\n .onChange(of: text) { newValue in\n print(\"Fired.\")\n withAnimation {\n proxy.scrollTo(bottomText, anchor: .center)\n }\n }\n Color.red.frame(height: 50).id(bottomText)\n }\n \n }\n }\n}\n"
},
{
"answer_id": 74509051,
"author": "Will",
"author_id": 5171317,
"author_profile": "https://Stackoverflow.com/users/5171317",
"pm_score": 0,
"selected": false,
"text": "VStack {\n // ... other code\n\n .onSubmit {\n // update state here !!\n if (i + 1) < inputsValues.count {\n focusedInput = i + 1\n } else {\n focusedInput = nil\n }\n }\n}\n.onChange(of: focusedInput) {\n // When TextField axis is .vertical, anchor must be .top\n proxy.scrollTo($0, anchor: .top)\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19233399/"
] |
74,345,465 | <p>I want to do a date comparison to check whether is the Before Period is bigger than After Periode
So far it has been working properly until the date range is a bit tricky</p>
<p>For example
The value is from a dropdownlist item
Before period is 21-10-2022
After period is 04-11-2022</p>
<p>It will trigger the error message I set if the before period is bigger than the period after</p>
<p>I have a code like this</p>
<pre class="lang-vb prettyprint-override"><code>If CDate(ddlPeriodeBefore.SelectedValue) <= CDate(ddlPeriodeBefore.SelectedValue) Then
'Does the job if the the before period is smaller than after period
Else
lblInfo.Text = "Period BEFORE Must Be SMALLER Than Period AFTER."
End If
</code></pre>
<p>Can anyone help me? it keeps saying <strong>"conversion from string to date is not valid"</strong></p>
<p>I've tried datetime.parse, parse exact, cdate, convert.todatetime but nothing works so far, or maybe I used it the wrong way</p>
<p>Please help, thanks in advance</p>
| [
{
"answer_id": 74345637,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 1,
"selected": true,
"text": "DateTime.Parse"
},
{
"answer_id": 74348224,
"author": "David",
"author_id": 1920035,
"author_profile": "https://Stackoverflow.com/users/1920035",
"pm_score": 1,
"selected": false,
"text": "Dim dates As New List(Of Tuple(Of String, DateTime))()\nDim today = DateTime.Today\nFor daysSubtract = 90 To 0 Step -1\n Dim dateToAdd = today.AddDays(-daysSubtract)\n dates.Add(New Tuple(Of String, DateTime)(dateToAdd.ToString(\"dd-MM-yyyy\"), dateToAdd))\nNext\n\nddlPeriodeBefore.ValueMember = \"Item1\"\nddlPeriodeBefore.DisplayMember = \"Item2\"\nddlPeriodeBefore.DataSource = dates\n\nddlPeriodeAfter.ValueMember = \"Item1\"\nddlPeriodeAfter.DisplayMember = \"Item2\"\nddlPeriodeAfter.DataSource = dates\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11188485/"
] |
74,345,509 | <h3>Description</h3>
<p>I have list of bigquery tables to be created using terraform but I need only the partition for specific tables.</p>
<p>Here is the ex.</p>
<pre><code>locals {
path = "../../../../../../../../db"
gcp_bq_tables = [
"my_table1",
"my_table1_daily",
"my_table2",
"my_table2_daily"
]
}
</code></pre>
<p>And, the terraform script to create the tables:</p>
<pre><code>resource "google_bigquery_table" "gcp_bq_tables" {
for_each = toset(local.gcp_bq_tables)
dataset_id = google_bigquery_dataset.gcp_bq_db.dataset_id
table_id = each.value
schema = file("${local.path}/schema/${each.value}.json")
labels = {
env = var.env
app = var.app
}
}
</code></pre>
<p>In that I need to create partition on timestamp, type as DAY but the columns are different.
Lets say for my_table1,</p>
<ol>
<li>The partition column would be my_ts_column_table1 for table1</li>
<li>The partition column would be my_last_modified_column_table2 for table2</li>
</ol>
<p>How to write the terraform script in this scenario.</p>
<h3>My exploration</h3>
<p>I find a way to do it in <a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_table#nested_time_partitioning" rel="nofollow noreferrer">terraform_documentation</a> but not sure for multiple tables and how can be specified the partition columns for both tables.</p>
| [
{
"answer_id": 74345637,
"author": "Tim Schmelter",
"author_id": 284240,
"author_profile": "https://Stackoverflow.com/users/284240",
"pm_score": 1,
"selected": true,
"text": "DateTime.Parse"
},
{
"answer_id": 74348224,
"author": "David",
"author_id": 1920035,
"author_profile": "https://Stackoverflow.com/users/1920035",
"pm_score": 1,
"selected": false,
"text": "Dim dates As New List(Of Tuple(Of String, DateTime))()\nDim today = DateTime.Today\nFor daysSubtract = 90 To 0 Step -1\n Dim dateToAdd = today.AddDays(-daysSubtract)\n dates.Add(New Tuple(Of String, DateTime)(dateToAdd.ToString(\"dd-MM-yyyy\"), dateToAdd))\nNext\n\nddlPeriodeBefore.ValueMember = \"Item1\"\nddlPeriodeBefore.DisplayMember = \"Item2\"\nddlPeriodeBefore.DataSource = dates\n\nddlPeriodeAfter.ValueMember = \"Item1\"\nddlPeriodeAfter.DisplayMember = \"Item2\"\nddlPeriodeAfter.DataSource = dates\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17759607/"
] |
74,345,575 | <p>I have two dataframes</p>
<p>df1</p>
<pre><code> Date RPM
0 0 0
1 1 0
2 2 0
3 3 0
4 4 0
5 5 0
6 6 0
7 7 0
</code></pre>
<p>and df2</p>
<pre><code> Date RPM
0 0 0
1 2 2
2 4 4
3 6 6
</code></pre>
<p>I want to replace the RPM in df1 with the RPM in df2 where they have the same Date</p>
<p>I tried with replace but it didn't work out</p>
| [
{
"answer_id": 74345597,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "Series.map"
},
{
"answer_id": 74345631,
"author": "Emi OB",
"author_id": 14463396,
"author_profile": "https://Stackoverflow.com/users/14463396",
"pm_score": 0,
"selected": false,
"text": "merge()"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439426/"
] |
74,345,579 | <p>I currently receive the following JSON body</p>
<pre class="lang-json prettyprint-override"><code>{
"productId": "90000011",
"offerId": "String",
"format": "String",
"sellerId": "String",
"sellerName": "String",
"shippingPrice[zone=BE,method=STD]": 0.0,
"deliveryTimeEarliestDays[zone=BE,method=STD]": 1,
"deliveryTimeLatestDays[zone=BE,method=STD]": 1,
"shippingPrice[zone=NL,method=STD]": 0.0,
"deliveryTimeEarliestDays[zone=NL,method=STD]": 1,
"deliveryTimeLatestDays[zone=NL,method=STD]": 1
}
</code></pre>
<p>As you can see, I have similar properties that differ by <code>zone</code> and <code>method</code> enclosed in square brackets. I don't want to change the code every time a new <code>zone</code> and/or <code>method</code> is introduced. I'm looking for a more dynamic way you deserialize this via Jackson.</p>
<p>Is there a way to automatically deserialize all properties starting with <code>shippingPrice</code>, <code>deliveryTimeEarliestDays</code> and <code>deliveryTimeLatestDays</code> into the following format?</p>
<pre class="lang-json prettyprint-override"><code>{
"productId": "90000011",
"offerId": "String",
"format": "String",
"sellerId": "String",
"sellerName": "String",
"deliveryModes":[
{
"method":"STD"
"zone":"BE",
"shippingPrice":0.0,
"deliveryTimeEarliestDays":1,
"deliveryTimeLatestDays":1
},{
"method":"STD"
"zone":"NL",
"shippingPrice":0.0,
"deliveryTimeEarliestDays":1,
"deliveryTimeLatestDays":1
}]
}
</code></pre>
<p>My first idea was to use the <code>@JsonAnySetter</code> annotation and put everything in a <code>Map</code> but that still leaves me with manual parsing of the field name.</p>
<p>My Second Idea was to <a href="https://www.baeldung.com/jackson-deserialization" rel="nofollow noreferrer">build a custom deserializer</a> where I loop over all attributes and filter out all the ones that start with <code>shippingPrice</code>, <code>deliveryTimeEarliestDays</code> and <code>deliveryTimeLatestDays</code> and map them to the described format above.</p>
| [
{
"answer_id": 74345988,
"author": "Michael Gantman",
"author_id": 5802417,
"author_profile": "https://Stackoverflow.com/users/5802417",
"pm_score": 0,
"selected": false,
"text": "JsonUtils"
},
{
"answer_id": 74348310,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
"author_profile": "https://Stackoverflow.com/users/17949945",
"pm_score": 3,
"selected": true,
"text": "@Getter\n@Setter\npublic static class MyPojo {\n private String productId;\n private String offerId;\n private String format;\n private String sellerId;\n private String sellerName;\n @JsonIgnore // we don't want to expose this field to Jackson as is\n private Map<DeliveryZoneMethod, DeliveryMode> deliveryModes = new HashMap<>();\n \n @JsonAnySetter\n public void setDeliveryModes(String property, String value) {\n DeliveryZoneMethod zoneMethod = DeliveryZoneMethod.parse(property);\n DeliveryMode mode = deliveryModes.computeIfAbsent(zoneMethod, DeliveryMode::new);\n \n String name = property.substring(0, property.indexOf('['));\n\n switch (name) {\n case \"shippingPrice\" -> mode.setShippingPrice(new BigDecimal(value));\n case \"deliveryTimeEarliestDays\" -> mode.setDeliveryTimeEarliestDays(Integer.parseInt(value));\n case \"deliveryTimeLatestDays\" -> mode.setDeliveryTimeLatestDays(Integer.parseInt(value));\n }\n }\n \n public Collection<DeliveryMode> getModes() {\n return deliveryModes.values();\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4614788/"
] |
74,345,596 | <p>I'm having hard time understanding OIDC that I'm asking here.</p>
<hr />
<h2><strong>[Current Understanding]</strong></h2>
<p><strong>ID Token (Based on JWT)</strong></p>
<p>[REQUIRED]</p>
<ul>
<li>iss (Issuer) : OPurl</li>
<li>sub (Subject Identifier) : unique identifier</li>
<li>aud (Audience) : Unique Client ID which OP provides beforehand</li>
<li>exp (Expires at) : When token expires</li>
<li>iat (Issued at) : When token is issued</li>
</ul>
<p>[OPTIONAL]</p>
<ul>
<li>nonce : string value used to associate a client session with ID token (REQ for Implicit Flow)</li>
<li>preferred_username : Shorthand name by which the End-User wishes to be referred to at the RP (The RP MUST NOT rely upon this value being unique)</li>
</ul>
<blockquote>
<p><strong>Sample Token</strong></p>
<ul>
<li><p>{"access_token":"SlAV32hkKG","token_type":"bearer","expires_in":3600,"id_token":"eyJ0...","refresh_token":"8xLOxBtZp8"}</p>
</li>
<li><p>Authorization Code Flow (/authorize GET => /token POST) : contains refresh_token and is in JSON form</p>
</li>
<li><p>Implicit Flow (/authorize GET) : does not contain refresh_token and is responsed in fragment mode</p>
</li>
</ul>
</blockquote>
<blockquote>
<p><strong>Sample ID Token</strong></p>
<ul>
<li>Header (Base64 Decoded) : {"typ":"JWT","alg":"RS256","kid":"sdfikhRETlknsdfollksdf324lhk"}</li>
<li>Payload (Base64 Decoded) : {"iss":"OPurl","aud":"ClientID","sub":"1234567890","exp":"1665666710","iat":"1665666790"}</li>
<li>Signature : ggW8hZ...zqg</li>
</ul>
</blockquote>
<hr />
<h2><strong>[Question]</strong></h2>
<p>In <a href="https://openid.net/specs/openid-connect-core-1_0.html" rel="nofollow noreferrer">OIDC Core Spec</a>, sub(subject identifier) is a "locally unique and never reassigned identifier within the Issuer for the End-User, which is intended to be consumed by the Client".</p>
<p>In <a href="https://datatracker.ietf.org/doc/html/rfc7519" rel="nofollow noreferrer">JWT Spec</a>, it can either be locally unique in the context of the issuer or be globally unique.</p>
<p><strong>Here I have a globally unique User ID.</strong> (Let's say 1234567890)</p>
<p>User uses this ID for client A, B, C... everywhere.</p>
<p>No others can use this ID.</p>
<p><strong>Can sub be that ID itself?</strong> ("sub":"1234567890")</p>
<p><strong>Or Should sub be like a mix of a random string with the id and preferred_username should be the ID itself?</strong> (Keycloak for example, returns the token like {"sub":"f:636436-348762gyu-234786234:1234567890", "preferred_username":1234567890})</p>
<p>I'm not really sure what it means to be "never reassigned identifier within the Issuer for the End-User"...</p>
<hr />
<p>Any help would be appreciated.</p>
<p>Please let me know if my current understanding is wrong!</p>
| [
{
"answer_id": 74345988,
"author": "Michael Gantman",
"author_id": 5802417,
"author_profile": "https://Stackoverflow.com/users/5802417",
"pm_score": 0,
"selected": false,
"text": "JsonUtils"
},
{
"answer_id": 74348310,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
"author_profile": "https://Stackoverflow.com/users/17949945",
"pm_score": 3,
"selected": true,
"text": "@Getter\n@Setter\npublic static class MyPojo {\n private String productId;\n private String offerId;\n private String format;\n private String sellerId;\n private String sellerName;\n @JsonIgnore // we don't want to expose this field to Jackson as is\n private Map<DeliveryZoneMethod, DeliveryMode> deliveryModes = new HashMap<>();\n \n @JsonAnySetter\n public void setDeliveryModes(String property, String value) {\n DeliveryZoneMethod zoneMethod = DeliveryZoneMethod.parse(property);\n DeliveryMode mode = deliveryModes.computeIfAbsent(zoneMethod, DeliveryMode::new);\n \n String name = property.substring(0, property.indexOf('['));\n\n switch (name) {\n case \"shippingPrice\" -> mode.setShippingPrice(new BigDecimal(value));\n case \"deliveryTimeEarliestDays\" -> mode.setDeliveryTimeEarliestDays(Integer.parseInt(value));\n case \"deliveryTimeLatestDays\" -> mode.setDeliveryTimeLatestDays(Integer.parseInt(value));\n }\n }\n \n public Collection<DeliveryMode> getModes() {\n return deliveryModes.values();\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12198033/"
] |
74,345,614 | <p>How to create merge statment that insert into table from onther select statment</p>
<p>my example is :</p>
<pre><code> MERGE INTO employees t
USING (SELECT :dept_id as dept_id FROM dual ) d
ON (t.dept_id = d.dept_id )
WHEN NOT MATCHED THEN
INSERT INTO employees (
ename,
fname )
SELECT
ename,
fname
FROM
trans_emps
where trans_id = :trans_id;
</code></pre>
| [
{
"answer_id": 74345988,
"author": "Michael Gantman",
"author_id": 5802417,
"author_profile": "https://Stackoverflow.com/users/5802417",
"pm_score": 0,
"selected": false,
"text": "JsonUtils"
},
{
"answer_id": 74348310,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
"author_profile": "https://Stackoverflow.com/users/17949945",
"pm_score": 3,
"selected": true,
"text": "@Getter\n@Setter\npublic static class MyPojo {\n private String productId;\n private String offerId;\n private String format;\n private String sellerId;\n private String sellerName;\n @JsonIgnore // we don't want to expose this field to Jackson as is\n private Map<DeliveryZoneMethod, DeliveryMode> deliveryModes = new HashMap<>();\n \n @JsonAnySetter\n public void setDeliveryModes(String property, String value) {\n DeliveryZoneMethod zoneMethod = DeliveryZoneMethod.parse(property);\n DeliveryMode mode = deliveryModes.computeIfAbsent(zoneMethod, DeliveryMode::new);\n \n String name = property.substring(0, property.indexOf('['));\n\n switch (name) {\n case \"shippingPrice\" -> mode.setShippingPrice(new BigDecimal(value));\n case \"deliveryTimeEarliestDays\" -> mode.setDeliveryTimeEarliestDays(Integer.parseInt(value));\n case \"deliveryTimeLatestDays\" -> mode.setDeliveryTimeLatestDays(Integer.parseInt(value));\n }\n }\n \n public Collection<DeliveryMode> getModes() {\n return deliveryModes.values();\n }\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17370829/"
] |
74,345,616 | <p>is there any solution to apply tint colour as a gradient in swift</p>
<p>my button has a simple white icon I want to change it to a gradient colour</p>
| [
{
"answer_id": 74358149,
"author": "Er.hiren",
"author_id": 15075298,
"author_profile": "https://Stackoverflow.com/users/15075298",
"pm_score": 0,
"selected": false,
"text": "class gradiunTitle : UIButton {\n\n override init(frame: CGRect) {\n super.init(frame: frame)\n setup()\n }\n required init?(coder aDecoder: NSCoder) {\n super.init(coder: aDecoder)\n setup()\n }\n private func setup() {\n let gradient = getGradientLayer(bounds: self.bounds)\n self.setTitleColor(gradientColor(bounds: self.bounds, gradientLayer: gradient), for: .normal)\n self.tintColor = gradientColor(bounds: self.frame, gradientLayer: gradient)\n }\n func getGradientLayer(bounds : CGRect) -> CAGradientLayer{\n let gradient = CAGradientLayer()\n gradient.frame = bounds\n //order of gradient colors\n gradient.colors = [UIColor.red.cgColor,UIColor.blue.cgColor, UIColor.green.cgColor]\n gradient.startPoint = CGPoint(x: 0.0, y: 0.5)\n gradient.endPoint = CGPoint(x: 1.0, y: 0.5)\n return gradient\n }\n \n func gradientColor(bounds: CGRect, gradientLayer :CAGradientLayer) -> UIColor? {\n UIGraphicsBeginImageContext(gradientLayer.bounds.size)\n gradientLayer.render(in: UIGraphicsGetCurrentContext()!)\n let image = UIGraphicsGetImageFromCurrentImageContext()\n UIGraphicsEndImageContext()\n return UIColor(patternImage: image!)\n }\n}\n"
},
{
"answer_id": 74361320,
"author": "Bulat Yakupov",
"author_id": 17834877,
"author_profile": "https://Stackoverflow.com/users/17834877",
"pm_score": 1,
"selected": false,
"text": "extension UIImage {\n \n func drawLinearGradient(colors: [CGColor], startingPoint: CGPoint, endPoint: CGPoint) -> UIImage? {\n let renderer = UIGraphicsImageRenderer(size: self.size)\n \n var shouldReturnNil = false\n let gradientImage = renderer.image { context in\n context.cgContext.translateBy(x: 0, y: self.size.height)\n context.cgContext.scaleBy(x: 1.0, y: -1.0)\n\n context.cgContext.setBlendMode(.normal)\n let rect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height)\n\n // Create gradient\n let colors = colors as CFArray\n let colorsSpace = CGColorSpaceCreateDeviceRGB()\n \n guard let gradient = CGGradient(colorsSpace: colorsSpace, colors: colors, locations: nil) else {\n shouldReturnNil = true\n return\n }\n\n // Apply gradient\n guard let cgImage = self.cgImage else {\n shouldReturnNil = true\n print(\"Couldn't get cgImage of UIImage.\")\n return\n }\n \n context.cgContext.clip(to: rect, mask: cgImage)\n context.cgContext.drawLinearGradient(\n gradient,\n start: endPoint,\n end: startingPoint,\n options: .init(rawValue: 0)\n )\n }\n\n return shouldReturnNil ? nil : gradientImage\n }\n \n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12748393/"
] |
74,345,628 | <p>I am working on a recursive function that looks for the first odd number in a list. It works as expected.</p>
<p>But when there is NO odd number in a list, it returns an error. Id like to control this error with some sort of message that says "no odd values found".</p>
<h2>Single Test Recursion Function</h2>
<pre class="lang-lisp prettyprint-override"><code>(defun find-first-odd (x)
(cond ((oddp (first x)) (first x))
(t (find-first-odd (rest x)))))
</code></pre>
<pre class="lang-lisp prettyprint-override"><code>
(find-first-odd '(2 2 10 3 4 6 4)) ; => 3
</code></pre>
<pre><code>(find-first-odd '(2 2 10 4 6 4)) ;=> value nil is not an integer
(find-first-odd '(2 2 10 4 6 4 . 2)) ;=> 2 is not type list
</code></pre>
| [
{
"answer_id": 74346497,
"author": "ignis volens",
"author_id": 17026934,
"author_profile": "https://Stackoverflow.com/users/17026934",
"pm_score": 3,
"selected": true,
"text": "(defun search-list-for (l ...)\n (cond ((null l)\n ...)\n (<(first l) is what we're after>\n ...)\n (t\n (search-list-for (rest l) ...))))\n"
},
{
"answer_id": 74352716,
"author": "Rainer Joswig",
"author_id": 69545,
"author_profile": "https://Stackoverflow.com/users/69545",
"pm_score": 0,
"selected": false,
"text": "(defun %find-first-odd (list)\n (etypecase list\n ((cons (satisfies oddp) list) (first list))\n ((cons T list) (find-first-odd (rest list)))))\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16237416/"
] |
74,345,657 | <p>is there a way in python to tell the interpretes a bunch of statements should all be executed on the same object/namespace?</p>
<p>In some other languages you have constructs like</p>
<pre><code>using myObject{
.a = 1;
.b = 2;
.c = 3;
}
</code></pre>
<p>as shorthand notation for</p>
<pre><code>myObject.a = 1;
myObject.b = 2;
myObject.c = 3;
</code></pre>
<p>Is there anything similar in python?</p>
<p>Something like</p>
<pre><code>mo = MyObject()
using mo:
.a = 1
.b = 2
.someMethod("whatever")
</code></pre>
<p>or</p>
<pre><code>import testmodule
using testmodule:
.target = MyObject()
result1 = .test1()
result2 = .test2()
</code></pre>
| [
{
"answer_id": 74346497,
"author": "ignis volens",
"author_id": 17026934,
"author_profile": "https://Stackoverflow.com/users/17026934",
"pm_score": 3,
"selected": true,
"text": "(defun search-list-for (l ...)\n (cond ((null l)\n ...)\n (<(first l) is what we're after>\n ...)\n (t\n (search-list-for (rest l) ...))))\n"
},
{
"answer_id": 74352716,
"author": "Rainer Joswig",
"author_id": 69545,
"author_profile": "https://Stackoverflow.com/users/69545",
"pm_score": 0,
"selected": false,
"text": "(defun %find-first-odd (list)\n (etypecase list\n ((cons (satisfies oddp) list) (first list))\n ((cons T list) (find-first-odd (rest list)))))\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11190464/"
] |
74,345,673 | <p>I am trying to write assert command for a Fortran program, but the whole thing is driving me nuts. Allow me to show you what have up to now:</p>
<p>File: Assert.h:</p>
<pre><code>#define Assert(X) call Handle_Assert(.not.(X), #X, __FILE__, __LINE__)
</code></pre>
<p>File: Check_Assert.F90:</p>
<pre><code>#include "Assert.h"
program Check_Assert
use Assert_Mod
Assert(1>2)
end program
</code></pre>
<p>And finally the file: Assert_Mod.F90:</p>
<pre><code>module Assert_Mod
contains
subroutine Handle_Assert(fail, text, file, line)
implicit none
logical :: fail
character(*) :: text
character(*) :: file
integer :: line
if(fail) then
print *, 'Assertion ', text, &
' failed in file ', file, &
' at line ', line, &
'.'
stop
end if
end subroutine
end module
</code></pre>
<p>When I compile it with:</p>
<pre><code>gfortran -c Assert_Mod.F90
gfortran -o check Assert_Mod.o Check_Assert.F90
</code></pre>
<p>I get the following error message:</p>
<pre><code>Check_Assert.F90:6:31:
6 | Assert(1>2);
| 1
Error: Syntax error in argument list at (1)
</code></pre>
<p>If I do exactly the same thing with Intel Fortran, all works fine and program gives expected output:</p>
<pre><code>Assertion 1>2 failed in file Check_Assert.F90 at line 6 .
</code></pre>
<p>
Does anyone have a clue what is going on with GNU Fortran? Why can't it swallow the assert in the way I defined it, and in the way it works for Intel?</p>
<p>Any help or hint would be appreciated.</p>
<p><em>Cheers</em></p>
| [
{
"answer_id": 74345960,
"author": "gnikit",
"author_id": 5648064,
"author_profile": "https://Stackoverflow.com/users/5648064",
"pm_score": 2,
"selected": false,
"text": "#X"
},
{
"answer_id": 74346006,
"author": "Bojan Niceno",
"author_id": 8178020,
"author_profile": "https://Stackoverflow.com/users/8178020",
"pm_score": 2,
"selected": false,
"text": "#if __GFORTRAN__ == 1\n# define Assert(X) call Handle_Assert(.not.(X), \"X\", __FILE__, __LINE__)\n#else\n# define Assert(X) call Handle_Assert(.not.(X), #X, __FILE__, __LINE__)\n#endif\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8178020/"
] |
74,345,727 | <p>I want to have a sas dataset with 1 decimal of some variables, so my code is the following</p>
<pre><code>data a;
set a;
dif=put(t0d,4.1);
drop t0d;
run;
</code></pre>
<p>Although in some cases with the dif variable I don't have this format. For example I have</p>
<pre><code>dif
-1.0
-9
15.0
2
3.0
5.0
15.0
</code></pre>
<p>how can i fix this ?? I want</p>
<pre><code>dif
-1.0
-9.0
15.0
2.0
3.0
5.0
15.0
</code></pre>
<p>Thank you!!</p>
| [
{
"answer_id": 74346772,
"author": "Negdo",
"author_id": 19646183,
"author_profile": "https://Stackoverflow.com/users/19646183",
"pm_score": 0,
"selected": false,
"text": "DATA have;\ninput x $; \ndatalines;\n8722\n-93.2\n-0.1122\n15.116\n5\n1.5\n;\nrun;\n\ndata want;\n set have;\n dif=input(x, 8.);\n drop x;\n format dif 8.1;\nrun;\n"
},
{
"answer_id": 74347743,
"author": "Tom",
"author_id": 4965549,
"author_profile": "https://Stackoverflow.com/users/4965549",
"pm_score": 1,
"selected": false,
"text": "data test;\n input t0d;\n dif = put(t0d,4.1);\ncards;\n-1.0\n-9 \n15.0\n2 \n3.0 \n5.0 \n15.0\n;\nproc print;\nrun;\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20238328/"
] |
74,345,757 | <p>I have a data frame with duplicated rows having one continuous variable column and 2-factor columns (0,1). The goal is to find the duplicated rows and identify them as replicates in a new column.</p>
<p>Here is the structure of the data frame</p>
<pre><code> cont.var fact1 fact2
1 1.0 1 0
2 1.0 0 1
3 1.5 1 0
4 1.5 1 0
5 1.5 0 1
6 1.5 0 1
</code></pre>
<p>Now let's say</p>
<ul>
<li><p>If <code>cont.var</code> has value <strong>1.0</strong> in two rows but has different values for <code>fact1</code> and <code>fact2</code>, so it will be assigned two different replicates.</p>
</li>
<li><p>If <code>cont.var</code> has value <strong>1.5</strong> and <code>fact1</code>/<code>fact2</code> is also the same for successive rows, they will be given the same replicate identifier.</p>
</li>
</ul>
<p><strong>Expected Output</strong></p>
<pre><code> cont.var fact1 fact2 rep
1 1.0 1 0 1
2 1.0 0 1 2
3 1.5 1 0 3
4 1.5 1 0 3
5 1.5 0 1 4
6 1.5 0 1 4
</code></pre>
<p><strong>What I have tried</strong></p>
<pre><code>library(dplyr)
sample.df <- data.frame(
cont.var = c(1,1,1.5,1.5,1.5,1.5,2,2,2,3),
fact1 = c(1,0,1,1,0,0,1,1,0,1),
fact2 = c(0,1,0,0,1,1,0,0,1,0)
)
sample.df %>%
group_by(cont.var, fact1, fact2) %>%
mutate(replicate = make.unique(as.character(cont.var), "_"))
</code></pre>
<p><strong>Incorrect Output</strong></p>
<ul>
<li>I would expect that <code>row-1</code> and <code>row-2</code> will have different replicate counts.</li>
<li>I would expect that Replicate count for <code>row-3</code> == <code>row-4</code> and <code>row-5</code> == <code>row-6</code>, but <code>row-5</code> != <code>row-3</code></li>
</ul>
<pre><code> cont.var fact1 fact2 replicate
1 1.0 1 0 1
2 1.0 0 1 1
3 1.5 1 0 1.5
4 1.5 1 0 1.5_1
5 1.5 0 1 1.5
6 1.5 0 1 1.5_1
</code></pre>
<p>I couldn't find a straightforward solution to this; I would really appreciate any help.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 74345783,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "data.table::rleid"
},
{
"answer_id": 74346118,
"author": "r2evans - GO NAVY BEAT ARMY",
"author_id": 3358272,
"author_profile": "https://Stackoverflow.com/users/3358272",
"pm_score": 1,
"selected": false,
"text": "quux %>%\n group_by(cont.var, fact1, fact2) %>%\n mutate(rep = group_indices()) %>%\n ungroup()\n# # A tibble: 6 x 4\n# cont.var fact1 fact2 rep\n# <dbl> <int> <int> <int>\n# 1 1 1 0 2\n# 2 1 0 1 1\n# 3 1.5 1 0 4\n# 4 1.5 1 0 4\n# 5 1.5 0 1 3\n# 6 1.5 0 1 3\n"
},
{
"answer_id": 74346229,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 1,
"selected": false,
"text": "sample.df <- data.frame(\n cont.var = c(1,1,1.5,1.5,1.5,1.5,2,2,2,3),\n fact1 = c(1,0,1,1,0,0,1,1,0,1),\n fact2 = c(0,1,0,0,1,1,0,0,1,0)\n)\n\n\nsample.df$replicate <- cumsum(!duplicated(sample.df)) \nsample.df\n#> cont.var fact1 fact2 replicate\n#> 1 1.0 1 0 1\n#> 2 1.0 0 1 2\n#> 3 1.5 1 0 3\n#> 4 1.5 1 0 3\n#> 5 1.5 0 1 4\n#> 6 1.5 0 1 4\n#> 7 2.0 1 0 5\n#> 8 2.0 1 0 5\n#> 9 2.0 0 1 6\n#> 10 3.0 1 0 7\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8791858/"
] |
74,345,770 | <p>I am trying to take values from a DB table where It has keys as enabled and values as true, false and empty, I want to take only True values from enabled keys and other keys and rows related to it.</p>
<p>Table</p>
<pre><code> id name enabled dept
1 abd TRUE cs
2 cdew FALSE ds
3 sda sd
4 asd TRUE as
</code></pre>
<p>I want only enabled = true values from table. how can I do it? without help of pandas? I want like</p>
<pre><code> id name enabled dept
1 abd TRUE cs
4 asd TRUE as
</code></pre>
| [
{
"answer_id": 74351849,
"author": "Lee Hannigan",
"author_id": 7909676,
"author_profile": "https://Stackoverflow.com/users/7909676",
"pm_score": 1,
"selected": false,
"text": "enabled"
},
{
"answer_id": 74357676,
"author": "Mia",
"author_id": 11867978,
"author_profile": "https://Stackoverflow.com/users/11867978",
"pm_score": 0,
"selected": false,
"text": "resp= key.get('enabled',None)\nif resp:\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11867978/"
] |
74,345,819 | <p>I have a POST table and a TAG table, I explain the POST table contains following fields : id , title , content , tags_ids which mean that the field tags_ids can contani multiple tags , for example the POST whose ID = 1, has following tags : tag_1, tag_2 tag_5 separated with ;</p>
<p>POST TABLE</p>
<pre><code> id title content tag_id
---------- ---------- ---------- ----------
1 title1 Text... 1; 2; 5
2 title2 Text... 3
3 title3 Text... 1; 2
4 title4 Text... 2; 3; 4
5 title4 Text... 2; 3; 4
6 title2 Text... 3
</code></pre>
<p>the TAG table</p>
<pre><code> id name
---------- ----------
1 tag_1
2 tag_2
3 tag_3
4 tag_4
5 tag_5
</code></pre>
<p>so i would like to know how many posts are registered for each case.</p>
<p>Here is my query</p>
<pre><code>select tag, COUNT(*) AS cnt
from(
select CATEGORY.name,
case
when POST.tag_id is not null then tag.name
end as tag
from POST
left join TAG ON POST.tag_id = TAG.id
)
GROUP BY tag
;
</code></pre>
<p>here is the result i want to display with my query</p>
<pre><code> tag cnt
-------------------- --------------
tag_1, tag_2, tag_5 1
tag_3 2
tag_1, tag_2 1
tag_2, tag_3, tag_4 2
</code></pre>
<p>Best regards</p>
| [
{
"answer_id": 74351849,
"author": "Lee Hannigan",
"author_id": 7909676,
"author_profile": "https://Stackoverflow.com/users/7909676",
"pm_score": 1,
"selected": false,
"text": "enabled"
},
{
"answer_id": 74357676,
"author": "Mia",
"author_id": 11867978,
"author_profile": "https://Stackoverflow.com/users/11867978",
"pm_score": 0,
"selected": false,
"text": "resp= key.get('enabled',None)\nif resp:\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19974817/"
] |
74,345,840 | <p>I am trying to push my data into SQL but it keeps telling me that one of my columns is an invalid data type float.</p>
<pre><code>sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', '[42000] [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 29 (""): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision. (8023) (SQLExecDirectW)')
[SQL: INSERT INTO dbo.[bid_ask_EnergyFwdOutright_101] ([ServiceId], [SchemaVersion], [PricingDate], [PricingTime], [PublicationGroup], [AssetType], [Underlying], [PricingRegion], [Derivative], [ReferenceSource], [ReferenceContractType], [ContractPeriod], [SettlementFrequency], [ContractStartDate], [ContractEndDate], [QuoteConvention], [SubmitterDataType], [Ccy], [CcyScalar], [SubmitterDataUnits], [IsImplied], [SubmitterData], [SubmissionGroupId], [InstrumentId], [SubmitterDataStatus], [RejectionReason], [RejectionDependentOn], [HistoricDataStatus], [HistoricPublicationCount], [HistoricNonComparableStreak], [HistoricNonComparableCount], [HistoricRejectionStreak], [HistoricRejectionCount], [HistoricNonSubmissionCount], [HistoricComparableCount], [PublicationDateTimeUTC], [CountSubmitted], [CountAccepted], [ConsensusData], [RangeData], [StandardDeviationData], [Percentile10Data], [Percentile90Data], [CompositeData]) VALUES (?,.....?)
</code></pre>
<p>I am creating a dictionary to convert the data to object and I have also tried as string. Ideally the data should be a float. My data type in SQL is matching whatever I use in python. I don't know how to correct this.</p>
| [
{
"answer_id": 74351849,
"author": "Lee Hannigan",
"author_id": 7909676,
"author_profile": "https://Stackoverflow.com/users/7909676",
"pm_score": 1,
"selected": false,
"text": "enabled"
},
{
"answer_id": 74357676,
"author": "Mia",
"author_id": 11867978,
"author_profile": "https://Stackoverflow.com/users/11867978",
"pm_score": 0,
"selected": false,
"text": "resp= key.get('enabled',None)\nif resp:\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18245053/"
] |
74,345,850 | <p>In this problem, I'm given an array(list) <code>strarr</code> of strings and an integer k. My task is to return the first longest string consisting of k consecutive strings taken in the array. My code passed all the sample tests from CodeWars but can't seem to pass the random tests.</p>
<p><a href="https://www.codewars.com/kata/56a5d994ac971f1ac500003e" rel="nofollow noreferrer">Here's the link to the problem.</a></p>
<p>I did it in two days. I found the max consecutively combined string first. Here's the code for that.</p>
<pre><code>strarr = []
def longest_consec(strarr, k):
strarr.append('')
length = len(strarr)
cons_list = []
end = k
start = 0
freq = -length/2
final_string = []
largest = max(strarr, key=len, default='')
if k == 1:
return largest
elif 1 < k < length:
while(freq <= 1):
cons_list.append(strarr[start:end])
start += k-1
end += k-1
freq += 1
for index in cons_list:
final_string.append(''.join(index))
return max(final_string, key=len, default='')
else:
return ""
</code></pre>
<p>Since that didn't pass all the random tests, I compared the combined k strings on both sides of the single largest string. But, this way, the code doesn't account for the case when the single largest string is in the middle. Please help.</p>
<pre><code>strarr = []
def longest_consec(strarr, k):
strarr.append('')
length = len(strarr)
largest = max(strarr, key=len, default='')
pos = int(strarr.index(largest))
if k == 1:
return largest
elif 1 < k < length:
prev_string = ''.join(strarr[pos+1-k:pos+1])
next_string = ''.join(strarr[pos:pos+k])
if len(prev_string) >= len(next_string):
res = prev_string
else:
res = next_string
return res
else:
return ""
print(longest_consec(["zone", "abigail", "theta", "form", "libe"], 2))
</code></pre>
| [
{
"answer_id": 74346471,
"author": "bwilk315",
"author_id": 20438342,
"author_profile": "https://Stackoverflow.com/users/20438342",
"pm_score": 1,
"selected": false,
"text": "if k == 1:\n while(p <= 1):\n b.append(strarr[j:i])\n j += 1\n i += 1\n p += 1\n for w in b:\n q.append(''.join(w))\n return max(q, key=len)\n"
},
{
"answer_id": 74356266,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
"author_profile": "https://Stackoverflow.com/users/11622508",
"pm_score": 0,
"selected": false,
"text": "def longest_consec(strarr, k):\n i = 0\n max_ = \"\"\n res = \"\"\n if (k<=0) or (k>len(strarr)):\n return \"\"\n while i<=(len(strarr)-k):\n start = \"\".join(strarr[i:i+k])\n max_ = max(max_, start, key=len)\n if max_==start:\n res=strarr[i:i+k]\n i+=1\n return max_\n\n#output: [\"zone\", \"abigail\", \"theta\", \"form\", \"libe\", \"zas\", \"theta\", \"abigail\"], 2 -> abigailtheta\n#output: [\"zones\", \"abigail\", \"theta\", \"form\", \"libe\", \"zas\", \"theta\", \"abigail\"],2 -> zonesabigail\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16579484/"
] |
74,345,864 | <p><a href="https://i.stack.imgur.com/zOxjt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zOxjt.png" alt="enter image description here" /></a></p>
<p>I need to add buttons and icons like this.</p>
<pre><code>I need to add multiple icons and button in List
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';
class settings_screen extends StatelessWidget {
const settings_screen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Settings'),
elevation: 10,
backgroundColor: const Color(0XFF82B58D),
),
body: ListTile(
leading: const Icon(Icons.notifications),
title: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xff6ae792),
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0),
),
),
onPressed: () {},
child: const Text('Reminders'),
),
),
);
}
}
</code></pre>
<p><a href="https://i.stack.imgur.com/hgvgn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hgvgn.png" alt="enter image description here" /></a></p>
<p>I tryied useing ListTile it is worked on one icon and button, but it can not use multiple times for other icons and buttons. please help to fix it. Thank you...</p>
| [
{
"answer_id": 74346471,
"author": "bwilk315",
"author_id": 20438342,
"author_profile": "https://Stackoverflow.com/users/20438342",
"pm_score": 1,
"selected": false,
"text": "if k == 1:\n while(p <= 1):\n b.append(strarr[j:i])\n j += 1\n i += 1\n p += 1\n for w in b:\n q.append(''.join(w))\n return max(q, key=len)\n"
},
{
"answer_id": 74356266,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
"author_profile": "https://Stackoverflow.com/users/11622508",
"pm_score": 0,
"selected": false,
"text": "def longest_consec(strarr, k):\n i = 0\n max_ = \"\"\n res = \"\"\n if (k<=0) or (k>len(strarr)):\n return \"\"\n while i<=(len(strarr)-k):\n start = \"\".join(strarr[i:i+k])\n max_ = max(max_, start, key=len)\n if max_==start:\n res=strarr[i:i+k]\n i+=1\n return max_\n\n#output: [\"zone\", \"abigail\", \"theta\", \"form\", \"libe\", \"zas\", \"theta\", \"abigail\"], 2 -> abigailtheta\n#output: [\"zones\", \"abigail\", \"theta\", \"form\", \"libe\", \"zas\", \"theta\", \"abigail\"],2 -> zonesabigail\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20407300/"
] |
74,345,871 | <p>I already have a css hover where when hovering over someones name, a card to the side appears with more information about that user.</p>
<p>Is it possible to have another hover on top of the first hover? So another card appears with even more information.</p>
<p>Name (hover on name) > d.o.b, address , etc (hover on their d.o.b for example) > second card appears with further info.</p>
<p>Thanks,</p>
<p>Jack</p>
<p>At the moment I just have the initial as a radio button which brings up the first info card, then I have a hover based off of that to show the second info card.</p>
| [
{
"answer_id": 74346471,
"author": "bwilk315",
"author_id": 20438342,
"author_profile": "https://Stackoverflow.com/users/20438342",
"pm_score": 1,
"selected": false,
"text": "if k == 1:\n while(p <= 1):\n b.append(strarr[j:i])\n j += 1\n i += 1\n p += 1\n for w in b:\n q.append(''.join(w))\n return max(q, key=len)\n"
},
{
"answer_id": 74356266,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
"author_profile": "https://Stackoverflow.com/users/11622508",
"pm_score": 0,
"selected": false,
"text": "def longest_consec(strarr, k):\n i = 0\n max_ = \"\"\n res = \"\"\n if (k<=0) or (k>len(strarr)):\n return \"\"\n while i<=(len(strarr)-k):\n start = \"\".join(strarr[i:i+k])\n max_ = max(max_, start, key=len)\n if max_==start:\n res=strarr[i:i+k]\n i+=1\n return max_\n\n#output: [\"zone\", \"abigail\", \"theta\", \"form\", \"libe\", \"zas\", \"theta\", \"abigail\"], 2 -> abigailtheta\n#output: [\"zones\", \"abigail\", \"theta\", \"form\", \"libe\", \"zas\", \"theta\", \"abigail\"],2 -> zonesabigail\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439616/"
] |
74,345,907 | <p>I have a dataframe with the sentences column and a column with a word present in the sentences.I want to string match the word to the word in the sentences column and create a data frame by splitting the sentences into two different sentences and placing them into separate columns as mentioned below.</p>
<p>I have df1</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Sentence</th>
<th>word</th>
</tr>
</thead>
<tbody>
<tr>
<td>me and John went to the area within 20 minutes</td>
<td>went to</td>
</tr>
<tr>
<td>I ran out of the house and jumped to a conclusion</td>
<td>jumped</td>
</tr>
</tbody>
</table>
</div>
<p>I want to create df2 as below.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Sentence</th>
<th>word</th>
<th>source</th>
<th>target</th>
</tr>
</thead>
<tbody>
<tr>
<td>me and John went to the area within 20 minutes</td>
<td>went to</td>
<td>me and John</td>
<td>the area within 20 minutes</td>
</tr>
<tr>
<td>I ran out of the house and jumped to a conclusion</td>
<td>jumped</td>
<td>I ran out of the house and</td>
<td>to a conclusion</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74346471,
"author": "bwilk315",
"author_id": 20438342,
"author_profile": "https://Stackoverflow.com/users/20438342",
"pm_score": 1,
"selected": false,
"text": "if k == 1:\n while(p <= 1):\n b.append(strarr[j:i])\n j += 1\n i += 1\n p += 1\n for w in b:\n q.append(''.join(w))\n return max(q, key=len)\n"
},
{
"answer_id": 74356266,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
"author_profile": "https://Stackoverflow.com/users/11622508",
"pm_score": 0,
"selected": false,
"text": "def longest_consec(strarr, k):\n i = 0\n max_ = \"\"\n res = \"\"\n if (k<=0) or (k>len(strarr)):\n return \"\"\n while i<=(len(strarr)-k):\n start = \"\".join(strarr[i:i+k])\n max_ = max(max_, start, key=len)\n if max_==start:\n res=strarr[i:i+k]\n i+=1\n return max_\n\n#output: [\"zone\", \"abigail\", \"theta\", \"form\", \"libe\", \"zas\", \"theta\", \"abigail\"], 2 -> abigailtheta\n#output: [\"zones\", \"abigail\", \"theta\", \"form\", \"libe\", \"zas\", \"theta\", \"abigail\"],2 -> zonesabigail\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15444339/"
] |
74,345,934 | <p>I have an array like this:</p>
<pre><code>$datas = array(54,12,61,98,88,
92,45,22,13,36);
</code></pre>
<p>I want to write a loop which can deduct values of an array like below and show it with echo:</p>
<pre><code>$datas[5]-$datas[0] for this line the result will be 92-54 "38"
$datas[6]-$datas[1] for this line the result will be 45-12 "33"
$datas[7]-$datas[2] ... "-39"
</code></pre>
<p>my codes are:</p>
<pre><code><?php
$smonth1= 0;
$emonth1=5;
for ($i = 5; $i > 0; $i-- ) {
$result = array_diff($datas[$emonth1], $datas[$smonth1]);
echo (implode ($result))."<br/>" ;
$smonth1++ ;
$emonth1++;
}
?>
</code></pre>
<p>but I couldn't get the result I don't know why. I am fresh in php. Can you help me??</p>
| [
{
"answer_id": 74346073,
"author": "trckster",
"author_id": 8896838,
"author_profile": "https://Stackoverflow.com/users/8896838",
"pm_score": 2,
"selected": false,
"text": "<?php\n\n$data = [\n 54, 12, 61, 98, 88,\n 92, 45, 22, 13, 36\n];\n\n$offset = 5;\n\nfor ($i = 0; $i + $offset < count($data); $i++) {\n echo $data[$i + $offset] - $data[$i];\n echo \"\\n\"; // or <br/> if you run it in browser\n}\n"
},
{
"answer_id": 74346076,
"author": "ADyson",
"author_id": 5947043,
"author_profile": "https://Stackoverflow.com/users/5947043",
"pm_score": 3,
"selected": true,
"text": "n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19844731/"
] |
74,345,948 | <p>I have a list of order items with the given structure :</p>
<pre><code>OrderItem { Id = 1, Name = "First Item", Quantity = 2 }
OrderItem { Id = 2, Name = "Second Item", Quantity = 2 }
OrderItem { Id = 3, Name = "Third Item", Quantity = 1 }
</code></pre>
<p>I want to flatten it to the following structure :</p>
<pre><code>DBItem{ Id = 1, Name = "First Item" }
DBItem{ Id = 2, Name = "First Item" }
DBItem{ Id = 3, Name = "Second Item" }
DBItem{ Id = 4, Name = "Second Item" }
DBItem{ Id = 5, Name = "Third Item" }
</code></pre>
<p>Is there a way using LINQ <code>SelectMany</code>?</p>
| [
{
"answer_id": 74346070,
"author": "Svyatoslav Danyliv",
"author_id": 10646316,
"author_profile": "https://Stackoverflow.com/users/10646316",
"pm_score": 3,
"selected": true,
"text": "Enumerable.Range"
},
{
"answer_id": 74346197,
"author": "Enigmativity",
"author_id": 259769,
"author_profile": "https://Stackoverflow.com/users/259769",
"pm_score": 1,
"selected": false,
"text": "var items = new[]\n{\n new OrderItem { Id = 1,Name = \"First Item\", Quantity = 2 },\n new OrderItem { Id = 2,Name = \"Second Item\", Quantity = 2 },\n new OrderItem { Id = 3,Name = \"Third Item\", Quantity = 1 },\n};\n\nvar dbItems =\n items\n .SelectMany(item => Enumerable.Repeat(item.Name, item.Quantity))\n .Select((name, index) => new DBItem { Id = index + 1, Name = name });\n"
},
{
"answer_id": 74346616,
"author": "Gernhart",
"author_id": 20320549,
"author_profile": "https://Stackoverflow.com/users/20320549",
"pm_score": 0,
"selected": false,
"text": "var items = new List<OrderItem>\n{\n new OrderItem { Id = 1,Name = \"First Item\", Quantity = 2 },\n new OrderItem { Id = 2,Name = \"Second Item\", Quantity = 2 },\n new OrderItem { Id = 3,Name = \"Third Item\", Quantity = 1 },\n};\nvar dbitems = new List<DBItem>();\nvar counter = 1;\n\nitems.ForEach(item =>\n{\n for (int i = 0; i < item.Quantity; i++)\n {\n dbitems.Add(new DBItem\n {\n Id = counter++,\n Name = item.Name,\n });\n }\n});\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13352466/"
] |
74,345,962 | <p>I want to get the <strong>number of results of a query</strong> in Spring Data Jpa, using a <strong>non-native</strong> <code>@Query</code> method. It consists of a basic group by plus a having clause.</p>
<p>My plain query looks like this (analogous example):</p>
<pre><code>select count(*) from (
select 1 from table t
where t.field_a = 1
group by t.id
having count(*) = 2) a;
</code></pre>
<p>Since Hibernate 5 does not allow subqueries in the <code>form</code> clause, I have to find a workaround for that. The only one I found is very inefficient as per the query plan:</p>
<pre><code>select count(*) from table t
where t.field_a = 1 and
2 = (select count(*) from table temp where temp.id = t.id);
</code></pre>
<p>Is there a way to write a Spring Data JPA query that's as efficient as the first one? I can think of no solution rather than selecting the inner query and taking its <code>size()</code> in java, but that can produce issues due to a ton of redundant data passing through the network.</p>
| [
{
"answer_id": 74500284,
"author": "Pierre Demeestere",
"author_id": 19868455,
"author_profile": "https://Stackoverflow.com/users/19868455",
"pm_score": 0,
"selected": false,
"text": "Query q = em.createQuery(\n \"select 1 from table t where field_a = 1 \" +\n \"group by t.id having count(*) = 2\");\n\nint count = q.getResultList().size();\n"
},
{
"answer_id": 74529860,
"author": "Pierre Demeestere",
"author_id": 19868455,
"author_profile": "https://Stackoverflow.com/users/19868455",
"pm_score": 2,
"selected": true,
"text": "count"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3214777/"
] |
74,345,965 | <p>In a Laravel project I have to store some data in json. For phpUnit tests I use a factory with faker. I try to fake a json structure for the tests, but it always fail on validation. Is there any proper way to create a json in factory that passes the validation for json?</p>
<p>I tried a simple json array, and the json array with json_encode, both of them failed at validation, and gives errors.</p>
<p>With simple json like: <code>'settings' => ['areas' => ['full', 'city']] </code>
the error is:</p>
<pre><code>Property [settings] is not of expected type [json].
Failed asserting that an array contains 'array'.
</code></pre>
<p>With json_encode like: <code>'settings' => json_encode(['areas' => ['full', 'city']])</code>
the error is:</p>
<pre><code>Property [settings] is not of expected type [json].
Failed asserting that an array contains 'string'.
</code></pre>
<p>My model:</p>
<pre class="lang-php prettyprint-override"><code>class Example extends Model
{
protected $fillable = [
'name',
'settings'
];
public static $rules = [
'name' => 'required|string|max:255',
'settings' => 'nullable|json'
];
protected $casts =
'settings' => 'array'
];
}
</code></pre>
<p>My factory:</p>
<pre class="lang-php prettyprint-override"><code><?php
class ExampleFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Example::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->words(3, 7),
'settings' => json_encode(['areas' => ['full', 'city']]) // or what?
];
}
}
</code></pre>
<p>In my test file:</p>
<pre class="lang-php prettyprint-override"><code>
/** @test */
public function shouldStore(): void
{
$item = $this->model::factory()->make();
$data = $item->toArray();
$this->post(action([$this->controller, 'store']), $data)
->assertOk();
}
</code></pre>
| [
{
"answer_id": 74346854,
"author": "Flame",
"author_id": 1346367,
"author_profile": "https://Stackoverflow.com/users/1346367",
"pm_score": 0,
"selected": false,
"text": "array"
},
{
"answer_id": 74348355,
"author": "matiaslauriti",
"author_id": 1998801,
"author_profile": "https://Stackoverflow.com/users/1998801",
"pm_score": 3,
"selected": true,
"text": "class ExampleFactory extends Factory\n{\n /**\n * The name of the factory's corresponding model.\n *\n * @var string\n */\n protected $model = Example::class;\n\n /**\n * Define the model's default state.\n *\n * @return array\n */\n public function definition()\n {\n return [\n 'name' => $this->faker->words(3, 7),\n 'settings' => ['areas' => ['full', 'city']],\n ];\n }\n}\n"
},
{
"answer_id": 74348664,
"author": "apokryfos",
"author_id": 487813,
"author_profile": "https://Stackoverflow.com/users/487813",
"pm_score": 1,
"selected": false,
"text": "public function shouldStore(): void\n{\n $item = $this->model::factory()->make();\n $data = $item->toArray();\n $data['settings'] = json_encode($data['settings']);\n $this->post(action([$this->controller, 'store']), $data)\n ->assertOk();\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11071718/"
] |
74,345,992 | <p>In prisma, I want to check if the data for specific user's exists, if so, pass, if data not exists, process and add the data. How can I do this?</p>
<pre><code> const users = await prisma.user.findUnique({
where: {
email: session.user.email
},
wallet: {
contains: "0x",
},
})
if(users !== 0){
console.log("wallet already signup");
}else{ ...
</code></pre>
| [
{
"answer_id": 74354971,
"author": "Hoàng Huy Khánh",
"author_id": 9711476,
"author_profile": "https://Stackoverflow.com/users/9711476",
"pm_score": 0,
"selected": false,
"text": " const user = await prisma.users.findFirst({\n where: {\n email: session.user.email,\n wallet: {\n contains: '0x',\n },\n },\n });\n\n if (users !== 0) {\n console.log('wallet already signup');\n } else {\n // ...\n }\n"
},
{
"answer_id": 74373872,
"author": "Raphael Etim",
"author_id": 1645620,
"author_profile": "https://Stackoverflow.com/users/1645620",
"pm_score": 1,
"selected": false,
"text": "upsert"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74345992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6894661/"
] |
74,346,000 | <p>I specalized <code>QApplication</code> as <code>MyApplication</code> taking an <code>int</code> parameter for construction.</p>
<pre><code>class MyApplication : public QApplication
{
public:
Foo( int argc, char **argv ) : QApplication( argc, argv )
{
...
}
};
</code></pre>
<p>This class is again specialized in many places in my code.</p>
<p>Unfortunately, I used <code>int</code>, while I should have used <code>int&</code> (as <code>Qapplication</code> expects). Under Windows it did not cause any trouble, but when I moved to Linux it started crashing. So I changed <code>MyApplication</code> to:</p>
<pre><code>class MyApplication : public QApplication
{
public:
Foo( int& argc, char **argv ) : QApplication( argc, argv )
{
...
}
};
</code></pre>
<p>But then, all classes specializing <code>MyApplication</code> also need to be updated, and there are many of them, if they are not, code still compiles but is likely to crash.</p>
<p><strong>I need to identify all places where the change should be applied, but I also want to prevent new code from doing the same mistake.</strong></p>
<p>Is there any way/trick to prevent specialization with <code>int</code> instead of `int&' to compile?</p>
<p>I'd like this code not to be permitted and to produce compilation error:</p>
<pre><code>class OtherApplication : public MyApplication
{
public:
Foo( int argc, char **argv ) : MyApplication( argc, argv )
{
...
}
};
</code></pre>
| [
{
"answer_id": 74346113,
"author": "Sam Varshavchik",
"author_id": 3943312,
"author_profile": "https://Stackoverflow.com/users/3943312",
"pm_score": 3,
"selected": false,
"text": "MyApplication( int &argc, char **argv, int ignore ) : QApplication( argc, argv )\n"
},
{
"answer_id": 74346403,
"author": "Jakob Stark",
"author_id": 17862371,
"author_profile": "https://Stackoverflow.com/users/17862371",
"pm_score": 2,
"selected": false,
"text": "argc"
},
{
"answer_id": 74346788,
"author": "paddy",
"author_id": 1553090,
"author_profile": "https://Stackoverflow.com/users/1553090",
"pm_score": 3,
"selected": true,
"text": "class MyApplication : public QApplication\n{\npublic:\n struct Args final\n {\n Args(int& argc, char** argv) : argc(argc) , argv(argv) {}\n int& argc;\n char** argv;\n };\n\n MyApplication(const Args& args)\n : QApplication(args.argc, args.argv)\n {\n }\n};\n\nint main(int argc, char** argv)\n{\n MyApplication myapp({argc, argv});\n\n // ...\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3336423/"
] |
74,346,041 | <p>First time when web application loads, <code>app.component</code> is getting called and <code>navigationbar #1</code> showing up. Now when user login I want to load <code>navigationbar #2</code> from <code>app.component</code> (or let <code>app.component</code> UI know that user has logged in) so that <code>ng-template</code> can update UI and set <code>navigationbar #2</code>.
This is my code in <code>app.component.html</code> file</p>
<pre><code><div *ngIf="session === 'true'; else NoUserTemplete">
<app-app-navigation-bar-admin></app-app-navigation-bar-admin>
</div>
<ng-template #NoUserTemplete>
<app-navigation-bar></app-navigation-bar>
</ng-template>
</code></pre>
<p><code>app.component.ts</code> file</p>
<pre><code>constructor() {
this.session = localStorage.getItem('isloggedin')
}
</code></pre>
<p>Below method called, when user hit Login button in <code>login.component</code></p>
<pre><code>UserLogin()
{
this.submitted = true;
if(this.loginForm.invalid)
{
localStorage.removeItem("isloggedin");
return
}
let data = { userName: this.loginForm.value.userName, txtemail:this.loginForm.value.txtEmail}
localStorage.setItem("userinfo", JSON.stringify(data));
localStorage.setItem('isloggedin','true');
this.router.navigate(['/home']);
}
</code></pre>
<p>Basically what I need is, whenever <code>localStorage</code>'s <code>isloggedin variable</code> is getting changed <code>app.component</code> should be aware about that and update the UI. How can I do that ?</p>
| [
{
"answer_id": 74346113,
"author": "Sam Varshavchik",
"author_id": 3943312,
"author_profile": "https://Stackoverflow.com/users/3943312",
"pm_score": 3,
"selected": false,
"text": "MyApplication( int &argc, char **argv, int ignore ) : QApplication( argc, argv )\n"
},
{
"answer_id": 74346403,
"author": "Jakob Stark",
"author_id": 17862371,
"author_profile": "https://Stackoverflow.com/users/17862371",
"pm_score": 2,
"selected": false,
"text": "argc"
},
{
"answer_id": 74346788,
"author": "paddy",
"author_id": 1553090,
"author_profile": "https://Stackoverflow.com/users/1553090",
"pm_score": 3,
"selected": true,
"text": "class MyApplication : public QApplication\n{\npublic:\n struct Args final\n {\n Args(int& argc, char** argv) : argc(argc) , argv(argv) {}\n int& argc;\n char** argv;\n };\n\n MyApplication(const Args& args)\n : QApplication(args.argc, args.argv)\n {\n }\n};\n\nint main(int argc, char** argv)\n{\n MyApplication myapp({argc, argv});\n\n // ...\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8977696/"
] |
74,346,060 | <p>I'm working on a PowerShell script to assign users office 365 license based on group (security group). So, i have created app registration and assigned the required API permissions.</p>
<p>When I try to run my script, i get the error below</p>
<pre><code>Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:1 char:1
+ Invoke-RestMethod -Uri $uri -Body $body -ContentType "application/jso ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
</code></pre>
<p>Below is the entire script</p>
<pre><code>$connectiondetails = @{
# This ids and secret are present in the overview and certificate & secret page of our application in azure AD
# Tenant ID here
'tenantid' = ""
# Application (client) ID here
'clientid' = ""
# Secret id here
'ClientSecret' = "" | ConvertTo-SecureString -AsPlainText -Force
}
$token = Get-MsalToken @connectiondetails
$tokenid_ = $token.AccessToken
# $uri = "https://graph.microsoft.com/v1.0/groups"
# $grp = Invoke-RestMethod -Uri $uri -Headers @{Authorization=("bearer {0}" -f $tokenid_)}
# $grp
$uri = "https://graph.microsoft.com/v1.0/groups/ffbabc6f-aa87-40f3-8665-9d140e4a7adb/assignLicense"
$body = "{""SkuId"":""cbdc14ab-d96c-4c30-b9f4-6ada7cdc1d46""}"
# assign license call
Invoke-RestMethod -Uri $uri -Body $body -ContentType "application/json" -Method post -Headers @{Authorization=("bearer {0}" -f $tokenid_)}
</code></pre>
<p>Permissions assigned to the app
<a href="https://i.stack.imgur.com/CARqF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CARqF.png" alt="enter image description here" /></a></p>
<p>I need assistance to know what am doing wrong. Thank you.</p>
<p>Solutions tried
<a href="https://i.stack.imgur.com/o7w5Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o7w5Q.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74346375,
"author": "user2250152",
"author_id": 2250152,
"author_profile": "https://Stackoverflow.com/users/2250152",
"pm_score": 2,
"selected": true,
"text": "addLicenses"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16997421/"
] |
74,346,078 | <h1>Problem</h1>
<p>I have a list of around ~1000 <a href="https://en.wikipedia.org/wiki/Honorific" rel="nofollow noreferrer">honorifics</a>, see below for a sample.</p>
<p>Given an input string of a name, for example <code>"her majesty queen elizabeth windsor"</code>, the function should return <code>"elizabeth windsor"</code>. If there is no honorific present <em>at the start of the name</em> (to simplify the problem), the function should simple return the name itself (e.g. <code>elizabeth windsor</code> -> <code>elizabeth windsor</code>).</p>
<p>I have pretty intense latency constraints, so need to optimise this code as much as possible.</p>
<h1>Working solution</h1>
<p>Here is my working solution, there are some additional constraints to reduce false positives (for example <code>lance</code> is both an honorific and a first name), see the unit tests:</p>
<pre><code>def strip_honorific(source: str, honorifics: List[str]) -> str:
source_tokens = source.split()
if len(source_tokens) > 2:
for honorific in honorifics:
if source.startswith(f"{honorific} "):
stripped_source = source[len(honorific) + 1 :]
if len(stripped_source.split()) > 1:
return stripped_source
return source
</code></pre>
<h1>Unit tests</h1>
<pre><code>def test_honorifics():
assert strip_honorific(source="her majesty queen elizabeth windsor", honorifics = honorifics) == "elizabeth windsor"
assert strip_honorific(source="elizabeth windsor", honorifics = honorifics) == "elizabeth windsor"
assert strip_honorific(source="mrs elizabeth windsor", honorifics = honorifics) == "elizabeth windsor"
assert strip_honorific(source="mrselizabeth windsor", honorifics = honorifics) == "mrselizabeth windsor"
assert strip_honorific(source="mrselizabeth windsor", honorifics = honorifics) == "mrselizabeth windsor"
assert strip_honorific(source="her majesty queen", honorifics = honorifics) == "her majesty queen"
assert strip_honorific(source="her majesty queen elizabeth", honorifics = honorifics) == "her majesty queen elizabeth"
assert strip_honorific(source="kapitan fred", honorifics = honorifics) == "kapitan fred"
test_honorifics()
</code></pre>
<h1>Benchmark</h1>
<p>For a basic benchmark, I've used the below list of honorifics (minus the ellipses).</p>
<pre><code>source_lst = [
"her majesty queen elizabeth windsor",
"mr fred wilson",
"the rt hon nolan borak",
"his most eminent highness simon smithson",
"kapteinis jurijs jakovļevs",
"miss nancy garland",
"missnancy garland",
]
times = []
for _ in range(1000):
for source in source_lst:
t0 = time.time()
strip_honorific(source=source, honorifics = honorifics)
times.append(time.time() - t0)
print(f"Mean time: {sum(times)/ len(times)}s") # Mean time: 5.11584963117327e-06s
</code></pre>
<h1>Honorifics list</h1>
<pre><code>honorifics = [
"mr",
"mrs",
"the hon",
"the hon dr",
"the hon lady",
"the hon lord",
"the hon mrs",
"the hon sir",
"the honourable",
"the rt hon",
"her majesty queen",
"his majesty king",
"vina",
"flottiljamiral",
"superintendent",
"rabbi",
"diraja",
"domnul",
"kindralleitnant",
"countess",
"pan",
"khatib",
"zur",
"vice",
"don",
"flotiles",
"dipl",
"his most eminent highness",
...
"the reverend",
"archbishop",
"sheik",
"shaikh",
"the rt hon lord",
"la tres honorable"
"ekselence",
"kapteinis",
"kapitan",
"excellenza"
"mr",
"mrs",
"miss"
]
</code></pre>
| [
{
"answer_id": 74346375,
"author": "user2250152",
"author_id": 2250152,
"author_profile": "https://Stackoverflow.com/users/2250152",
"pm_score": 2,
"selected": true,
"text": "addLicenses"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2205969/"
] |
74,346,094 | <p>I am trying to create a basic calculator where I have a string for inputs..</p>
<p>like user has inputed 79+93-27,</p>
<p>Here I want to set black colour for digits and red for operators...</p>
<p>this is my code to explain what I want</p>
<p>this is a part of my code , and I don't want to change any kind of variable types..</p>
<pre><code>class MyApp extends StatelessWidget {
MyApp({Key? key}) : super(key: key);
String inputstring = '79+93-27';
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Text(
inputstring,
style: TextStyle(fontSize: 30),
)),
),
);
}
}
</code></pre>
| [
{
"answer_id": 74346285,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "RegExp"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18817235/"
] |
74,346,173 | <p>I am trying to create a POST endpoint which receives a ClassB. This class is a subtype of an abstract class ClassA, and there is another ClassC which is a subclass from ClassA.
This is like that, because ClassB has a collection of ClassA, so ClassB can contain multiple ClassB or ClassC.</p>
<p>The problem is that I always get a Jackson Databind error while processing the request:</p>
<pre><code>An unknown error occurred while processing the request.: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class ClassB]: missing type id property 'type'
at [Source: (io.undertow.servlet.spec.ServletInputStreamImpl); line: 67, column: 1]
at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:43)
at com.fasterxml.jackson.databind.DeserializationContext.missingTypeIdException(DeserializationContext.java:2083)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingTypeId(DeserializationContext.java:1596)
at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._handleMissingTypeId(TypeDeserializerBase.java:307)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedUsingDefaultImpl(AsPropertyTypeDeserializer.java:185)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:119)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1292)
</code></pre>
<p>I have the abstract ClassA as follows:</p>
<pre><code>@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = ClassB.class, name = "classb"),
@JsonSubTypes.Type(value = ClassC.class, name = "classc")})
public abstract class ClassA {
public ClassA () {
}
}
</code></pre>
<p>The ClassB:</p>
<pre><code>@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@JsonTypeName("classb")
public class ClassB extends ClassA implements Serializable {
...
private Collection<ClassA> myList;
...
}
</code></pre>
<p>And the ClassC is created like ClassB, but with the "classc" jsonTypeName and without the collection of ClassA elements.</p>
<p>In the pom.xml I have the following dependency:</p>
<pre><code><dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
</code></pre>
<p>Previously I also had the jsonb dependency in the pom.xml:</p>
<pre><code><dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
</code></pre>
<p>But I commented it out because I thought it could cause some conflict.</p>
<p>In the API, I have the following method:</p>
<pre><code>@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response createClassB(ClassB classB, @Context UriInfo uriInfo) {
...
}
</code></pre>
<p>But I always get the same error, as if I would not have added the @JsonTypeName annotation in ClassB and ClassC.</p>
<p>Is there something I am missing?</p>
<hr />
<p>EDIT: This is the request that I am sending:</p>
<pre><code>{
...
"myList" : [ {
"type" : "classb",
...
}, {
"type" : "classb",
...
} ],
"user" : null
}
</code></pre>
| [
{
"answer_id": 74346285,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "RegExp"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4930717/"
] |
74,346,177 | <p>I'm building a react-electron app. I created a custom window header but I can't access app.quit() & a.*() in my project.</p>
<p>app.js(react):</p>
<pre><code>i tried both type :
</code></pre>
<p>1.import electron from "electron";
2.const electron = require('electron')</p>
<pre><code>
<div onClick={()=>{
electron.app.quit()
}} </div>
</code></pre>
<p>main.js :</p>
<pre><code>const mainWindow = new BrowserWindow({
width: 900,
height: 675,
frame: false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
}
})
mainWindow.loadURL('http://localhost:3000');
</code></pre>
<p>i run the app with this script:</p>
<pre><code>"start": "concurrently \"npm run react-start\" \"wait-on http://localhost:3000 && electron .\"",
</code></pre>
<p>i got this error :
<a href="https://i.stack.imgur.com/sDzhP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sDzhP.png" alt="" /></a></p>
| [
{
"answer_id": 74346285,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "RegExp"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439588/"
] |
74,346,190 | <p>The command I'm inputting into pmc is
<code>Scaffold-DbContext "DataSource=C:\SQLite\Databases\Ticket0.db3" Microsoft.EntityFrameworkCore.Sqlite -OutputDir C:\WPFTutorials\TicketEF\TicketEF\DB -context TicketContext -force</code>
I've checked and double checked the data source, but it only generates a generic context and no tables (I can't include images as I don't have high enough reputation).</p>
<p>I also checked on stack overflow but the closest relevant post I could find was this <a href="https://stackoverflow.com/questions/37984456/sqlite-scaffolding-with-entity-framework-core">SQLite scaffolding with Entity Framework Core</a>, however the problem there was relative pathing whereas I am using an absolute path.
Another I tried was <a href="https://stackoverflow.com/questions/59726563/scaffold-reverse-engineering-existing-database-return-empty-sets">Scaffold (reverse engineering) existing database return empty sets</a> and tried commenting out the <code><Nullable>enable</Nullable></code> which solved their issue but that didn't work either.</p>
<p>I have the</p>
<p><code>Microsoft.EntityFrameworkCore, Microsoft.EntityFrameworkCore.Design, Microsoft.EntityFrameworkCore.Sqlite and Microsoft.EntityFrameworkCore.Tools</code></p>
<p>NuGet packages installed.</p>
<p>In case it matters the database I am trying to connect can be opened and changed in SQLiteStudio so it should be working fine, and it has 5 tables and 2 views.</p>
| [
{
"answer_id": 74346285,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "RegExp"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20284242/"
] |
74,346,199 | <p>I want to create a GUI, without Tkinter or any other library (preferably in Windows and CPython).</p>
<p>Basically, if you go into the files of Python and its libraries, you can find the functions of the libraries. An example is the <code>randint</code> function of the <code>random</code> library:</p>
<pre><code>def randint(self, a, b):
"""Return random integer in range [a, b], including both end points.
"""
return self.randrange(a, b+1)
</code></pre>
<p>Now, instead of using <code>randint</code>, I could just type what the function does in my programs.</p>
<p>This means that Tkinter must have something similar for creating a GUI (though I cannot find Tkinter's files), a made-up example:</p>
<pre><code>def Tk(self, ...):
"""...
"""
...
(simple library like "os" or "sys").create_window(...)
...
</code></pre>
<p>I want the <code>create_window</code> function to use <em>instead of</em> Tkinter, and I would like some documentation on those functions.</p>
<p>I have heard that Tkinter communicates directly to some C stuff, if that is the case, I want to know how to do it directly from my program instead of using Tkinter. And I do not care if it's more complicated, unnecessary, non-pythonic, or any of those, I simply need to create a GUI without any GUI libraries.</p>
| [
{
"answer_id": 74346285,
"author": "eamirho3ein",
"author_id": 10306997,
"author_profile": "https://Stackoverflow.com/users/10306997",
"pm_score": 3,
"selected": true,
"text": "RegExp"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16096769/"
] |
74,346,206 | <p>When trying to run my react native app on android, I get this error:</p>
<p>FAILURE: Build failed with an exception.</p>
<p>What went wrong:
Execution failed for task ':@react-native-firebase_app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.</p>
<p>Build failed error
<a href="https://justpaste.it/27m0w" rel="nofollow noreferrer">link</a></p>
<p>If i commented the react-native-firebase_app package, some other package also return same error.</p>
<p><strong>Example:</strong>
`</p>
<pre><code>> Task :amazon-cognito-identity-js:compileDebugJavaWithJavac FAILED
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
/Users/spurge/Music/ghoshak_owner/node_modules/amazon-cognito-identity-js/android/src/main/java/com/amazonaws/RNAWSCognitoPackage.java:7: error: package com.facebook.react does not exist
import com.facebook.react.ReactPackage;
^
/Users/spurge/Music/ghoshak_owner/node_modules/amazon-cognito-identity-js/android/src/main/java/com/amazonaws/RNAWSCognitoPackage.java:8: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.NativeModule;
^
/Users/spurge/Music/ghoshak_owner/node_modules/amazon-cognito-identity-js/android/src/main/java/com/amazonaws/RNAWSCognitoPackage.java:9: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.ReactApplicationContext;
^
/Users/spurge/Music/ghoshak_owner/node_modules/amazon-cognito-identity-js/android/src/main/java/com/amazonaws/RNAWSCognitoPackage.java:10: error: package com.facebook.react.uimanager does not exist
import com.facebook.react.uimanager.ViewManager;
^
/Users/spurge/Music/ghoshak_owner/node_modules/amazon-cognito-identity-js/android/src/main/java/com/amazonaws/RNAWSCognitoPackage.java:11: error: package com.facebook.react.bridge does not exist
import com.facebook.react.bridge.JavaScriptModule;
^
/Users/spurge/Music/ghoshak_owner/node_modules/amazon-cognito-identity-js/android/src/main/java/com/amazonaws/RNAWSCognitoPackage.java:13: error: cannot find symbol
public class RNAWSCognitoPackage implements ReactPackage {
^
symbol: class ReactPackage
/Users/spurge/Music/ghoshak_owner/node_modules/amazon-cognito-identity-js/android/src/main/java/com/amazonaws/RNAWSCognitoPackage.java:15: error: cannot find symbol
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
^
symbol: class ReactApplicationContext
location: class RNAWSCognitoPackage
/Users/spurge/Music/ghoshak_owner/node_modules/amazon-cognito-identity-js/android/src/main/java/com/amazonaws/RNAWSCognitoPackage.java:15: error: cannot find symbol
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
^
symbol: class NativeModule
location: class RNAWSCognitoPackage
</code></pre>
<p>`</p>
<p><strong>Android/build.gradle</strong></p>
<p>`</p>
<pre><code>ext {
var = '3.1.1'
var1 = '3.6.3'
}
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 30
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "16.+"
firebaseVersion = "17.6.0"
googlePlayServicesAuthVersion = "19.2.0" // <--- use this version or newer
}
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.3'
classpath 'com.google.gms:google-services:4.3.14'
// classpath 'com.android.tools.build:gradle:4.2.1' // <--- use this version or newer
// classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
mavenLocal()
google()
mavenCentral()
maven { url 'https://maven.google.com' }
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url 'https://jitpack.io' }
}
}
subprojects { subproject ->
afterEvaluate {
if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion 29
buildToolsVersion "28.0.3"
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("reactNative51") || names.contains("reactNative55")) {
setIgnore(true)
}
}
}
}
}
}
</code></pre>
<p>`
<strong>Android/app/build.gradle</strong></p>
<p>`</p>
<pre><code>apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js",
// bundleCommand: "ram-bundle",
// bundleAssetName: "index.android.bundle",
// bundleInAlpha: true,
// bundleInBeta: true
]
apply from: "../../node_modules/react-native/react.gradle"
project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf', 'EvilIcons.ttf' ] // Name of the font files you want to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = true
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// configurations {
// exclude group: 'com.google.zxing'
// }
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
defaultConfig {
applicationId "com.ghoshak_owner"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57" // See note below!
versionCode 188
versionName "1.0.5"
multiDexEnabled true
}
signingConfigs {
debug {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
shrinkResources enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
}
configurations {
compile.exclude group: 'com.google.zxing'
compile.exclude group: "junit", module: "junit"
}
dependencies {
implementation project(':react-native-bluetooth-escpos-printer')
implementation project(':react-native-google-signin')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-view-shot')
// implementation project(':@react-native-community_toolbar-android')
// implementation project(':@react-native-firebase_dynamic-links')
// implementation project(':@react-native-firebase_app')
// implementation project(':react-native-safe-area-context')
// implementation project(':react-native-reanimated')
implementation project(':react-native-localization')
// implementation project(':@leesiongchan_react-native-esc-pos')
implementation project(':react-native-notification-sounds')
implementation project(':react-native-image-resizer')
implementation project(':react-native-charts-wrapper')
implementation project(':react-native-razorpay')
implementation project(':react-native-device-info')
implementation project(':react-native-html-to-pdf')
implementation project(':react-native-share')
implementation project(':react-native-pdf-lib')
implementation project(':react-native-google-places')
// implementation project(':react-native-camera')
implementation project(':react-native-maps')
implementation project(':react-native-pdf')
implementation project(':rn-fetch-blob')
// implementation project(':@philly25_react-native-paytm')
implementation project(':react-native-webview')
implementation project(':react-native-youtube')
implementation project(':react-native-camera-kit')
implementation project(':react-native-push-notification')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-svg')
implementation project(':react-native-vector-icons')
implementation project(':amazon-cognito-identity-js')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-navigation')
implementation project(':react-native-splash-screen')
implementation project(':react-native-geolocation-service')
// implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:multidex:1.0.3'
// For WebP support, including animated WebP
implementation 'com.facebook.fresco:animated-webp:1.3.0'
implementation 'com.facebook.fresco:webpsupport:1.3.0'
// For WebP support, without animations
compile 'com.facebook.fresco:webpsupport:1.3.0'
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
implementation 'com.facebook.fresco:webpsupport:1.3.0'
// implementation project(path: ":@react-native-firebase_app")
// implementation project(path: ":@react-native-firebase_dynamic-links")
// implementation project(':react-native-esc-pos')
implementation 'com.android.support:support-compat:+'
implementation 'com.google.android.play:core:1.8.2'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.android.support:design:25.1.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' // <-- add this; newer versions should work too
// implementation platform('com.google.firebase:firebase-bom:26.5.0')
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
//apply plugin: 'com.google.gms.google-services'
</code></pre>
<p>`
<strong>setting.gradle</strong></p>
<p>`</p>
<pre><code>rootProject.name = 'ghoshak_owner'
include ':react-native-bluetooth-escpos-printer'
project(':react-native-bluetooth-escpos-printer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-bluetooth-escpos-printer/android')
include ':react-native-google-signin'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-view-shot'
project(':react-native-view-shot').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-view-shot/android')
// include ':@react-native-community_toolbar-android'
// project(':@react-native-community_toolbar-android').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/toolbar-android/android')
// include ':@react-native-firebase_dynamic-links'
// project(':@react-native-firebase_dynamic-links').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/dynamic-links/android')
// include ':@react-native-firebase_app'
// project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/app/android')
// include ':react-native-safe-area-context'
// project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-safe-area-context/android')
// include ':react-native-reanimated'
// project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')
include ':react-native-localization'
project(':react-native-localization').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-localization/android')
// include ':@leesiongchan_react-native-esc-pos'
// project(':@leesiongchan_react-native-esc-pos').projectDir = new File(rootProject.projectDir, '../node_modules/@leesiongchan/react-native-esc-pos/android')
include ':react-native-notification-sounds'
project(':react-native-notification-sounds').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notification-sounds/android')
include ':react-native-image-resizer'
project(':react-native-image-resizer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-resizer/android')
include ':react-native-charts-wrapper'
project(':react-native-charts-wrapper').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-charts-wrapper/android')
include ':react-native-razorpay'
project(':react-native-razorpay').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-razorpay/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-html-to-pdf'
project(':react-native-html-to-pdf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-html-to-pdf/android')
include ':react-native-share'
project(':react-native-share').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share/android')
include ':react-native-pdf-lib'
project(':react-native-pdf-lib').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf-lib/android')
include ':react-native-google-places'
project(':react-native-google-places').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-places/android')
// include ':react-native-camera'
// project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':react-native-pdf'
project(':react-native-pdf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf/android')
include ':rn-fetch-blob'
project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
// include ':@philly25_react-native-paytm'
// project(':@philly25_react-native-paytm').projectDir = new File(rootProject.projectDir, '../node_modules/@philly25/react-native-paytm/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
include ':react-native-youtube'
project(':react-native-youtube').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-youtube/android')
include ':react-native-camera-kit'
project(':react-native-camera-kit').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera-kit/android')
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-push-notification/android')
include ':react-native-image-crop-picker'
project(':react-native-image-crop-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-crop-picker/android')
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':amazon-cognito-identity-js'
project(':amazon-cognito-identity-js').projectDir = new File(rootProject.projectDir, '../node_modules/amazon-cognito-identity-js/android')
include ':react-native-navigation'
project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
include ':react-native-image-crop-picker'
project(':react-native-image-crop-picker').projectDir = new File(settingsDir, '../node_modules/react-native-image-crop-picker/android')
include ':react-native-push-notification'
project(':react-native-push-notification').projectDir = file('../node_modules/react-native-push-notification/android')
include ':react-native-splash-screen'
project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android')
include ':react-native-geolocation-service'
project(':react-native-geolocation-service').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geolocation-service/android')
// include ':@react-native-firebase_app'
// project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, './../node_modules/@react-native-firebase/app/android')
// include ':@react-native-firebase_dynamic-links'
// project(':@react-native-firebase_dynamic-links').projectDir = new File(rootProject.projectDir, './../node_modules/@react-native-firebase/dynamic-links/android')
// include ':react-native-esc-pos'
// project(':react-native-esc-pos').projectDir = new File(rootProject.projectDir, '../node_modules/@leesiongchan/react-native-esc-pos/android')
include ':app'
</code></pre>
<p>`</p>
| [
{
"answer_id": 74346417,
"author": "Shivam",
"author_id": 8709100,
"author_profile": "https://Stackoverflow.com/users/8709100",
"pm_score": 4,
"selected": true,
"text": "android/build.gradle"
},
{
"answer_id": 74347556,
"author": "Karthik Suthan",
"author_id": 7470531,
"author_profile": "https://Stackoverflow.com/users/7470531",
"pm_score": 2,
"selected": false,
"text": "buildscript {\n // ...\n}\n\n\nallprojects {\n repositories {\n exclusiveContent {\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n // ...\n }\n}\n"
},
{
"answer_id": 74358633,
"author": "LedioNase",
"author_id": 14837281,
"author_profile": "https://Stackoverflow.com/users/14837281",
"pm_score": 0,
"selected": false,
"text": "npm install"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15528101/"
] |
74,346,214 | <p>I want to persist value after user leaves page, also I would like to persist selected values, so I found out shared prefernces and I save it locally, but when I left page and return it remains unselected.</p>
<p>So I decided to convert my multipleSelected list to String, because sharedprefernces can't save list of ints and sfter that save selected values in lists. So how can i solve that problem when user leaves page and selected items become unselected.</p>
<pre><code>class DataBaseUser extends StatefulWidget {
const DataBaseUser({Key? key}) : super(key: key);
@override
State<DataBaseUser> createState() => _DataBaseUserState();
}
class _DataBaseUserState extends State<DataBaseUser> {
int index = 1;
/// add selected items from list
List multipleSelected = [];
/// another list to form the new list above previous one
List chosenListsAbove = [];
List basesNames = [];
SharedPreferences? sharedPreferences;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Typographys.primaryColor,
appBar: PreferredSize(
preferredSize: const Size(125, 125),
child: AppBarService(),
),
body: Column(
children: [
// chosenOne(),
Card(
color: Typographys.gradientCard2,
child: ExpansionTile(
iconColor: Colors.white,
maintainState: true,
title: Text(
'Bases',
style: TextStyle(
fontFamily: 'fonts/Montserrat',
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 35),
),
children: [
SizedBox(
height: 10,
),
getDataBaseList(),
SizedBox(
height: 22,
),
getUpdateBaseButtons(),
SizedBox(
height: 10,
),
],
),
),
],
),
);
}
Widget getDataBaseList() {
return FutureBuilder<List>(
future: BasesService().GetBases(),
builder: (context, snapshot) {
List? baseNames = snapshot.data;
print(baseNames);
return ListView.builder(
shrinkWrap: true,
itemCount: baseNames?.length ?? 0,
itemBuilder: (context, i) {
Future<void> _onCategorySelected(bool selected, id) async {
final pref = await SharedPreferences.getInstance();
if (selected == true) {
setState(() {
multipleSelected.add(id);
List<String> stringsList =
multipleSelected.map((i) => i.toString()).toList();
// store your string list in shared prefs
pref.setStringList("stringList", stringsList);
List<String> mList =
(pref.getStringList('stringList') ?? <String>[]);
print('HERE');
print(mList);
print('HERE 2');
});
} else {
setState(
() {
multipleSelected.remove(id);
},
);
}
}
return Column(
children: [
ListTile(
title: Padding(
padding: const EdgeInsets.only(left: 1.0),
child: Text(
baseNames?[i]['name'] ?? 'not loading',
style: TextStyle(
fontFamily: 'fonts/Montserrat',
fontSize: 24,
fontWeight: FontWeight.w900,
color: Colors.white),
),
),
leading: Checkbox(
activeColor: Colors.green,
checkColor: Colors.green,
side: BorderSide(width: 2, color: Colors.white),
value: multipleSelected.contains(
baseNames?[i]['id'],
),
onChanged: (bool? selected) {
_onCategorySelected(selected!, baseNames?[i]['id']);
},
)
//you can use checkboxlistTile too
),
],
);
},
);
},
);
}
Widget getUpdateBaseButtons() {
return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FutureBuilder<bool>(
future: BasesService().SelectBaseAsync(multipleSelected.cast()),
builder: (context, snapshot) {
return ElevatedButton(
onPressed: () {
if (snapshot.data == true) {
BasesService().SelectBaseAsync(multipleSelected.cast());
print(multipleSelected.cast());
print(multipleSelected);
successSnackBar();
} else {
notSuccessSnackBar();
}
},
child: Text(
'Send bases',
style: TextStyle(
fontFamily: 'fonts/Montserrat',
fontSize: 22,
fontWeight: FontWeight.w900,
color: Colors.white,
letterSpacing: 2),
),
style: ElevatedButton.styleFrom(
minimumSize: Size(200, 40),
primary: Colors.green,
onPrimary: Colors.white,
),
);
return Container();
})
],
),
);
}
</code></pre>
| [
{
"answer_id": 74346417,
"author": "Shivam",
"author_id": 8709100,
"author_profile": "https://Stackoverflow.com/users/8709100",
"pm_score": 4,
"selected": true,
"text": "android/build.gradle"
},
{
"answer_id": 74347556,
"author": "Karthik Suthan",
"author_id": 7470531,
"author_profile": "https://Stackoverflow.com/users/7470531",
"pm_score": 2,
"selected": false,
"text": "buildscript {\n // ...\n}\n\n\nallprojects {\n repositories {\n exclusiveContent {\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n // ...\n }\n}\n"
},
{
"answer_id": 74358633,
"author": "LedioNase",
"author_id": 14837281,
"author_profile": "https://Stackoverflow.com/users/14837281",
"pm_score": 0,
"selected": false,
"text": "npm install"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16357470/"
] |
74,346,237 | <p>I am currently struggling to get a function working with a button that has an onclick event to toggle a class. Please can you review the code and help me understand why it is needing two clicks and how to fix it.</p>
<pre class="lang-js prettyprint-override"><code>function dropdownbuttonclick(element) {
let coll = $(".dropdown");
for (let i = 0; i < coll.length; i++) {
//coll[i].addEventListener("click", function () {
$(this.firstChild).toggleClass('fa-chevron-down fa-chevron-up');
var content = this.nextElementSibling;
//console.log(content);
if (content.style.height === "auto") {
content.style.height = "75px";
}
else {
content.style.height = "auto";
}
//});
}
}
</code></pre>
<pre class="lang-js prettyprint-override"><code>if (row.description.length > 50) {
return "<div width='100%' style='min-height:100px;" + backgrnd + "'><button type='button' class='dropdown' onclick='dropdownbuttonclick(this)'><i class='fa fa-solid fa-chevron-down'></i></button><div class='content' style='margin:20px;'>" + title + "</div></div>";
}
</code></pre>
<p>I have tried to change the onclick event but I am not sure how to fix.</p>
| [
{
"answer_id": 74346341,
"author": "Rory McCrossan",
"author_id": 519413,
"author_profile": "https://Stackoverflow.com/users/519413",
"pm_score": 1,
"selected": true,
"text": "this"
},
{
"answer_id": 74346407,
"author": "gloomy",
"author_id": 19681339,
"author_profile": "https://Stackoverflow.com/users/19681339",
"pm_score": -1,
"selected": false,
"text": "fa-chevron-down"
},
{
"answer_id": 74346581,
"author": "biberman",
"author_id": 15377355,
"author_profile": "https://Stackoverflow.com/users/15377355",
"pm_score": 0,
"selected": false,
"text": "this"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439903/"
] |
74,346,248 | <p>I wanted to change my array of object to different format</p>
<p>I have below output,</p>
<pre><code>let result = [
{
"team_details_id": 1,
"team_name": "Avengers",
"team_description": null,
"date_created": "2022-11-03T09:31:13.000Z",
"date_updated": "2022-11-03T09:31:13.000Z",
"created_by": "23",
"updated_by": null,
"team_participants_id": 2,
"user_id": 101,
"user_name": "test 2",
"email_id": "test2@gmail.com",
"role_id": 3,
"is_active": 1,
"access_code": null
},
{
"team_details_id": 1,
"team_name": "Avengers",
"team_description": null,
"date_created": "2022-11-03T09:31:13.000Z",
"date_updated": "2022-11-03T09:31:13.000Z",
"created_by": "23",
"updated_by": null,
"team_participants_id": 3,
"user_id": 102,
"user_name": "test 3",
"email_id": "test3@gmail.com",
"role_id": 3,
"is_active": 1,
"access_code": null
},
{
"team_details_id": 1,
"team_name": "Avengers",
"team_description": null,
"date_created": "2022-11-03T09:31:13.000Z",
"date_updated": "2022-11-03T09:31:13.000Z",
"created_by": "23",
"updated_by": null,
"team_participants_id": 4,
"user_id": 103,
"user_name": "test 4",
"email_id": "test4@gmail.com",
"role_id": 3,
"is_active": 1,
"access_code": null
},
{
"team_details_id": 1,
"team_name": "Avengers",
"team_description": null,
"date_created": "2022-11-03T09:34:24.000Z",
"date_updated": "2022-11-03T09:34:24.000Z",
"created_by": "23",
"updated_by": "23",
"team_participants_id": 13,
"user_id": 104,
"user_name": "test 5",
"email_id": "test5@gmail.com",
"role_id": 3,
"is_active": 1,
"access_code": null
},
{
"team_details_id": 5,
"team_name": "KantaraBuilders",
"team_description": null,
"date_created": "2022-11-03T09:35:23.000Z",
"date_updated": "2022-11-03T09:35:23.000Z",
"created_by": "23",
"updated_by": null,
"team_participants_id": 16,
"user_id": 105,
"user_name": "test 6",
"email_id": "test6@gmail.com",
"role_id": 3,
"is_active": 1,
"access_code": null
},
{
"team_details_id": 5,
"team_name": "KantaraBuilders",
"team_description": null,
"date_created": "2022-11-03T09:35:23.000Z",
"date_updated": "2022-11-03T09:35:23.000Z",
"created_by": "23",
"updated_by": null,
"team_participants_id": 17,
"user_id": 106,
"user_name": "test 7",
"email_id": "test7@gmail.com",
"role_id": 3,
"is_active": 1,
"access_code": null
}
]
</code></pre>
<p>And I wanted to convert to below format</p>
<pre><code>let foramtedResponse = [{
"team_details_id": 1,
"team_name": "Avengers",
"participant_list":[{
"user_id": 101,
"user_name": "test 2",
"email_id": "test2@gmail.com",
"role_id": 3
},{
"user_id": 102,
"user_name": "test 3",
"email_id": "test3@gmail.com",
"role_id": 3,
},
{
"user_id": 103,
"user_name": "test 4",
"email_id": "test4@gmail.com",
"role_id": 3
},
{
"user_id": 104,
"user_name": "test 5",
"email_id": "test5@gmail.com",
"role_id": 3
}]
},
{
"team_details_id": 5,
"team_name": "KantaraBuilders",
"participant_list":[{
"user_id": 105,
"user_name": "test 6",
"email_id": "test6@gmail.com",
"role_id": 3
},{
"team_participants_id": 17,
"user_id": 106,
"user_name": "test 7",
"email_id": "test7@gmail.com",
"role_id": 3
}]
}
]
</code></pre>
<p>I wanted to do this with the help of map.reduce to reduce to nested array of object and I wanted to match the user_name,user_id and team_details_id for reference.
Please help me
Thanks in advance</p>
| [
{
"answer_id": 74346341,
"author": "Rory McCrossan",
"author_id": 519413,
"author_profile": "https://Stackoverflow.com/users/519413",
"pm_score": 1,
"selected": true,
"text": "this"
},
{
"answer_id": 74346407,
"author": "gloomy",
"author_id": 19681339,
"author_profile": "https://Stackoverflow.com/users/19681339",
"pm_score": -1,
"selected": false,
"text": "fa-chevron-down"
},
{
"answer_id": 74346581,
"author": "biberman",
"author_id": 15377355,
"author_profile": "https://Stackoverflow.com/users/15377355",
"pm_score": 0,
"selected": false,
"text": "this"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439375/"
] |
74,346,255 | <p>When trying static data the slider works fine but when I get my data from an API the design breaks down into a list and the slider stops working.
The slider implementation is as follows:</p>
<p>js</p>
<pre><code> $(".feedback-slider").bxSlider({
slideWidth: 177,
minSlides: 1,
maxSlides: 6,
slideMargin: 15,
touchEnabled: false,
});
</code></pre>
<p>React render</p>
<pre><code><ul className="feedback-slider">
{ApiRes.map((item, i) => {
return (
<li key={i}>
<div className="feedback-single-box">
<div className="card p-20">
<p className="m-0">{item.review}</p>
</div>
<div className="media">
<div className="thumbnail">
{
item.customerimage === null ?
<img
width="36px"
src = "/assets/img/avtar.png"
alt = "/"/>
:
<img
width="36px"
src={ImgPath + item.customerimage}
alt={item.name}
/>
}
</div>
<div className="media-body">
<span className="designation">{item.name}</span>
<h6 className="title">{item.title}</h6>
</div>
</div>
</div>
</li>
);
})}
</ul>
</code></pre>
<p>The result I expected was an infinite scrolling slider but the outcome that i got was a list without the slider working at all. Could any one of you tell me where am i going wrong?</p>
| [
{
"answer_id": 74346360,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": 1,
"selected": false,
"text": "feedback-slider"
},
{
"answer_id": 74347671,
"author": "Nicolas Goudry",
"author_id": 6517788,
"author_profile": "https://Stackoverflow.com/users/6517788",
"pm_score": 0,
"selected": false,
"text": "bxSlider"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20290198/"
] |
74,346,276 | <p>I have a textfield and i want to ensure the data or entry is not more than the intended value.example "the value to be entered should not be more than $4000".</p>
<p>i did some research but i still have been able to solve the problem.</p>
<p>`</p>
<pre><code>TextFormField(
decoration: InputDecoration(
hintStyle: TextStyle(
fontFamily: "Proxima Nova",
fontWeight: FontWeight.w300,
),
border: InputBorder.none,
labelStyle: TextStyle(
color: Color(0xffFAFAFA),
),
),
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(r"[0-9]+|\s"))
],
controller: kiloMeter,
validator: (value) {
if (value != null &&
value.isEmpty &&
value.length < 4) {
return 'Please enter the price you want to purchase';
}
return null;
},
)
: const SizedBox(
height: 120,
);
</code></pre>
<p>`</p>
| [
{
"answer_id": 74346360,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": 1,
"selected": false,
"text": "feedback-slider"
},
{
"answer_id": 74347671,
"author": "Nicolas Goudry",
"author_id": 6517788,
"author_profile": "https://Stackoverflow.com/users/6517788",
"pm_score": 0,
"selected": false,
"text": "bxSlider"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6143170/"
] |
74,346,287 | <p>I currently running a code generating a heatmap with a list of specific genes for different cell type. Each gene is classified in a specified category (A, B, C, etc). In my heatmap function (pheatmap package), I can put "breaks" with a vector of number specifying the row where the break has to be made.</p>
<p>However, I want that code to be flexible and use with modified gene list/table. So I would like to create a vector specifying the "position" where a change in factors is made. Here is a dummy example:</p>
<pre><code>df <- data.frame("Gene ID" = rep(paste0("Gene",1:10),1),
"Category" = c("A", "B", "B", "D", "D", "D", "D", "E", "E", "H" ))
df
#which give
#Gene.ID Category
#1 Gene1 A
#2 Gene2 B
#3 Gene3 B
#4 Gene4 D
#5 Gene5 D
#6 Gene6 D
#7 Gene7 D
#8 Gene8 E
#9 Gene9 E
#10 Gene10 H
</code></pre>
<p>My idea was to order/arrange everything alphabetically (which is already done in my example) and extract the number of occurence through table() fonction:</p>
<pre><code>table(factor(df$Category))
# Which give:
#A B D E H
#1 2 4 2 1
</code></pre>
<p><strong>What I would like to do now</strong></p>
<p>Is to create a vector that "sum" every number with the previous one, so I can have a vector indicating <strong>where the change of factor occurs</strong>. So the output would be:</p>
<pre><code># "1", "3", "7", "9", "10"
</code></pre>
<p>Indicating there that a break should occurs after row 1, row 3, row 7, row 9 and "row 10" (which is the end of the heatmap). How can I achieve that?</p>
<p>Also, in case, is there a better approach to do that?</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 74346360,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": 1,
"selected": false,
"text": "feedback-slider"
},
{
"answer_id": 74347671,
"author": "Nicolas Goudry",
"author_id": 6517788,
"author_profile": "https://Stackoverflow.com/users/6517788",
"pm_score": 0,
"selected": false,
"text": "bxSlider"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14529546/"
] |
74,346,290 | <p>So I encountered this weird issue that is self explanatory in this photo:<a href="https://i.stack.imgur.com/WZfOa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WZfOa.png" alt="C++ program" /></a></p>
<p>In the first 8 lines, I used a variable called <code>classwidth</code> to add increments to l which is set to have an initial value of <code>18.75</code>. Each iteration of the loop prints l value.</p>
<p>However in the second 8 lines, I do the same thing but, I replaced <code>classwidth</code> variable with a constant 1.68, the results are identical in the first 2 lines in each iteration, but in the second 8 lines the program calculates numbers correctly and as expected, while in the first 8 lines, the code starts to lose precession in the fourth line as shown in the photo.</p>
<p>I don't want to use a constant value of 1.68, because this value is calculated by range and k parameters, so it will not always be <code>1.68</code>.</p>
<p>What should I do to have the precession in the second eight lines while using constant <code>classwidth</code>?</p>
<p>This is my code:</p>
<pre><code>#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
// cout << fixed;
// cout << setprecision(2);
// cout << 20.42 + 1.68*3 << endl;
double range;
double l;
int k = 8;
range = 32.17 -18.75;
double classwidth = range/k;
cout << fixed;
cout << setprecision(2);
l = 18.75;
for(int n = 1; n<=k ; n++){
cout<< l << " classwidth: "<< classwidth<<endl;
l += classwidth;
}
cout << "\n\n\n";
l = 18.75;
for(int n = 1; n<=k ; n++){
cout<< l << " classwidth: "<< 1.68 <<endl;
l += 1.68;
}
//groupedData();
}
</code></pre>
<p>I commented the</p>
<pre><code>cout << fixed;
cout << setprecision(2);
</code></pre>
<p>line of code so it is nonfunctional and I still didn't achieve what I want:
<a href="https://i.stack.imgur.com/aJdr9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aJdr9.png" alt="C++ program" /></a></p>
<p>This is the full program:</p>
<pre><code>#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
//CURRENTLY UNFINISHED YET!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void groupedData()
{
int b = 0;
int j;
double numberOfClasses = 0;
int i = 0;
double arr[300];
cout << "Will you specify number of classes (k) 1(yes), 0(no)?"<<endl;
bool k_manual;
cin >> k_manual;
if(cin.fail())
{
cout <<"Invalid input."<<endl;
exit(0);
}
else if(k_manual == 1)
{
cout << "What is it?\n";
cin >> numberOfClasses;
if(cin.fail())
{
cout <<"Invalid input."<<endl;
exit(0);
}
}
cout << "Enter grouped discrete quantitative data to calculate measures of central tendency and measures of variation.\nUse 0 to terminate.\n";
cout << "======================================"<<endl;
while (i < 300)
{
cin >> arr[i];
if (!cin.fail() && arr[i] == 0)
{
int classesK[150];
if (numberOfClasses == 0)
{
numberOfClasses = ceil(1 + 3.3*log10(i));
}
for(j=0; j<= numberOfClasses; j++)
{
b += 1;
classesK[j] = b;
}
double classWidthPrecession;
cout << "Class width precession (1/0.1/0.01)?"<<endl;
cin >> classWidthPrecession;
//int arr[] = {1,2,3,3,2,5,4,4,3,1,2,1,4,6,5,5,4,2,3,2};
cout << "\n\nCalculating..."<<endl;
cout << "------------------"<<endl;
//mean calculation
double mean;
double sum = 0;
for (j=0; j < i; j++)
{
sum += arr[j];
}
mean = sum / i;
cout << "\nMeasures of central tendency:\n----------------------------\n";
cout <<"Mean(x_-): "<< mean <<endl;
//median calculation
sort(arr, arr + i, less<double>());
if (!((i % 2) == 0))
{
int median_index = (i+1) / 2;
double median = arr[median_index - 1];
cout << "Median (x_~): " << median;
}
else
{
double median = (arr[i/2 - 1] + arr[i/2] ) / 2.0;
cout << "Median (x_~): " << median;
}
//range calculation
double range = arr[i-1] - arr[0];
cout << "\n\nMeasures of variability:\n-------------------------\n";
cout << "Range: " << range;
sum = 0;
for (j=0; j<i; j++)
{
sum += pow((arr[j] - mean), 2);
}
double variance = sum / (i-1);
double stdDeviation = sqrt(variance);
double COV = (stdDeviation/mean) * 100;
cout << "\nVariance_s2: " << variance;
cout << "\nStandard Deviation: " << stdDeviation;
cout << "\nCoefficient of Variation: " << COV << "%";
//mean deviation calc
sum = 0;
for (j=0; j<i; j++)
{
sum += abs(arr[j] - mean);
}
double meanDeviation = sum / i;
cout << "\nMean Deviation: " << meanDeviation <<endl;
cout << "-----------------------------------------------------------"<<endl;
int frqArr[150];
double XiArr[150];
for(j=0; j<150; j++)
{
frqArr[j]=0;
}
int k = 0;
// for(j=0; j<i; j++)
// {
// if(arr[j] == arr[j + 1])
// {
// frqArr[k] += 1;
// continue;
// }
// else
// {
// k++;
// XiArr[k] = arr[j];
// }
// }
// int cumArr[150];
// int sumInt = 0;
// for(j=0; j<=k; j++)
// {
// sumInt += frqArr[j];
// cumArr[j] = sumInt;
//
// }
sort(arr, arr+i, less<double>());
double classWidth = range/numberOfClasses;
if(classWidthPrecession == 1)
{
classWidth = ceil(classWidth);
}
cout << fixed;
cout << setprecision(3);
double temp = 1.0;
double ll = arr[0];
double ul;
double ulArr[150];
double llArr[150];
ul = (ll + classWidth) - classWidthPrecession;
double num = classWidth;
for(j=0; j<=numberOfClasses; j++)
{
ulArr[j] = ul;
llArr[j] = ll;
temp = 2.0;
ll = ll + (temp-1.0)*(classWidth);
ul = ul + (temp-1.0)*(classWidth);
}
b=0;
k=0;
for(j=0; j<=i; j++)
{
if((arr[j] >= llArr[b]) && (arr[j] <= ulArr[b]))
{
frqArr[k]++;
continue;
}
else
{
b++;
k++;
continue;
}
}
frqArr[0] -= 1;
int cumArr[150];
int sumInt = 0;
for(j=0; j<=k; j++)
{
sumInt += frqArr[j];
cumArr[j] = sumInt;
}
cout << fixed;
cout << setprecision(2);
cout << "k\t\b|classes\t\t\t\b|Fi\t\t\b|FiXi\t\b|(Xi - X_)^2\t\b|Fi(Xi - X_)^2\t\b|Xi - X_|\t\b|Fi|Xi - X_|"<<endl;
for(j=1; j<=numberOfClasses; j++)
{
//table output..........................
cout<<classesK[j-1]<< "\t\b|" << llArr[j-1] << " - " << ulArr[j-1] << "\t\t\b|" << frqArr[j-1]<<endl;
}
// int frqArrSorted [150];
// copy(frqArr, frqArr + k, frqArrSorted);
// sort(frqArrSorted, frqArrSorted + k);
// // cout << "\n\n" << frqArrSorted[k-1];
// int largestFrq = frqArrSorted[k-1];
// bool isMultimodal = 0;
//
//
// for(b=2; b<=k; b++)
// {
// if(largestFrq == frqArrSorted[k-b])
// {
// isMultimodal = 1;
// continue;
//
// }
// else if(!isMultimodal)
// {
// break;
// }
// }
// b = 0;
// int ModeValIndex[150];
// for(j=0; j<=k; j++)
// {
// if (frqArr[j] == largestFrq && !isMultimodal)
// {
// ModeValIndex[0] = j;
// break;
// }
// else if(frqArr[j] == largestFrq && isMultimodal)
// {
// ModeValIndex[b] = j ;
// b++;
// }
// continue;
// }
//
// if(isMultimodal)
// {
// cout << "\n\nModes are: " <<endl;
// for(j=0; j<b; j++)
// {
// cout << XiArr[ModeValIndex[j] + 1] <<endl;
// }
// if(b==2)
// {
// cout << "\nMode is BiModal." << endl;
// }
// else
// {
// cout << "\nMode is MultiModal." << endl;
// }
//
//
//
// }
//
// else
// {
// cout << "\n\nMode is: " << XiArr[ModeValIndex[0] + 1] << " (UniModal) " <<endl;
//
// }
//
// int max_frqArrVal = 0;
// for(j=0; j<=k; j++){
// if(frqArr[j] > frqArr[j+1]){
// if(frqArr[j] > max_frqArrVal){
// max_frqArrVal = frqArr[j];
// continue;
// }else if()
// else{
// continue;
// }
//
// }else{
// continue;
// }
//
// }
exit(0);
}
else if (!cin.fail())
{
i++;
continue;
}
else
{
cout<<"Wrong!"<<endl;
system("pause");
exit(0);
}
}
}
int main()
{
// cout << fixed;
// cout << setprecision(2);
// cout << 20.42 + 1.68*3 << endl;
double range;
double l;
int k = 8;
range = 32.17 -18.75;
double classwidth = range/k;
// cout << fixed;
// cout << setprecision(2);
l = 18.75;
for(int n = 1; n<=k ; n++)
{
cout<< l << " classwidth: "<< classwidth<<endl;
l += classwidth;
}
cout << "\n\n\n";
l = 18.75;
for(int n = 1; n<=k ; n++)
{
cout<< l << " classwidth: "<< 1.68 <<endl;
l += 1.68;
}
//groupedData();
}
</code></pre>
<p>These are the test data that I use:</p>
<pre class="lang-none prettyprint-override"><code>21.52
19.83
23.11
18.75
20.5
22.48
21.61
19.24
20.48
22.25
19.72
24.36
20.84
22.74
19.37
21.75
20.21
32.17
20.38
20.76
21.87
19.81
21.95
20.93
19.05
23.39
21.05
22.87
22.17
21.24
24.1
20.15
19.84
23.6
20.26
21.47
22.98
21.13
20.04
22.05
21.33
21.36
24.87
19.42
21.23
25.12
20.58
21.75
19.95
21.94
</code></pre>
| [
{
"answer_id": 74346517,
"author": "Eric Postpischil",
"author_id": 298225,
"author_profile": "https://Stackoverflow.com/users/298225",
"pm_score": 2,
"selected": false,
"text": "double start = 18.75, end = 32.17;\nfor (int n = 0; n < k; ++n)\n{\n l = start + (end-start)*n/k;\n cout << l << endl;\n}\n"
},
{
"answer_id": 74349787,
"author": "Ahmad",
"author_id": 8371638,
"author_profile": "https://Stackoverflow.com/users/8371638",
"pm_score": -1,
"selected": false,
"text": "double rounderFunction(double request, int decimalPlaces)\n{\n double newNum;\n double shiftAmount = pow(10, decimalPlaces);\n newNum = round(request * shiftAmount) / shiftAmount;\n return newNum;\n\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8371638/"
] |
74,346,292 | <p>I made three conditional selections on my dataframe. So lets say:</p>
<pre><code>final_df[(final_df['acceptance_advice'] == 'standard') & (final_df['acceptance'] == 'ok')]
final_df[(final_df['acceptance_advice'] == 'not accepted') & (final_df['acceptance'] == 'ok')]
final_df[(final_df['acceptance_advice'] == 'postponed') & (final_df['acceptance'] == 'declined')]
</code></pre>
<p>Now I want to add a categorical variable (the class I am going to use for prediction) from each of these selections. So let's say: the first selection should be class 1 and the second should class 2 and the third selection should be class 3.</p>
<p>I have tried:</p>
<pre><code>cat_1 = final_df[(final_df['acceptance_advice'] == 'standard') & (final_df['acceptance'] == 'ok')]
cat_2 = final_df[(final_df['acceptance_advice'] == 'not accepted') & (final_df['acceptance'] == 'ok')]
cat_3 = final_df[(final_df['acceptance_advice'] == 'postponed') & (final_df['acceptance'] == 'declined')]
final_df['class'] = (cat_1 | cat_2 | cat_3).astype(int)
</code></pre>
<p>But it only worked on two categories (e.g. 0 and 1) but not on three.</p>
<p>final_df looks something like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>feature1</th>
<th>feature2</th>
<th>acceptance_advice</th>
<th>acceptance</th>
</tr>
</thead>
<tbody>
<tr>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
</tr>
<tr>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
</tr>
<tr>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
</tr>
<tr>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
</tr>
</tbody>
</table>
</div>
<p>I want it to look like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>feature1</th>
<th>feature2</th>
<th>acceptance_advice</th>
<th>acceptance</th>
<th>class</th>
</tr>
</thead>
<tbody>
<tr>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>1</td>
</tr>
<tr>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>2</td>
</tr>
<tr>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>1</td>
</tr>
<tr>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>some value</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
<p>I want to add a column class, which should be the class to be predicted.</p>
| [
{
"answer_id": 74346517,
"author": "Eric Postpischil",
"author_id": 298225,
"author_profile": "https://Stackoverflow.com/users/298225",
"pm_score": 2,
"selected": false,
"text": "double start = 18.75, end = 32.17;\nfor (int n = 0; n < k; ++n)\n{\n l = start + (end-start)*n/k;\n cout << l << endl;\n}\n"
},
{
"answer_id": 74349787,
"author": "Ahmad",
"author_id": 8371638,
"author_profile": "https://Stackoverflow.com/users/8371638",
"pm_score": -1,
"selected": false,
"text": "double rounderFunction(double request, int decimalPlaces)\n{\n double newNum;\n double shiftAmount = pow(10, decimalPlaces);\n newNum = round(request * shiftAmount) / shiftAmount;\n return newNum;\n\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439899/"
] |
74,346,350 | <p>I have a table such as follows:</p>
<pre><code>CREATE TABLE Associations (
obj_id int unsigned NOT NULL,
attr_id int unsigned NOT NULL,
assignment Double NOT NULL
PRIMARY KEY (`obj_id`, `attr_id`),
);
</code></pre>
<p>Now the insertion order for the rows is/will be random. Would such a definition lead to fragmentation of the table? Should I be adding an auto inc primary key or would that only speed up the insert and would not help the speed of <code>SELECT</code> queries?<br />
What would a better table definition be for random inserts?</p>
<p>Note, that performance wise I am more interested in <code>SELECT</code> than <code>INSERT</code></p>
| [
{
"answer_id": 74346517,
"author": "Eric Postpischil",
"author_id": 298225,
"author_profile": "https://Stackoverflow.com/users/298225",
"pm_score": 2,
"selected": false,
"text": "double start = 18.75, end = 32.17;\nfor (int n = 0; n < k; ++n)\n{\n l = start + (end-start)*n/k;\n cout << l << endl;\n}\n"
},
{
"answer_id": 74349787,
"author": "Ahmad",
"author_id": 8371638,
"author_profile": "https://Stackoverflow.com/users/8371638",
"pm_score": -1,
"selected": false,
"text": "double rounderFunction(double request, int decimalPlaces)\n{\n double newNum;\n double shiftAmount = pow(10, decimalPlaces);\n newNum = round(request * shiftAmount) / shiftAmount;\n return newNum;\n\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9055634/"
] |
74,346,364 | <p>I'm trying to capture ID scan using MicroBlink BlinkID library
I need to get both:</p>
<ol>
<li>processed , cropped unskewed image from front and back of the ID</li>
<li>unprocessed raw UIImage of which front picture was processed out.</li>
</ol>
<p><code>returnFullDocumentImage</code> and <code>encodeFullDocumentImage</code> but I'm always getting cropped images accessing those properties:</p>
<p><code>fullDocumentFrontImage?.image</code></p>
<p><code>fullDocumentBackImage?.image</code></p>
<p>how to get uncropped front image of the ID?</p>
<p>whatever I do, I get nil when trying to access: <code>frontCameraFrame?.image</code></p>
| [
{
"answer_id": 74346517,
"author": "Eric Postpischil",
"author_id": 298225,
"author_profile": "https://Stackoverflow.com/users/298225",
"pm_score": 2,
"selected": false,
"text": "double start = 18.75, end = 32.17;\nfor (int n = 0; n < k; ++n)\n{\n l = start + (end-start)*n/k;\n cout << l << endl;\n}\n"
},
{
"answer_id": 74349787,
"author": "Ahmad",
"author_id": 8371638,
"author_profile": "https://Stackoverflow.com/users/8371638",
"pm_score": -1,
"selected": false,
"text": "double rounderFunction(double request, int decimalPlaces)\n{\n double newNum;\n double shiftAmount = pow(10, decimalPlaces);\n newNum = round(request * shiftAmount) / shiftAmount;\n return newNum;\n\n}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/399021/"
] |
74,346,383 | <p><strong>TemplateSyntaxError at /challeges/1</strong></p>
<p>Could not parse the remainder: ':' from '1:'</p>
<p>This is my <strong>challege.html</strong></p>
<pre><code>{% if month == 1: %}
<h1>This is {{ text }}</h1>
{% else: %}
<p>This is {{ text }}</p>
{% endif %}
</code></pre>
<p>This is my <strong>views.py</strong></p>
<pre><code>def monthly_challege(request, month):
return render(request, "challeges/challege.html", {
"text": "Your Url Is Empty",
month: month
})
</code></pre>
<p>This is my <strong>urls.py</strong></p>
<pre><code>urlpatterns = [
path("<month>", views.monthly_challege),
]
</code></pre>
| [
{
"answer_id": 74346438,
"author": "TrueGopnik",
"author_id": 16494437,
"author_profile": "https://Stackoverflow.com/users/16494437",
"pm_score": 2,
"selected": true,
"text": "{% if month == 1 %}\n <h1>This is {{ text }}</h1>\n{% else %}\n <p>This is {{ text }}</p>\n{% endif %}\n"
},
{
"answer_id": 74346470,
"author": "Path Parakh",
"author_id": 16527878,
"author_profile": "https://Stackoverflow.com/users/16527878",
"pm_score": 0,
"selected": false,
"text": "before\n{% if month == 1: %}\n<h1>This is {{ text }}</h1>\n{% else: %}\n<p>This is {{ text }}</p>\n{% endif %}\n\n\nafter\n{% if month == 1 %}\n<h1>This is {{ text }}</h1>\n{% else %}\n<p>This is {{ text }}</p>\n{% endif %}\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16527878/"
] |
74,346,397 | <p>I want to extract one key out of my dictionary where the value is >= 0.05. My dictionary looks like this</p>
<pre><code>{'Bed_to_Toilet': 0.5645161290322581,
'Sleep': 0.016129032258064516,
'Morning_Meds': 0.03225806451612903,
'Watch_TV': 0.0,
'Kitchen_Activity': 0.04838709677419355,
'Chores': 0.0,
'Leave_Home': 0.03225806451612903,
'Read': 0.0,
'Guest_Bathroom': 0.08064516129032258,
'Master_Bathroom': 0.22580645161290322}
</code></pre>
<p>and I want <code>startActivity</code> to be a random name from these keys, like the first time I run my code is <code>startActivity = Bed_to_Toilet</code>, the second time is <code>startActivity = Guest_Bathroom</code> and so on.
How can I do it?</p>
<p>I tried doing this</p>
<pre><code>def findFirstActivity(self, startActModel):
startActivity, freq = random.choice(list(startActModel.items()))
return startActivity
</code></pre>
<p>and it works pretty well, I just need a way to add for a condition.</p>
| [
{
"answer_id": 74346601,
"author": "Thomas Kimber",
"author_id": 4137061,
"author_profile": "https://Stackoverflow.com/users/4137061",
"pm_score": 2,
"selected": true,
"text": "candidate_list = [k for k,v in startActModel.items() if v >= 0.05]\n"
},
{
"answer_id": 74346699,
"author": "0x0fba",
"author_id": 20339407,
"author_profile": "https://Stackoverflow.com/users/20339407",
"pm_score": 0,
"selected": false,
"text": "findFirstActivity()"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20071282/"
] |
74,346,402 | <p>Example: Below is the string(sentence) in field and I want to extract the specific data from the below patterns using select query in different fields:</p>
<p>i )</p>
<p>Input :
/a03/infor/current/server/infa_sh/ScriptFil/infa_common/adap_main <strong>'FI_RE_PRJ' 'wf_RE_ACC_TIE_HIS_MNT_EN_AM'</strong></p>
<p>Output :
Select query to fetch FI_RE_PRJ and wf_RE_ACC_TIE_HIS_MNT_EN_AM</p>
<p>Other pattern I have is :</p>
<p>Input :</p>
<p>$SCRIPTS/run_in.ksh -f <strong>FI_FLE_PRJ</strong> -wait <strong>wf_FI_SV_CNCL_RP_BAS_KF</strong></p>
<p>Output :
Select query to fetch FI_FLE_PRJ and wf_FI_SV_CNCL_RP_BAS_KF from input</p>
| [
{
"answer_id": 74346601,
"author": "Thomas Kimber",
"author_id": 4137061,
"author_profile": "https://Stackoverflow.com/users/4137061",
"pm_score": 2,
"selected": true,
"text": "candidate_list = [k for k,v in startActModel.items() if v >= 0.05]\n"
},
{
"answer_id": 74346699,
"author": "0x0fba",
"author_id": 20339407,
"author_profile": "https://Stackoverflow.com/users/20339407",
"pm_score": 0,
"selected": false,
"text": "findFirstActivity()"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11591428/"
] |
74,346,432 | <pre class="lang-py prettyprint-override"><code>players_list = [a,b,c,d,e]
scores_list = [1,2,3,4,5]
</code></pre>
<p>I want the output to be like:</p>
<pre><code>"-a_____________1-"
"-b_____________2-"
"-c_____________3_"
</code></pre>
<p>and so on</p>
<p>I have tried using a nested loop, 2 loops and text formatting and lots of stuff but still can't figure out.</p>
| [
{
"answer_id": 74346544,
"author": "Roland",
"author_id": 20440021,
"author_profile": "https://Stackoverflow.com/users/20440021",
"pm_score": 1,
"selected": false,
"text": "players_list = ['a','b','c','d','e']\nscores_list = [1,2,3,4,5]\nfor p, s in zip(players_list, scores_list):\n print(f\"-{p}_____________{s}-\")\n"
},
{
"answer_id": 74346553,
"author": "Hamatti",
"author_id": 1079129,
"author_profile": "https://Stackoverflow.com/users/1079129",
"pm_score": 0,
"selected": false,
"text": "zip"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18392111/"
] |
74,346,440 | <p>I have got some data from a website. But it has a problem. It has only one column, which contains all the data, which should be in different columns. And it also has implicit missing values. The original data is like</p>
<pre><code>structure(list(original_data = c("Title1", "Authors1", "Reference1 Publication Month Date, Year",
"Abstract1", "Title2", "Authors2", "Reference2 Publication Month Date, Year",
"Abstract2", "Title3", "Authors3", "Reference3 Publication Month Date, Year",
"Title4", "Authors4", "Reference4 Publication Month Date, Year",
"Abstract1")), class = "data.frame", row.names = c(NA, -15L))
</code></pre>
<p>The third item doesn't have "Abstract" for it, and there is no NA also in its place.</p>
<p>So, I want to spread the data in different columns. The expected format would be</p>
<pre><code>structure(list(Titles_Data = c("Title1", "Title2", "Title3",
"Title4"), Authors_Data = c("Authors1", "Authors2", "Authors3",
"Authors4"), Details_Data = c("Reference1 Publication Month Date, Year",
"Reference2 Publication Month Date, Year", "Reference3 Publication Month Date, Year",
"Reference4 Publication Month Date, Year"), Abstracts_Data = c("Abstract1",
"Abstract2", NA, "Abstract4")), class = "data.frame", row.names = c(NA,
-4L))
</code></pre>
<p>How can I spread this data in this situation? The real data is of much larger size, around 1,700 rows.</p>
| [
{
"answer_id": 74346577,
"author": "Anoushiravan R",
"author_id": 14314520,
"author_profile": "https://Stackoverflow.com/users/14314520",
"pm_score": 1,
"selected": false,
"text": "Abstract_data"
},
{
"answer_id": 74346722,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 0,
"selected": false,
"text": "library(tidyverse)\n\ndf |> \n group_by(group = cumsum(grepl(\"Title\", original_data))) |>\n summarise(txt = paste(original_data, collapse = \"---\")) |>\n separate(txt, into = c(\"Titles_Data\", \"Authors_Data\", \"Details_Data\", \"Abstracts_Data\"),\n sep = \"---\")\n#> # A tibble: 4 x 5\n#> group Titles_Data Authors_Data Details_Data Abstr~1\n#> <int> <chr> <chr> <chr> <chr> \n#> 1 1 Title1 Authors1 Reference1 Publication Month Date, Year Abstra~\n#> 2 2 Title2 Authors2 Reference2 Publication Month Date, Year Abstra~\n#> 3 3 Title3 Authors3 Reference3 Publication Month Date, Year <NA> \n#> 4 4 Title4 Authors4 Reference4 Publication Month Date, Year Abstra~\n#> # ... with abbreviated variable name 1: Abstracts_Data\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12806202/"
] |
74,346,450 | <p>Are the following two any different?</p>
<ol>
<li><p>Using <code>@Environment(\.managedObjectContext) private var moc</code></p>
</li>
<li><p>Calling <code>PersistentController.shared.container.viewContext</code> when the <code>PersistentController.shared</code> is a <code>static let</code> instance, i.e. <code>static let shared = PersistenceController()</code></p>
</li>
</ol>
<p>As I currently understand it, <code>static let</code> means one and only instance across the whole application, which is pretty much the same as a singleton.</p>
<p>In my view models I currently pass in <code>moc</code> in the contractors to be used later such as (and I'll call <code>.init(moc)</code> where <code>moc</code> comes from <code>@Environment(\.managedObjectContext))</code></p>
<pre><code>
init(moc: NSManagedObjectContext) {
self.moc = moc
//the rest are omitted but you get the idea...
}
</code></pre>
<p>And I was wondering if I can simplify it using the <code>static let</code> instance like</p>
<pre><code>
init() {
self.moc = PersistenceController.shared.container.viewContext
}
</code></pre>
| [
{
"answer_id": 74346577,
"author": "Anoushiravan R",
"author_id": 14314520,
"author_profile": "https://Stackoverflow.com/users/14314520",
"pm_score": 1,
"selected": false,
"text": "Abstract_data"
},
{
"answer_id": 74346722,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 0,
"selected": false,
"text": "library(tidyverse)\n\ndf |> \n group_by(group = cumsum(grepl(\"Title\", original_data))) |>\n summarise(txt = paste(original_data, collapse = \"---\")) |>\n separate(txt, into = c(\"Titles_Data\", \"Authors_Data\", \"Details_Data\", \"Abstracts_Data\"),\n sep = \"---\")\n#> # A tibble: 4 x 5\n#> group Titles_Data Authors_Data Details_Data Abstr~1\n#> <int> <chr> <chr> <chr> <chr> \n#> 1 1 Title1 Authors1 Reference1 Publication Month Date, Year Abstra~\n#> 2 2 Title2 Authors2 Reference2 Publication Month Date, Year Abstra~\n#> 3 3 Title3 Authors3 Reference3 Publication Month Date, Year <NA> \n#> 4 4 Title4 Authors4 Reference4 Publication Month Date, Year Abstra~\n#> # ... with abbreviated variable name 1: Abstracts_Data\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13286319/"
] |
74,346,457 | <p><a href="https://i.stack.imgur.com/9QBa9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9QBa9.png" alt="enter image description here" /></a></p>
<p>I wanted to get the value in column A which does not have a certain value on column B. For example, in this picture, given the set in column B when grouped using the value in column A, how can I get the values which does not have "4" in each set?</p>
<p>So the answer that I'm looking for is 2000 and 3000 because they do not have "4" in their respective sets in column B.</p>
<p>Is this achievable? I can't wrap around my head if INDEX and MATCH can do this.</p>
| [
{
"answer_id": 74346652,
"author": "Tom Sharpe",
"author_id": 3894917,
"author_profile": "https://Stackoverflow.com/users/3894917",
"pm_score": 3,
"selected": true,
"text": "=UNIQUE(FILTER(A1:A20,(COUNTIFS(A1:A20,A1:A20,B1:B20,4)=0)*(A1:A20<>\"\")))\n"
},
{
"answer_id": 74347339,
"author": "P.b",
"author_id": 12634230,
"author_profile": "https://Stackoverflow.com/users/12634230",
"pm_score": 2,
"selected": false,
"text": "=LET(range,A1:B13,\n ca,INDEX(range,,1),\n cb,INDEX(range,,2),\n ua,UNIQUE(ca),\n ub,UNIQUE(cb), \n all,DROP(REDUCE(0,ub,LAMBDA(x,u,VSTACK(x,ua&u))),1), \n alla,DROP(REDUCE(0,ub,LAMBDA(x,u,VSTACK(x,ua))),1),\nFILTER(alla,ISERROR(XMATCH(all,ca&cb))))\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3959685/"
] |
74,346,459 | <p>I want to position my element according to top and not according to margin-top but the default is top = 0 and I try to change and fail only using br</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>.hover {
color: #fff0;
background: linear-gradient(90deg, gold 50%, #fff 0) var(--_p, 100%)/200% no-repeat;
-webkit-background-clip: text;
background-clip: text;
transition: 3s;
font-family: system-ui, sans-serif;
font-size: 2rem;
line-height: 1.5;
max-width: 23.2%;
margin-left: 120px;
}
.h1 {
top:100px
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="h1">
<h1 class="hover">
<div>Hi,</div>
<div>I'm Opal</div>
<div>Welcome to my site.</div>
<!-- <span class="h1">&lt;h1&gt;</span> -->
</h1>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74346813,
"author": "JKD",
"author_id": 14152908,
"author_profile": "https://Stackoverflow.com/users/14152908",
"pm_score": 0,
"selected": false,
"text": ".h1 {\n position: fixed; \n width: 100%;\n margin-top:100px;\n}\n"
},
{
"answer_id": 74347037,
"author": "Mad7Dragon",
"author_id": 6467902,
"author_profile": "https://Stackoverflow.com/users/6467902",
"pm_score": 0,
"selected": false,
"text": "div.a {\n position: relative;\n width: 400px;\n height: 200px;\n border: 3px solid red;\n}\n\ndiv.b {\n position: absolute;\n top: 0;\n border: 3px solid blue;\n} \n\ndiv.c {\n position: absolute;\n top: 50px;\n border: 3px solid green;\n} "
},
{
"answer_id": 74347166,
"author": "Mohammed Anwar Alhamed",
"author_id": 20337125,
"author_profile": "https://Stackoverflow.com/users/20337125",
"pm_score": 1,
"selected": false,
"text": "<!DOCTYPE html>\n<html>\n<head>\n<style>\ndiv.relative {\n position: relative;\n left: 30px;\n border: 3px solid #73AD21;\n}\n</style>\n</head>\n<body>\n\n<h2>position: relative;</h2>\n\n<p>An element with position: relative; is positioned relative to its normal position:</p>\n\n<div class=\"relative\">\nThis div element has position: relative;\n</div>\n\n</body>\n</html>\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19877456/"
] |
74,346,465 | <p>I have a list of 42 tasks. I represent that those tasks are complete with a date (date completed). I want to calculate the percentage of tasks completed in row 45, but the percetage of tasks complete keep getting mixed up witht he dates. The date is just when the task was completed, and I want to know the percent of the tasks completed.</p>
<p>I haven't actually been able to figure out the code because the date is read. The date is irrelevant to the percentage of tasks completed, but it is needed for me to know WHEN it was done for annual training.</p>
| [
{
"answer_id": 74346813,
"author": "JKD",
"author_id": 14152908,
"author_profile": "https://Stackoverflow.com/users/14152908",
"pm_score": 0,
"selected": false,
"text": ".h1 {\n position: fixed; \n width: 100%;\n margin-top:100px;\n}\n"
},
{
"answer_id": 74347037,
"author": "Mad7Dragon",
"author_id": 6467902,
"author_profile": "https://Stackoverflow.com/users/6467902",
"pm_score": 0,
"selected": false,
"text": "div.a {\n position: relative;\n width: 400px;\n height: 200px;\n border: 3px solid red;\n}\n\ndiv.b {\n position: absolute;\n top: 0;\n border: 3px solid blue;\n} \n\ndiv.c {\n position: absolute;\n top: 50px;\n border: 3px solid green;\n} "
},
{
"answer_id": 74347166,
"author": "Mohammed Anwar Alhamed",
"author_id": 20337125,
"author_profile": "https://Stackoverflow.com/users/20337125",
"pm_score": 1,
"selected": false,
"text": "<!DOCTYPE html>\n<html>\n<head>\n<style>\ndiv.relative {\n position: relative;\n left: 30px;\n border: 3px solid #73AD21;\n}\n</style>\n</head>\n<body>\n\n<h2>position: relative;</h2>\n\n<p>An element with position: relative; is positioned relative to its normal position:</p>\n\n<div class=\"relative\">\nThis div element has position: relative;\n</div>\n\n</body>\n</html>\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20439032/"
] |
74,346,554 | <p>I run Memgraph on Kubernetes using the sample service+deployment found in the memgraph/bolt-proxy repo. Unfortunately, that config doesn’t include a persistent volume claim. I'd like to keep Memgraph’s log and snapshots persistent in Kubernetes. How can I do that?</p>
| [
{
"answer_id": 74346555,
"author": "KWriter",
"author_id": 18781306,
"author_profile": "https://Stackoverflow.com/users/18781306",
"pm_score": 0,
"selected": false,
"text": "PersistentVolumeClaim"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18781306/"
] |
74,346,559 | <p>im trying to join data together using the join function on SQL and every time i run my query it shows error and the error says according to the data im using right now, it says 'bikeshare_trips' is not qualified with the dataset (e.g data table )</p>
<p>i checked for the data in the dataset and its there so i dont really understand what the error mean. and also check for any mistakes in my query and run it again but still the same result. and the link to my query is gonna be placed in case anyone wants to check it out. <a href="https://console.cloud.google.com/bigquery?sq=740828604161:fd77df6d30144ae5ab39070c0d68d6a1" rel="nofollow noreferrer">https://console.cloud.google.com/bigquery?sq=740828604161:fd77df6d30144ae5ab39070c0d68d6a1</a></p>
| [
{
"answer_id": 74346555,
"author": "KWriter",
"author_id": 18781306,
"author_profile": "https://Stackoverflow.com/users/18781306",
"pm_score": 0,
"selected": false,
"text": "PersistentVolumeClaim"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20318123/"
] |
74,346,571 | <p><a href="https://i.stack.imgur.com/fE3kD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fE3kD.png" alt="enter image description here" /></a></p>
<p>How do I get the About Me and Education sections to the right side of the web</p>
<p>Here is pencode link: <a href="https://codepen.io/Weng-Hong-the-selector/pen/GRGjVLy" rel="nofollow noreferrer">https://codepen.io/Weng-Hong-the-selector/pen/GRGjVLy</a></p>
<p>Here is my HTML and CSS
`</p>
<pre><code><!DOCTYPE html>
<body>
<div class="resume">
<div class="resume_left">
<div class="resume_profile">
<img src="me.png" width=500px height=250px alt="profile_pic">
</div>
<div class="resume_content">
<div class="resume_item resume_info">
<div class="title">
<p class="bold">TAN WENG HONG</p>
<p class="regular">STUDENT OF DIPLOMA IN IT</p>
</div>
<ul>
<li>
<div class="icon">
<i class="fas fa-mars-and-venus"></i>
</div>
<div class="data">
Male
</div>
</li>
<li>
<div class="icon">
<i class="fa-solid fa-flag"></i>
</div>
<div class="data">
Malaysian
</div>
</li>
<li>
<div class="icon">
<i class="fa-solid fa-signs-post"></i>
</div>
<div class="data">
13A, Elitis Suria, Valencia, 47000, Sungai Buloh, Selangor
</div>
</li>
<li>
<div class="icon">
<i class="fas fa-mobile-alt"></i>
</div>
<div class="data">
012-352-5089
</div>
</li>
<li>
<div class="icon">
<i class="fas fa-envelope"></i>
</div>
<div class="data">
wenghong.tan@sd.taylors.edu.my
</div>
</li>
</ul>
</div>
<div class="resume_item resume_social">
<div class="title">
<p class="bold">Social</p>
</div>
<ul>
<li>
<div class="icon">
<i class="fab fa-facebook-square"></i>
</div>
<div class="data">
<p><a href="https://www.facebook.com/tan.w.hong.16">Facebook</a></p>
</div>
</li>
<li>
<div class="icon">
<i class="fab fa-instagram-square"></i>
</div>
<div class="data">
<p><a href="https://www.instagram.com/wenghongggggg/">Instagram</a></p>
</div>
</li>
<li>
<div class="icon">
<i class="fab fa-youtube"></i>
</div>
<div class="data">
<p><a href="https://www.youtube.com/channel/UCXdPTNsToFxqfBvHg_z5XTA">Youtube</a></p>
</div>
</li>
<li>
<div class="icon">
<i class="fab fa-linkedin"></i>
</div>
<div class="data">
<p><a href="https://www.linkedin.com/in/tan-weng-hong-314211251/">LinkedIn</a></p>
</div>
</li>
</ul>
</div>
<div class="resume_right">
<div class="resume_item resume_about">
<div class="title">
<p class="bold">About me</p>
</div>
<p>My name is Tan Weng Hong and I am currently 19 years old</p>
</div>
</div>
</div>
<div class="resume_item resume_education">
<div class="title">
<p class="bold">Education</p>
</div>
<ul>
<li>
<div class="date">2021 - present</div>
<div class="info">
<p class="semi-bold">Taylor's College</p>
<p>Diploma in Information Technology</p>
<p>Current CGPA: 3.01</p>
<p>Will Graduate August 2023</p>
</div>
</li>
<li>
<div class="date">2016 - 2020</div>
<div class="info">
<p class="semi-bold">SMK Sri KDU</p>
<p>- Sijil Pelajaran Malaysia (SPM)</p>
<p> &nbsp&nbspResults: 1A+ 1A 1C+ 1C 2D 3E 1G</p>
</div>
</li>
</ul>
</div>
<div class="resume_item resume_hobby">
</body>
</html>
</code></pre>
<p>`</p>
<p>`</p>
<pre><code>* {
margin: 0;
padding: 0;
box-sizing: border-box;
list-style: none;
font-family: 'Roboto Condensed', sans-serif;
}
body {
background: #D3D3D3;
font-size: 14px;
line-height: 22px;
color: #555555;
width: 200vh;
text-align: center;
}
img{
border: solid;
border_width: 5px;
}
.bold {
font-weight: 700;
font-size: 20px;
text-transform: uppercase;
}
.semi-bold {
font-weight: 500;
font-size: 16px;
}
.regular{
font-weight: 700;
font-size: 12px;
text-transform: uppercase;
}
.resume {
width: 1200px;
height: auto;
display: flex;
margin: 50px auto;
}
.resume .resume_left {
width: 290px;
height: 1050px;
background: #0bb5f4;
padding: 3px;
}
.resume .resume_left .resume_profile {
width: 100%;
height: 350px;
}
.resume .resume_left .resume_profile img {
width: 100%;
height: 100%;
}
.resume .resume_left .resume_content {
padding: 0 25px;
}
.resume .title {
margin-bottom: 20px;
}
.resume .resume_left .bold {
color: #fff;
}
.resume .resume_left .regular {
color: #b1eaff;
}
.resume .resume_item {
padding: 25px 0;
border-bottom: 2px solid #b1eaff;
}
.resume .resume_left ul li {
display: flex;
margin-bottom: 20px;
align-items: center;
}
.resume .resume_left ul li:last-child {
margin-bottom: 0;
}
.resume .resume_left ul li .icon {
width: 35px;
height: 35px;
background: #fff;
color: #0bb5f4;
border-radius: 50%;
margin-right: 15px;
font-size: 16px;
position: relative;
}
.resume .icon i,
.resume ul li i {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.resume .resume_left ul li .data {
color: #b1eaff;
}
.resume .resume_left .resume_social .semi-bold {
color: #fff;
margin-bottom: 3px;
}
</code></pre>
<p>`</p>
<p>i want my about me section and education section to be on the right side of info section, any idea how to get that to work? thank you in advance</p>
| [
{
"answer_id": 74346650,
"author": "HmBloqued",
"author_id": 17183809,
"author_profile": "https://Stackoverflow.com/users/17183809",
"pm_score": 0,
"selected": false,
"text": "position : fixed;\nright : 0;\n"
},
{
"answer_id": 74346657,
"author": "Shaya",
"author_id": 3612903,
"author_profile": "https://Stackoverflow.com/users/3612903",
"pm_score": 0,
"selected": false,
"text": "text-align: right"
},
{
"answer_id": 74346742,
"author": "Shoaib Amin",
"author_id": 19580087,
"author_profile": "https://Stackoverflow.com/users/19580087",
"pm_score": 0,
"selected": false,
"text": " display: flex;\n justify-content: flex-end\n"
},
{
"answer_id": 74346948,
"author": "Gabriel Silva",
"author_id": 19986160,
"author_profile": "https://Stackoverflow.com/users/19986160",
"pm_score": 1,
"selected": false,
"text": "\n<div class=\"resume\">\n <div class=\"resume_left\">\n <div class=\"resume_profile\">\n <img src=\"me.png\" width=500px height=250px alt=\"profile_pic\">\n </div>\n <div class=\"resume_content\">\n <div class=\"resume_item resume_info\">\n <div class=\"title\">\n <p class=\"bold\">TAN WENG HONG</p>\n <p class=\"regular\">STUDENT OF DIPLOMA IN IT</p>\n </div>\n <ul>\n <li>\n <div class=\"icon\">\n <i class=\"fas fa-mars-and-venus\"></i>\n </div>\n <div class=\"data\">\n Male\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fa-solid fa-flag\"></i>\n </div>\n <div class=\"data\">\n Malaysian\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fa-solid fa-signs-post\"></i>\n </div>\n <div class=\"data\">\n 13A, Elitis Suria, Valencia, 47000, Sungai Buloh, Selangor\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fas fa-mobile-alt\"></i>\n </div>\n <div class=\"data\">\n 012-352-5089\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fas fa-envelope\"></i>\n </div>\n <div class=\"data\">\n wenghong.tan@sd.taylors.edu.my\n </div>\n </li>\n </ul>\n </div>\n <div class=\"resume_item resume_social\">\n <div class=\"title\">\n <p class=\"bold\">Social</p>\n </div>\n <ul>\n <li>\n <div class=\"icon\">\n <i class=\"fab fa-facebook-square\"></i>\n </div>\n <div class=\"data\">\n <p><a href=\"https://www.facebook.com/tan.w.hong.16\">Facebook</a></p>\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fab fa-instagram-square\"></i>\n </div>\n <div class=\"data\">\n <p><a href=\"https://www.instagram.com/wenghongggggg/\">Instagram</a></p>\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fab fa-youtube\"></i>\n </div>\n <div class=\"data\">\n <p><a href=\"https://www.youtube.com/channel/UCXdPTNsToFxqfBvHg_z5XTA\">Youtube</a></p>\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fab fa-linkedin\"></i>\n </div>\n <div class=\"data\">\n <p><a href=\"https://www.linkedin.com/in/tan-weng-hong-314211251/\">LinkedIn</a></p>\n </div>\n </li>\n </ul>\n </div>\n \n </div>\n </div>\n <div class=\"resume_right\">\n <div class=\"resume_item resume_about\">\n <div class=\"title\">\n <p class=\"bold\">About me</p>\n </div>\n <p>My name is Tan Weng Hong and I am currently 19 years old</p>\n </div>\n <div class=\"resume_item resume_education\">\n <div class=\"title\">\n <p class=\"bold\">Education</p>\n </div>\n <ul>\n <li>\n <div class=\"date\">2021 - present</div>\n <div class=\"info\">\n <p class=\"semi-bold\">Taylor's College</p>\n <p>Diploma in Information Technology</p>\n <p>Current CGPA: 3.01</p>\n <p>Will Graduate August 2023</p>\n </div>\n </li>\n <li>\n <div class=\"date\">2016 - 2020</div>\n <div class=\"info\">\n <p class=\"semi-bold\">SMK Sri KDU</p>\n <p>- Sijil Pelajaran Malaysia (SPM)</p>\n <p>   Results: 1A+ 1A 1C+ 1C 2D 3E 1G</p>\n </div>\n </li>\n </ul>\n </div>\n </div>\n </div>\n\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440005/"
] |
74,346,596 | <p>New with C++ but been coding a lot of ObjC back in the day. So i thought i was smart trying to solve a cross reference issue with the old delegate pattern used widely in ObjC but only managed to move the issue it to another file .</p>
<p>Im trying to reach the invoker of the file by passing it as a reference, conforming to a "interface".</p>
<pre><code>#pragma once
#include <libUI.h>
#include <Arduino.h>
class PeripheralDelegate {
public:
virtual void pushViewController(PeripheralViewController* vc) = 0;
virtual void popLastViewController() = 0;
};
class PeripheralViewController: public ViewController {
private:
PeripheralDelegate* mDelegate;
public:
PeripheralViewController(): ViewController(), mDelegate() {}
PeripheralViewController(String id, Rect frame, PeripheralDelegate* delegate): ViewController(id, frame), mDelegate(delegate) {}
virtual ~PeripheralViewController() {}
virtual void encoderValueChanged(int newVal, int oldVal) = 0;
virtual void encoderSwitchPressed() = 0;
virtual void backButtonPressed() = 0;
virtual void firstButtonPressed() = 0;
virtual void secondButtonPressed() = 0;
};
</code></pre>
<p>Also, all kind of feedback on the code is much appriciated!</p>
| [
{
"answer_id": 74346650,
"author": "HmBloqued",
"author_id": 17183809,
"author_profile": "https://Stackoverflow.com/users/17183809",
"pm_score": 0,
"selected": false,
"text": "position : fixed;\nright : 0;\n"
},
{
"answer_id": 74346657,
"author": "Shaya",
"author_id": 3612903,
"author_profile": "https://Stackoverflow.com/users/3612903",
"pm_score": 0,
"selected": false,
"text": "text-align: right"
},
{
"answer_id": 74346742,
"author": "Shoaib Amin",
"author_id": 19580087,
"author_profile": "https://Stackoverflow.com/users/19580087",
"pm_score": 0,
"selected": false,
"text": " display: flex;\n justify-content: flex-end\n"
},
{
"answer_id": 74346948,
"author": "Gabriel Silva",
"author_id": 19986160,
"author_profile": "https://Stackoverflow.com/users/19986160",
"pm_score": 1,
"selected": false,
"text": "\n<div class=\"resume\">\n <div class=\"resume_left\">\n <div class=\"resume_profile\">\n <img src=\"me.png\" width=500px height=250px alt=\"profile_pic\">\n </div>\n <div class=\"resume_content\">\n <div class=\"resume_item resume_info\">\n <div class=\"title\">\n <p class=\"bold\">TAN WENG HONG</p>\n <p class=\"regular\">STUDENT OF DIPLOMA IN IT</p>\n </div>\n <ul>\n <li>\n <div class=\"icon\">\n <i class=\"fas fa-mars-and-venus\"></i>\n </div>\n <div class=\"data\">\n Male\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fa-solid fa-flag\"></i>\n </div>\n <div class=\"data\">\n Malaysian\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fa-solid fa-signs-post\"></i>\n </div>\n <div class=\"data\">\n 13A, Elitis Suria, Valencia, 47000, Sungai Buloh, Selangor\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fas fa-mobile-alt\"></i>\n </div>\n <div class=\"data\">\n 012-352-5089\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fas fa-envelope\"></i>\n </div>\n <div class=\"data\">\n wenghong.tan@sd.taylors.edu.my\n </div>\n </li>\n </ul>\n </div>\n <div class=\"resume_item resume_social\">\n <div class=\"title\">\n <p class=\"bold\">Social</p>\n </div>\n <ul>\n <li>\n <div class=\"icon\">\n <i class=\"fab fa-facebook-square\"></i>\n </div>\n <div class=\"data\">\n <p><a href=\"https://www.facebook.com/tan.w.hong.16\">Facebook</a></p>\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fab fa-instagram-square\"></i>\n </div>\n <div class=\"data\">\n <p><a href=\"https://www.instagram.com/wenghongggggg/\">Instagram</a></p>\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fab fa-youtube\"></i>\n </div>\n <div class=\"data\">\n <p><a href=\"https://www.youtube.com/channel/UCXdPTNsToFxqfBvHg_z5XTA\">Youtube</a></p>\n </div>\n </li>\n <li>\n <div class=\"icon\">\n <i class=\"fab fa-linkedin\"></i>\n </div>\n <div class=\"data\">\n <p><a href=\"https://www.linkedin.com/in/tan-weng-hong-314211251/\">LinkedIn</a></p>\n </div>\n </li>\n </ul>\n </div>\n \n </div>\n </div>\n <div class=\"resume_right\">\n <div class=\"resume_item resume_about\">\n <div class=\"title\">\n <p class=\"bold\">About me</p>\n </div>\n <p>My name is Tan Weng Hong and I am currently 19 years old</p>\n </div>\n <div class=\"resume_item resume_education\">\n <div class=\"title\">\n <p class=\"bold\">Education</p>\n </div>\n <ul>\n <li>\n <div class=\"date\">2021 - present</div>\n <div class=\"info\">\n <p class=\"semi-bold\">Taylor's College</p>\n <p>Diploma in Information Technology</p>\n <p>Current CGPA: 3.01</p>\n <p>Will Graduate August 2023</p>\n </div>\n </li>\n <li>\n <div class=\"date\">2016 - 2020</div>\n <div class=\"info\">\n <p class=\"semi-bold\">SMK Sri KDU</p>\n <p>- Sijil Pelajaran Malaysia (SPM)</p>\n <p>   Results: 1A+ 1A 1C+ 1C 2D 3E 1G</p>\n </div>\n </li>\n </ul>\n </div>\n </div>\n </div>\n\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175053/"
] |
74,346,612 | <p>I am working on Cypress API and trying to get response but the problem I am facing is that I need to wait for some time for the next request until I get the response from previous one. For example, until "activated: true" and "fileType not inprogress".</p>
<pre class="lang-js prettyprint-override"><code>[
{
"filenameSource": "test",
"fileExt": "mp4",
"uniqueId": "18564Cm_BTo7Q0Sb0xCT",
"fileName": "test.mp4",
"title": "Test Video",
"language": "##",
"validFrom": "2022-10-01T00:00:00.000Z",
"rating": 0,
"aspect": "null",
"duration": -1,
"fps": 0,
"activated": false,
"fileSize": 0,
"importTime": "2022-11-07T12:14:31.813Z",
"fileType": "inprogress"
}
]
</code></pre>
<p>Please need some help to tackle such scenario. Thanks in advance!</p>
| [
{
"answer_id": 74351922,
"author": "Fody",
"author_id": 16997707,
"author_profile": "https://Stackoverflow.com/users/16997707",
"pm_score": 2,
"selected": false,
"text": "function req(attempts = 0) {\n\n if (attempts === 100) {\n throw new Error('Too many attempts')\n }\n\n cy.request('GET', ...)\n .then(resp => resp.json())\n .then(json => {\n\n const data = resp.body\n \n if (data[0].activated) {\n return // break out of the recursive loop\n }\n \n cy.wait(200)\n req(++attempts) // else recurse\n })\n}\n\ncy.request('POST', ...) // initiate product\n\nreq() // wait for activated \n\ncy.request('DELETE', ...) // now delete product\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12024752/"
] |
74,346,672 | <p>I will like to delete all empty row in a column</p>
<p>prices_dataframe[prices_dataframe['postcode'].isnull()]</p>
<p>This only seems to be showing me the empty rows not deleting it.</p>
| [
{
"answer_id": 74351922,
"author": "Fody",
"author_id": 16997707,
"author_profile": "https://Stackoverflow.com/users/16997707",
"pm_score": 2,
"selected": false,
"text": "function req(attempts = 0) {\n\n if (attempts === 100) {\n throw new Error('Too many attempts')\n }\n\n cy.request('GET', ...)\n .then(resp => resp.json())\n .then(json => {\n\n const data = resp.body\n \n if (data[0].activated) {\n return // break out of the recursive loop\n }\n \n cy.wait(200)\n req(++attempts) // else recurse\n })\n}\n\ncy.request('POST', ...) // initiate product\n\nreq() // wait for activated \n\ncy.request('DELETE', ...) // now delete product\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18815892/"
] |
74,346,678 | <p>It is possible substitute a word in a column that contains specific characters?
I would like to change the character "osa" in the set. What can I do?</p>
<pre><code>iris
iris$Species <- gsub(contains("osa"), "set", iris$Species, fixed = TRUE)
</code></pre>
| [
{
"answer_id": 74346737,
"author": "M.Viking",
"author_id": 10276092,
"author_profile": "https://Stackoverflow.com/users/10276092",
"pm_score": 2,
"selected": false,
"text": ".*"
},
{
"answer_id": 74346796,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 2,
"selected": true,
"text": "iris$Species <- as.character(iris$Species)\n\ntable(iris$Species)\n# setosa versicolor virginica \n# 50 50 50 \n\niris$Species[ grepl(\"osa\", iris$Species, fixed = TRUE) ] <- \"set\"\n\ntable(iris$Species)\n# set versicolor virginica \n# 50 50 50\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16204721/"
] |
74,346,684 | <p>I have a dictionary which has peoples' first names as keys. Each name has a capitalised first letter (James, Ben, John, etc).</p>
<p>I use list comprehension to check if any keys are in a string:</p>
<pre><code>[val for key, val in name_dict.items() if key in new_message]
</code></pre>
<p>The issue is that sometimes the names appear in new_message without capitalised first letters (james, ben, john, etc). I could add these variations to the dictionary but that sould invovle a lot of work.</p>
<p>Is there a simple way to iterate over the dictionary keys in a case insensitive way?</p>
| [
{
"answer_id": 74346739,
"author": "Guy",
"author_id": 5168011,
"author_profile": "https://Stackoverflow.com/users/5168011",
"pm_score": 2,
"selected": false,
"text": "title()"
},
{
"answer_id": 74346855,
"author": "Akash Ranjan",
"author_id": 3606723,
"author_profile": "https://Stackoverflow.com/users/3606723",
"pm_score": 2,
"selected": true,
"text": "new_message = [x.lower() for x in new_message]\n[val for key, val in name_dict.items() if key.lower() in new_message]\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16027663/"
] |
74,346,686 | <p>how to make a model have a mandatory field in the database but ignore it in swagger? I already used [JSONIGNORE] but it is still mandatory in swagger.</p>
| [
{
"answer_id": 74346739,
"author": "Guy",
"author_id": 5168011,
"author_profile": "https://Stackoverflow.com/users/5168011",
"pm_score": 2,
"selected": false,
"text": "title()"
},
{
"answer_id": 74346855,
"author": "Akash Ranjan",
"author_id": 3606723,
"author_profile": "https://Stackoverflow.com/users/3606723",
"pm_score": 2,
"selected": true,
"text": "new_message = [x.lower() for x in new_message]\n[val for key, val in name_dict.items() if key.lower() in new_message]\n"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20146067/"
] |
74,346,698 | <p>On a unix system I have a file and I need to remove all lines that would match <code>Package: <PKG_NAME></code> until an empty line is found. Here is an example, I would need to remove <code>terminfo</code> information:</p>
<pre><code>...
Package: kmod-usb-storage
Version: 5.4.218-1
Depends: kernel (= 5.4.218-1-0c02597a113d34441a9bfe9294e3fb84), kmod-scsi-core, kmod-usb-core
Status: install user installed
Architecture: mips_24kc
Installed-Time: 1667822688
Auto-Installed: yes
Package: terminfo
Version: 6.2-1
Depends: libc
Status: install user installed
Architecture: mips_24kc
Installed-Time: 1667816896
Package: libuci-lua
Version: 2020-10-06-52bbc99f-5
Depends: libc, libuci20130104, liblua5.1.5
Status: install user installed
Architecture: mips_24kc
Installed-Time: 1667816896
Auto-Installed: yes
...
</code></pre>
<p>Afterwards I need to have no information about <code>terminfo</code>:</p>
<pre><code>...
Package: kmod-usb-storage
Version: 5.4.218-1
Depends: kernel (= 5.4.218-1-0c02597a113d34441a9bfe9294e3fb84), kmod-scsi-core, kmod-usb-core
Status: install user installed
Architecture: mips_24kc
Installed-Time: 1667822688
Auto-Installed: yes
Package: libuci-lua
Version: 2020-10-06-52bbc99f-5
Depends: libc, libuci20130104, liblua5.1.5
Status: install user installed
Architecture: mips_24kc
Installed-Time: 1667816896
Auto-Installed: yes
...
</code></pre>
<p>I would be using this functionality inside a shell script, I have tried using <code>sed</code> and <code>awk</code> with no useful results, I couldn't figure out this problem.</p>
| [
{
"answer_id": 74346769,
"author": "William Pursell",
"author_id": 140750,
"author_profile": "https://Stackoverflow.com/users/140750",
"pm_score": 3,
"selected": true,
"text": " awk '!/terminfo/' RS= ORS='\\n\\n' \n"
},
{
"answer_id": 74346827,
"author": "Sundeep",
"author_id": 4082052,
"author_profile": "https://Stackoverflow.com/users/4082052",
"pm_score": 2,
"selected": false,
"text": "sed '/terminfo/,/^$/d'"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14984008/"
] |
74,346,705 | <p>I'm having data like</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>columnname</th>
<th>value</th>
<th>table</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>1</td>
<td>X</td>
</tr>
<tr>
<td>b</td>
<td>2</td>
<td>X</td>
</tr>
<tr>
<td>a</td>
<td>3</td>
<td>X</td>
</tr>
<tr>
<td>b</td>
<td>4</td>
<td>X</td>
</tr>
<tr>
<td>a</td>
<td>5</td>
<td>X</td>
</tr>
<tr>
<td>b</td>
<td>6</td>
<td>X</td>
</tr>
</tbody>
</table>
</div>
<p>and need to transform into</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>table</th>
<th>a</th>
<th>b</th>
</tr>
</thead>
<tbody>
<tr>
<td>X</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>X</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>X</td>
<td>5</td>
<td>6</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74346769,
"author": "William Pursell",
"author_id": 140750,
"author_profile": "https://Stackoverflow.com/users/140750",
"pm_score": 3,
"selected": true,
"text": " awk '!/terminfo/' RS= ORS='\\n\\n' \n"
},
{
"answer_id": 74346827,
"author": "Sundeep",
"author_id": 4082052,
"author_profile": "https://Stackoverflow.com/users/4082052",
"pm_score": 2,
"selected": false,
"text": "sed '/terminfo/,/^$/d'"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4575271/"
] |
74,346,786 | <p>I have a complete application and I'm using a custom font.</p>
<p>Is there a way to use two font families one for Text and one for numbers only?</p>
<p>Bearing in mind that the texts and numbers from API and they are mixed.</p>
| [
{
"answer_id": 74347509,
"author": "Ivo",
"author_id": 1514861,
"author_profile": "https://Stackoverflow.com/users/1514861",
"pm_score": 3,
"selected": true,
"text": "GoogleFonts"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17733339/"
] |
74,346,793 | <p>I want to store two values in an object: <code>today</code>, <code>todayInOneYear</code>. I use a function to calculate the +1 year.</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>obj = {}
today = new Date();
obj = {
today: today,
oneYear: addOneYear(today)
}
console.log(obj)
function addOneYear(date) {
date.setFullYear(date.getFullYear() + 1);
return date;
}</code></pre>
</div>
</div>
</p>
<p><strong>Problem:</strong> Today and todayInOneYear are the same. But I expect two different dates. Once from now (today) and then once from a year from now. Do you know what I'm missing?</p>
| [
{
"answer_id": 74346840,
"author": "0stone0",
"author_id": 5625547,
"author_profile": "https://Stackoverflow.com/users/5625547",
"pm_score": 3,
"selected": true,
"text": "obj = {}\ntoday = new Date();\n\nobj = {\n today: today,\n oneYear: addOneYear(today)\n}\nconsole.log(obj)\n\nfunction addOneYear(date) {\n let clone = new Date(date);\n clone.setFullYear(clone.getFullYear() + 1);\n return clone;\n}"
},
{
"answer_id": 74346901,
"author": "Syed Arsalan Hussain",
"author_id": 14733216,
"author_profile": "https://Stackoverflow.com/users/14733216",
"pm_score": 0,
"selected": false,
"text": "obj = {}\ntoday = new Date();\n\nobj = {\n today: today,\n oneYear: addOneYear(today)\n}\nconsole.log(obj)\nfunction addOneYear(date) {\n const aYearFromNow = new Date(date);\n aYearFromNow.setFullYear(aYearFromNow.getFullYear() + 1);\n console.log(aYearFromNow)\n return aYearFromNow;\n}"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14807111/"
] |
74,346,808 | <p>noob here.</p>
<p>I have a dataframe that looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>start</th>
<th>end</th>
<th>start_year</th>
</tr>
</thead>
<tbody>
<tr>
<td>NaT</td>
<td>NaT</td>
<td>2020</td>
</tr>
<tr>
<td>NaT</td>
<td>NaT</td>
<td>2021</td>
</tr>
</tbody>
</table>
</div>
<p>and I want to fill in the NaT's with the first and last day of the year listed in the start_year column. So it would look like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>start</th>
<th>end</th>
<th>start_year</th>
</tr>
</thead>
<tbody>
<tr>
<td>2020-01-01</td>
<td>2020-12-31</td>
<td>2020</td>
</tr>
<tr>
<td>2021-01-01</td>
<td>2021-12-31</td>
<td>2021</td>
</tr>
</tbody>
</table>
</div>
<p>I tried to fill in the NaTs in the 'end' column like this:</p>
<pre><code>df2.loc[df2['start'].isnull()
& df2['end'].isnull()
& df2['start_year'].notnull()
, "end"] = dt.date(df2["start_year"], 12, 31)
</code></pre>
<p>but I get this error:</p>
<pre><code>TypeError: cannot convert the series to <class 'int'>
</code></pre>
<p>When I look at just the start year column it says this:</p>
<pre><code>Name: start_year, Length: 4213, dtype: int64
</code></pre>
<p>I also tried using</p>
<pre><code>df2["start_year"].values
</code></pre>
<p>but that didn't help.</p>
<p>Apologies if I'm just being an idiot. I searched around on here and google but couldn't find an answer.</p>
| [
{
"answer_id": 74346840,
"author": "0stone0",
"author_id": 5625547,
"author_profile": "https://Stackoverflow.com/users/5625547",
"pm_score": 3,
"selected": true,
"text": "obj = {}\ntoday = new Date();\n\nobj = {\n today: today,\n oneYear: addOneYear(today)\n}\nconsole.log(obj)\n\nfunction addOneYear(date) {\n let clone = new Date(date);\n clone.setFullYear(clone.getFullYear() + 1);\n return clone;\n}"
},
{
"answer_id": 74346901,
"author": "Syed Arsalan Hussain",
"author_id": 14733216,
"author_profile": "https://Stackoverflow.com/users/14733216",
"pm_score": 0,
"selected": false,
"text": "obj = {}\ntoday = new Date();\n\nobj = {\n today: today,\n oneYear: addOneYear(today)\n}\nconsole.log(obj)\nfunction addOneYear(date) {\n const aYearFromNow = new Date(date);\n aYearFromNow.setFullYear(aYearFromNow.getFullYear() + 1);\n console.log(aYearFromNow)\n return aYearFromNow;\n}"
}
] | 2022/11/07 | [
"https://Stackoverflow.com/questions/74346808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20440058/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.