qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,311,861 | <p>I am trying to make the FlatList component show the data from students objects array. Here's my current code.</p>
<pre><code>import { Text, View, StyleSheet, TextInput, TouchableOpacity, FlatList } from 'react-native';
import {useState} from 'react';
export default function App() {
const [name, setName] = useState("");
const [age, setAge] = useState(0);
const [gender, setGender] = useState("");
const [students, setStudents] = useState([]);
const submit = () => {
setStudents(students + [
{
id: Math.floor(Math.random * 100000),
name: name,
age: age,
gender: gender
}
]);
}
return (
<View>
<Text style={styles.title}>Students List</Text>
<Text style={styles.fieldNames}>Name</Text>
<TextInput placeholder="Enter name here..." style={styles.inputField} onChangeText={(name) => setName(name)}></TextInput>
<Text style={styles.fieldNames}>Age</Text>
<TextInput placeholder="Enter age here..." style={styles.inputField} onChangeText={(age) => setAge(age)}></TextInput>
<Text style={styles.fieldNames}>Gender</Text>
<TextInput placeholder="Enter gender here..." style={styles.inputField} onChangeText={(gender) => setGender(gender)}></TextInput>
<TouchableOpacity style={styles.buttons} onPress={submit}>
<Text style={{color: 'white'}}>Submit</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.buttons}>
<Text style={{color: 'white'}}>Reset</Text>
</TouchableOpacity>
<FlatList
data={students}
renderItem={({item}) => {
<Text style={{color: 'black'}}>{item.name} {item.age} {item.gender}</Text>
}}
/>
</View>
);
}
const styles = StyleSheet.create({
title: {
fontSize: 20,
textAlign: 'center',
marginTop: 20,
fontWeight: 500
},
inputField: {
borderWidth: 2,
padding: 5,
marginLeft: 20,
marginRight: 20
},
fieldNames: {
marginLeft: 20,
marginTop: 20,
marginBottom: 5,
},
buttons: {
backgroundColor: 'blue',
paddingTop: 10,
paddingBottom: 10,
textAlign: 'center',
marginTop: 20,
marginLeft: 20,
marginRight: 20,
}
});
</code></pre>
<p>And here's the screenshot of the app till now. <a href="https://i.stack.imgur.com/CfTHv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CfTHv.png" alt="image" /></a></p>
<p>I have no clue what's going wrong and have failed to find a solution online. Can someone please help? Thank you.</p>
<p>I want the FlatList to display the data from the students objects array.</p>
| [
{
"answer_id": 74311886,
"author": "Sachila Ranawaka",
"author_id": 6428638,
"author_profile": "https://Stackoverflow.com/users/6428638",
"pm_score": 0,
"selected": false,
"text": "setStudents([...students, \n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]\n"
},
{
"answer_id": 74311888,
"author": "Vardhan",
"author_id": 18725205,
"author_profile": "https://Stackoverflow.com/users/18725205",
"pm_score": 1,
"selected": false,
"text": "setStudents([...students,\n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74311861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20413350/"
] |
74,311,890 | <p>I'm using addOrReplaceParams in rules.json, but it seems that it can only add or replace key-value pairs, but i just want modify the key name,is there any way to do this?
For example, i want to modify the param name postID to po.
<code>https://www.blogger.com/comment/frame/5235590154125226279?postID=9028051665011570908&hl=zh-CN&blogspotRpcToken=942236&parentID=7864247129676677521#</code>
And this is my rules.json, it redirect well, but i dont know how to gain the origin url postID's value 9028051665011570908</p>
<pre><code>[{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"transform": {
"queryTransform": {
"removeParams": ["postID"],
"addOrReplaceParams": [
{
"key": "po",
"value": how to gain postID's value
}
]
}
}
}
},
"condition": {
"urlFilter": "blogger.com/comment/frame",
"resourceTypes": ["main_frame"]
}
}]
</code></pre>
<p>I have read the doc below, but i cant find any solutions
<a href="https://3-72-0-dot-chrome-apps-doc.appspot.com/extensions/declarativeNetRequest" rel="nofollow noreferrer">3-72-0-dot-chrome-apps-doc.appspot.com</a>
<a href="https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#type-QueryTransform" rel="nofollow noreferrer">developer.chrome.com</a></p>
| [
{
"answer_id": 74311886,
"author": "Sachila Ranawaka",
"author_id": 6428638,
"author_profile": "https://Stackoverflow.com/users/6428638",
"pm_score": 0,
"selected": false,
"text": "setStudents([...students, \n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]\n"
},
{
"answer_id": 74311888,
"author": "Vardhan",
"author_id": 18725205,
"author_profile": "https://Stackoverflow.com/users/18725205",
"pm_score": 1,
"selected": false,
"text": "setStudents([...students,\n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74311890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20413526/"
] |
74,311,923 | <p>Recently, I came across with a problem at work.</p>
<p>A person needs to use a web service that mandatorily requires Java Applets to work.
I searched a lot and saw that those were removed from browsers because were insecure. And later on removed from Java itself.</p>
<p>I could not find a way to make it work. Downgraded it to Java 8 and even tried to use what rested from Internet Explorer (Which has Java Scripts enabled on "inetcpl.cpl").</p>
<p>Any suggetions on how to make it work?</p>
| [
{
"answer_id": 74311886,
"author": "Sachila Ranawaka",
"author_id": 6428638,
"author_profile": "https://Stackoverflow.com/users/6428638",
"pm_score": 0,
"selected": false,
"text": "setStudents([...students, \n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]\n"
},
{
"answer_id": 74311888,
"author": "Vardhan",
"author_id": 18725205,
"author_profile": "https://Stackoverflow.com/users/18725205",
"pm_score": 1,
"selected": false,
"text": "setStudents([...students,\n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74311923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16627440/"
] |
74,311,929 | <p>I have an excel sheet with 10,000 rows. Say a personal budget and expense tracker. It tracks my income and expenses on a weekly basis. I am paid every 15 days. So i want to recursively add a static row in my excel sheet for every 10 or 15 rows which looks something like this below</p>
<p>I want the income row to be repeatedly pasted (say) every 10 rows automatically. I don't want to do it manually.</p>
<p>Please advise if this can be automated.</p>
<p><a href="https://i.stack.imgur.com/nslvZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nslvZ.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74311886,
"author": "Sachila Ranawaka",
"author_id": 6428638,
"author_profile": "https://Stackoverflow.com/users/6428638",
"pm_score": 0,
"selected": false,
"text": "setStudents([...students, \n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]\n"
},
{
"answer_id": 74311888,
"author": "Vardhan",
"author_id": 18725205,
"author_profile": "https://Stackoverflow.com/users/18725205",
"pm_score": 1,
"selected": false,
"text": "setStudents([...students,\n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74311929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/146345/"
] |
74,311,967 | <p>I am having trouble trying to get my string to repeat the amount of times I want it to.</p>
<p>Here is my code, but I am not sure where I am going wrong.</p>
<pre><code>def respond_echo(input_string, number_of_echoes, spacer):
echo_output = ''
if len(input_string) > 0:
for i in range(number_of_echoes):
echo_output += (input_string+spacer) * number_of_echoes
else:
echo_output = None
return echo_output
</code></pre>
<p>respond_echo('meow', 3, '~')</p>
<pre><code>'meow~~~meow~~~meow~~~'
</code></pre>
<p>It comes out like this but I want it to look like this</p>
<pre><code>'meow~meow~meow~'
</code></pre>
| [
{
"answer_id": 74311886,
"author": "Sachila Ranawaka",
"author_id": 6428638,
"author_profile": "https://Stackoverflow.com/users/6428638",
"pm_score": 0,
"selected": false,
"text": "setStudents([...students, \n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]\n"
},
{
"answer_id": 74311888,
"author": "Vardhan",
"author_id": 18725205,
"author_profile": "https://Stackoverflow.com/users/18725205",
"pm_score": 1,
"selected": false,
"text": "setStudents([...students,\n {\n id: Math.floor(Math.random * 100000),\n name: name,\n age: age,\n gender: gender\n }\n]);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74311967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20413677/"
] |
74,311,980 | <p>I have a nginx configuration where with Lua code I want to block all domain except one(<code>example.com</code>). Since I am using Azure, I could not get just domain value from the IDToken so I am using emails(<code>ajay@example.com</code> since email also contains domain name).</p>
<p>Requirement is to block all access if the user email does not contain the string <code>example.com</code>
This is what I have so far but it does not have <strong>does not contain string</strong></p>
<pre><code>if res.id_token.email ~= 'example.com' then
ngx.exit(ngx.HTTP_FORBIDDEN)
end
</code></pre>
<p>it blocks all emails with <code>example.com</code></p>
<p>since email can be anything and its a string that should use "CONTAINS", so its failing. What will be the solution for <strong>if condition with does not contain example.com</strong></p>
| [
{
"answer_id": 74312060,
"author": "shingo",
"author_id": 6196568,
"author_profile": "https://Stackoverflow.com/users/6196568",
"pm_score": 1,
"selected": false,
"text": "@example.com"
},
{
"answer_id": 74312232,
"author": "Ajay k",
"author_id": 18333302,
"author_profile": "https://Stackoverflow.com/users/18333302",
"pm_score": 0,
"selected": false,
"text": "if not string.match(res.id_token.email, \"@example.com\") then\n ngx.exit(ngx.HTTP_FORBIDDEN)\nend\n"
},
{
"answer_id": 74315795,
"author": "LMD",
"author_id": 7185318,
"author_profile": "https://Stackoverflow.com/users/7185318",
"pm_score": 3,
"selected": true,
"text": "string.match"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74311980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18333302/"
] |
74,312,002 | <p>I have express.js controller and I can't use req.params</p>
<p>The error is <code>Property 'id' is missing in type 'ParamsDictionary' but required in type 'IParam'.</code></p>
<p>I need to get <code>id</code> from param with type string</p>
<pre class="lang-js prettyprint-override"><code>import { Request, Response } from 'express'
interface IParam {
id: string
}
const Update = (req: Request, res: Response) => {
const { id }: IParam = req.param // The error occured here
}
export default Update
</code></pre>
| [
{
"answer_id": 74312017,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "interface IParam {\n id: string\n}\n\nconst Update = (req: Request, res: Response) => {\n const { id } = req.param as unknown as IParam\n}\n\nexport default Update\n"
},
{
"answer_id": 74312037,
"author": "Phil",
"author_id": 283366,
"author_profile": "https://Stackoverflow.com/users/283366",
"pm_score": 3,
"selected": true,
"text": "req.params.id"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14813577/"
] |
74,312,025 | <p>I am working on creating a world game, and I do not want my game to accept duplicate input's by the user, ex: 'mirror'.</p>
<p>I tried finding the duplicates one way but it didn't work, and I do not know how to make my program realize that the inout is a duplicate.</p>
<p>this is my non working code:</p>
<pre><code>def checkForDuplicates(userWord):
duplicates=[]
return True
</code></pre>
<p>I tried setting this statement to true, if any duplicates where found but it didn't work, I was expecting the function to check the users word for duplicate letters, and If there are duplicates the function returns True if not the function returns False.</p>
<p>this is also python programming language</p>
<pre><code>
</code></pre>
| [
{
"answer_id": 74312017,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "interface IParam {\n id: string\n}\n\nconst Update = (req: Request, res: Response) => {\n const { id } = req.param as unknown as IParam\n}\n\nexport default Update\n"
},
{
"answer_id": 74312037,
"author": "Phil",
"author_id": 283366,
"author_profile": "https://Stackoverflow.com/users/283366",
"pm_score": 3,
"selected": true,
"text": "req.params.id"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20133439/"
] |
74,312,033 | <p>I couldn't understand how the value of m=7 after execution of program.</p>
<pre><code>void test(int m , int &n)
{
n=n-2*m;
m=2*m;
}
int main()
{
int a=7, b=12;
test(a,b);
cout << a<<b;
return 0;
}
</code></pre>
| [
{
"answer_id": 74312017,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "interface IParam {\n id: string\n}\n\nconst Update = (req: Request, res: Response) => {\n const { id } = req.param as unknown as IParam\n}\n\nexport default Update\n"
},
{
"answer_id": 74312037,
"author": "Phil",
"author_id": 283366,
"author_profile": "https://Stackoverflow.com/users/283366",
"pm_score": 3,
"selected": true,
"text": "req.params.id"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4831138/"
] |
74,312,046 | <p>This is my first time posting, apologize for the question format, I'm not sure how to edit it.</p>
<p>My question is, is it possible to call a data generated (in this case the random code for OTP) in different class, in this case from otp controller class to the email service class?</p>
<p>I'm generating an otp to be sent to email with ASP.NET Web API. So far, I created a separate class / controller to generate and save the otp, then another class to set up the email service then lastly email controller to send the email.</p>
<p>I'm generating a random code as OTP to be send directly to the database with the post method.</p>
<p>Here's the code in OTP controller</p>
<pre><code>[HttpPost]
public async Task<IActionResult> AddOTPs(Otp otp)
{
Random rand = new Random();
randomcode = (rand.Next(9999999)).ToString();
var otps = new Otp()
{
AlamatEmail = otp.AlamatEmail,
NamaKaryawan = otp.NamaKaryawan,
OTP_C = randomcode,
};
await _context.Otps.AddAsync(otps);
await _context.SaveChangesAsync();
return Ok(otps);
}
</code></pre>
<p><a href="https://i.stack.imgur.com/NkhCr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NkhCr.png" alt="enter image description here" /></a></p>
<p>In a different class, I have set up the email service to be called in email controller. Here's that code:</p>
<pre><code>public void SendEmail(Otp request)
{
var email = new MimeMessage();
email.From.Add(MailboxAddress.Parse(_config.GetSection("EmailUsername").Value));
email.To.Add(MailboxAddress.Parse(request.AlamatEmail));
email.Subject = "OTP Test";
email.Body = new TextPart(TextFormat.Html) {
Text = request.OTP_C
};
using var smtp = new SmtpClient();
smtp.Connect(_config.GetSection("EmailHost").Value, 587, SecureSocketOptions.StartTls);
smtp.Authenticate(_config.GetSection("EmailUsername").Value, _config.GetSection("EmailPassword").Value);
smtp.Send(email);
smtp.Disconnect(true);
}
</code></pre>
<p><a href="https://i.stack.imgur.com/Tg5mi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tg5mi.png" alt="enter image description here" /></a></p>
<p>Email controller code :</p>
<pre><code>[HttpPost]
public IActionResult SendEmail(Otp request)
{
_emailService.SendEmail(request);
return Ok();
}
</code></pre>
<p>Now, all of this code works well without any error, but when I have to call separate API to post the otp to the database, and then another API to send the email where I have to input both the email address and otp manually. So now the flow is like this, post otp to database api, get otp from database api, then post send email api, with total of 3 api calls.</p>
<p>My question is: how can I make sure the random code generated in OTP controller is being sent to the email service class? Or how can I make it so when the otp generated its going to be saved to database and then send the email.</p>
<p>Basically I want to make sure there's only 1-2 APIs being called instead of 3 by eliminating the get otp from database API.</p>
<p>Thank you in advance.</p>
<p>All the code is written in C# for the ASP.NET framework</p>
| [
{
"answer_id": 74312017,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "interface IParam {\n id: string\n}\n\nconst Update = (req: Request, res: Response) => {\n const { id } = req.param as unknown as IParam\n}\n\nexport default Update\n"
},
{
"answer_id": 74312037,
"author": "Phil",
"author_id": 283366,
"author_profile": "https://Stackoverflow.com/users/283366",
"pm_score": 3,
"selected": true,
"text": "req.params.id"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20413691/"
] |
74,312,051 | <p>I made an example data frame for my situation:</p>
<pre><code>df <- data.frame(ID=c(1,2,3,4), AGE1=c(25,32,29,45), AGE2=c(27,34,31,47), AGE3=c(29,36,33,49), AGE4=c(31,38,35,51), SCORE1=c(20,9,12,19), SCORE2=c(9,10,17,12), SCORE3=c(15,12,13,15), SCORE4=c(13,12,8,12))
</code></pre>
<p><a href="https://i.stack.imgur.com/txvMy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/txvMy.png" alt="enter image description here" /></a></p>
<p>The format of my data frame is longitudinal, so the age of each person increases with each response, and the corresponding scores are also recorded. AGE1 corresponds to SCORE1, AGE2 with SCORE2, etc.</p>
<p>In the end, the x-axis should be ages and the y-axis should be scores. Each row should have their own line with 4 data points.</p>
<p>I made what the data frame should look like (after the transformation). Then I can group by ID and overlay the lines onto the plot, I think:</p>
<p><a href="https://i.stack.imgur.com/nejyD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nejyD.png" alt="enter image description here" /></a></p>
<p>It seems like I would have to use pivot_longer or melt but I wasn't able to figure out how to map each age column with the score columns. Any help would be appreciated.</p>
| [
{
"answer_id": 74312017,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "interface IParam {\n id: string\n}\n\nconst Update = (req: Request, res: Response) => {\n const { id } = req.param as unknown as IParam\n}\n\nexport default Update\n"
},
{
"answer_id": 74312037,
"author": "Phil",
"author_id": 283366,
"author_profile": "https://Stackoverflow.com/users/283366",
"pm_score": 3,
"selected": true,
"text": "req.params.id"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11217654/"
] |
74,312,071 | <p>I have a table like this</p>
<p>Table name: tasks</p>
<pre><code>+---------+-------------+-------------
| Name | taskName | issueDate |
+---------+-------------+-------------
| A | AA | 4/11/2022 |
| A | AB | 4/11/2022 |
| A | AC | 4/11/2022 |
| B | BA | 3/11/2022 |
| B | BB | 3/11/2022 |
| B | BC | 3/11/2022 |
| C | CA | 2/11/2022 |
| C | CB | 2/11/2022 |
+---------+-------------+-------------
</code></pre>
<p>Resulted table will be like this</p>
<pre><code>+---------+-------------+------------
| Name | taskName | issueTime |
+---------+-------------+------------
| A | AA | 4/11/2022 |
| B | BA | 3/11/2022 |
| C | CA | 2/11/2022 |
| A | AB | 4/11/2022 |
| B | BB | 3/11/2022 |
| C | CB | 2/11/2022 |
| A | AC | 4/11/2022 |
| C | CB | 2/11/2022 |
+---------+-------------+-----------|
</code></pre>
<p>Show the unique name first according to <code>issueTime</code> in descending order.</p>
| [
{
"answer_id": 74312017,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "interface IParam {\n id: string\n}\n\nconst Update = (req: Request, res: Response) => {\n const { id } = req.param as unknown as IParam\n}\n\nexport default Update\n"
},
{
"answer_id": 74312037,
"author": "Phil",
"author_id": 283366,
"author_profile": "https://Stackoverflow.com/users/283366",
"pm_score": 3,
"selected": true,
"text": "req.params.id"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4811008/"
] |
74,312,078 | <p>I'm looking for a way to add watermark to videos in Flutter. I prefer not to use the package but if I don't have a choice, then I would use packages. Any ideas or suggestions? Thank you!</p>
| [
{
"answer_id": 74312017,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "interface IParam {\n id: string\n}\n\nconst Update = (req: Request, res: Response) => {\n const { id } = req.param as unknown as IParam\n}\n\nexport default Update\n"
},
{
"answer_id": 74312037,
"author": "Phil",
"author_id": 283366,
"author_profile": "https://Stackoverflow.com/users/283366",
"pm_score": 3,
"selected": true,
"text": "req.params.id"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15193435/"
] |
74,312,080 | <p><strong>Question:</strong></p>
<p>I have div boxes lined side by side with arrows pointing. I want to write content above the arrow using html css. How can I do that?</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> #border {
height: 80px;
width: 10%;
border: 1px black solid;
display: inline-block;
}
#borders {
height: 80px;
width: 10%;
border: 1px black solid;
display: inline-block;
}
#borderss {
height: 80px;
width: 10%;
border: 1px black solid;
display: inline-block;
}
#bordersss {
height: 80px;
width: 10%;
border: 1px black solid;
display: inline-block;
}
.arrow {
font-size: 105px;
color: red;
width:115%
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <div id="border"></div><span class="arrow">&#8594;</span>
<div id="borders"></div>
<span class="arrow">&#8594;</span>
<div id="borderss"></div>
<span class="arrow">&#8594;</span>
<div id="bordersss">
</div></code></pre>
</div>
</div>
</p>
<p><strong>Codepen link:</strong> <a href="https://codepen.io/acqafqe/pen/yLEJgVv" rel="nofollow noreferrer">https://codepen.io/acqafqe/pen/yLEJgVv</a></p>
| [
{
"answer_id": 74312162,
"author": "ChanHyeok-Im",
"author_id": 6329353,
"author_profile": "https://Stackoverflow.com/users/6329353",
"pm_score": 1,
"selected": false,
"text": ":before"
},
{
"answer_id": 74312295,
"author": "Kiandokht",
"author_id": 14876820,
"author_profile": "https://Stackoverflow.com/users/14876820",
"pm_score": 2,
"selected": false,
"text": "#border {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n}\n\n#borders {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n}\n\n#borderss {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n}\n\n#bordersss {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n}\n.arrow {\nfont-size: 105px;\ncolor: red;\nwidth:115%\n}\n.arrowTitle {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n#wrapper{\n display: flex; \n align-items: center;\n}"
},
{
"answer_id": 74312307,
"author": "Bryan Carrera",
"author_id": 20413885,
"author_profile": "https://Stackoverflow.com/users/20413885",
"pm_score": 3,
"selected": true,
"text": " #main-content {\n display: flex;\n flex-direction: row;\n align-items: center;\n }\n\n\n #border {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n }\n\n #borders {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n }\n\n #borderss {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n }\n\n #bordersss {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n }\n .arrow {\n font-size: 105px;\n color: red;\n width:100px;\n margin-top: -60px;\n }\n\n .arrow-flex {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding-top: 50px;\n }"
},
{
"answer_id": 74425796,
"author": "Jon P",
"author_id": 4665,
"author_profile": "https://Stackoverflow.com/users/4665",
"pm_score": 0,
"selected": false,
"text": "#main-content {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding-top: 50px;\n}\n\n.border {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n}\n\n#borders {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n}\n\n#borderss {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n}\n\n.bordersss {\n height: 80px;\n width: 10%;\n border: 1px black solid;\n display: inline-block;\n}\n\n.seperator {\n display: flex;\n flex-direction: column;\n align-items: center;\n height: 80px;\n padding-top: 20px;\n}\n\n.seperator::after {\n content: \"\\2192\";\n display: inline-block;\n font-size: 105px;\n color: red;\n width: 100px;\n margin-top: -60px;\n}"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20089685/"
] |
74,312,082 | <p>I am working on an Ansible task that is meant to search for a line in a file and update that line if necessary. However my task is not indempotent in that the more times I run it the more times my line addition gets added to the end of the line. How do I avoid this? Here is my task:</p>
<pre><code>- name: Enable libvirt_guest dns via nss
ansible.builtin.lineinfile:
path: /etc/nsswitch.conf
regex: ^(hosts:.*)
line: \1 libvirt_guest
backrefs: true
become: true
</code></pre>
<p>I want to be able to run this task over and over and never get libvirt_guest to appear on the line more than once. However with this task I get an extra libvirt_guest added to the end of the line every time I run the playbook that pulls in this task.</p>
| [
{
"answer_id": 74313929,
"author": "Vladimir Botka",
"author_id": 6482561,
"author_profile": "https://Stackoverflow.com/users/6482561",
"pm_score": 2,
"selected": false,
"text": "shell> cat /etc/nsswitch.conf \n# /etc/nsswitch.conf\n#\n# Example configuration of GNU Name Service Switch functionality.\n# If you have the `glibc-doc-reference' and `info' packages installed, try:\n# `info libc \"Name Service Switch\"' for information about this file.\n\npasswd: files systemd\ngroup: files systemd\nshadow: files\ngshadow: files\n\nhosts: files mdns4_minimal [NOTFOUND=return] dns mymachines\nnetworks: files\n\nprotocols: db files\nservices: db files\nethers: db files\nrpc: db files\n\nnetgroup: nis\n"
},
{
"answer_id": 74369512,
"author": "sbates-nvme",
"author_id": 20304923,
"author_profile": "https://Stackoverflow.com/users/20304923",
"pm_score": 0,
"selected": false,
"text": "- name: Check for libvirt_guest in nsswitch.conf\n ansible.builtin.lineinfile:\n path: /etc/nsswitch.conf\n regex: ^hosts:.*libvirt_guest*\n state: absent\n check_mode: true\n changed_when: false\n register: libvirt_guest\n become: false\n\n- name: Enable libvirt_guest dns via nss\n ansible.builtin.lineinfile:\n path: /etc/nsswitch.conf\n regex: ^(hosts:.*)\n line: \\1 libvirt_guest\n backrefs: true\n become: true\n when: not libvirt_guest.found\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20304923/"
] |
74,312,084 | <p>I altered a table using the command</p>
<pre><code>ALTER TABLE sys.system_property
ADD COLUMN IF NOT EXISTS description text;
COMMENT ON COLUMN sys.system_property.description IS 'description of property';
</code></pre>
<p>I then need to have a default value and set it no <code>Not NULL</code> so I did:</p>
<pre><code>ALTER TABLE sys.system_property
ADD COLUMN IF NOT EXISTS description text NOT NULL DEFAULT 'Missing Description';
COMMENT ON COLUMN sys.system_property.description IS 'description of property';
</code></pre>
<p>I added the line <code>NOT NULL DEFAULT 'Missing Description';</code> to make the column <code>Not Null</code> and have a <code>DEFAULT VALUE</code> but running this code didnt alter the table the code is skipped.</p>
<pre><code>ALTER TABLE sys.system_property
ADD COLUMN IF NOT EXISTS description text NOT NULL DEFAULT 'Missing Description'
[2022-11-04 12:02:22] [42701] column "description" of relation "system_property" already exists, skipping
</code></pre>
<p>How to alter column ?</p>
| [
{
"answer_id": 74312204,
"author": "Belayer",
"author_id": 7623856,
"author_profile": "https://Stackoverflow.com/users/7623856",
"pm_score": 2,
"selected": true,
"text": "ADD"
},
{
"answer_id": 74312369,
"author": "Yugesh Eathalapaka",
"author_id": 17634984,
"author_profile": "https://Stackoverflow.com/users/17634984",
"pm_score": 0,
"selected": false,
"text": "ALTER TABLE sys.system_property \n ALTER COLUMN price SET NOT NULL DEFAULT 'Missing Description';\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4452553/"
] |
74,312,092 | <p>I have the following scenario: I am trying to pass result of one query to another , In this case I am trying to pass view_id in another query since this are ids they are unique and cant be duplicate in any case .</p>
<pre><code>select view_id from view where view_query_id = "18711987173"
select queue_id from queue where queue_view = view_id
</code></pre>
<p>`</p>
<p>I saw some examples and I tried executing them something like as</p>
<pre><code>select view_id from view where view_query_id = "18711987173 exists (select queue_id from queue where queue_view = view.view_id)
</code></pre>
<p>But surely this didnt helped :)</p>
| [
{
"answer_id": 74312204,
"author": "Belayer",
"author_id": 7623856,
"author_profile": "https://Stackoverflow.com/users/7623856",
"pm_score": 2,
"selected": true,
"text": "ADD"
},
{
"answer_id": 74312369,
"author": "Yugesh Eathalapaka",
"author_id": 17634984,
"author_profile": "https://Stackoverflow.com/users/17634984",
"pm_score": 0,
"selected": false,
"text": "ALTER TABLE sys.system_property \n ALTER COLUMN price SET NOT NULL DEFAULT 'Missing Description';\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20413769/"
] |
74,312,096 | <p>I got <code>self.PatrolList = ko.observableArray()</code> which contains:</p>
<pre><code>//value
0: {DateAdd: 'Tuesday, 01 November 2022', sessionList: Array(2)}
1: {DateAdd: 'Wednesday, 02 November 2022', sessionList: Array(4)}
//sessionList value
Array(2)
0: "Patrol_011122168"
1: "Patrol_011122256"
</code></pre>
<p>Now, I want to display them. The problem is <code>sessionList</code> value displaying in a string:</p>
<p>View:</p>
<pre><code><div class="overflow-auto body-overflow" data-bind="foreach:PatrolList">
<div class="timeline-date" data-bind="text: DateAdd"><i class="fa fa-calendar text-success"></i></div>
<ul>
<li class="timeline-content" data-bind="text: sessionList"></li>
</ul>
</div>
</code></pre>
<p><a href="https://i.stack.imgur.com/CVvtd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CVvtd.png" alt="enter image description here" /></a></p>
<p>How do I split them by <code>(,)</code> and display vertically. What I want to achieve :</p>
<pre><code>Tuesday, 01 November 2022
-Patrol_011122168
-Patrol_011122256
</code></pre>
| [
{
"answer_id": 74312234,
"author": "whatISboolean",
"author_id": 13955999,
"author_profile": "https://Stackoverflow.com/users/13955999",
"pm_score": 0,
"selected": false,
"text": "<div class=\"overflow-auto body-overflow\" data-bind=\"foreach:PatrolList\">\n <div class=\"timeline-date\" data-bind=\"text: DateAdd\"><i class=\"fa fa-calendar text-success\"></i> 28 Dec</div>\n <ul data-bind=\"foreach: $data.sessionList\">\n <li class=\"timeline-content\" data-bind=\"text: $data\"></li>\n </ul>\n </div>\n"
},
{
"answer_id": 74312251,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 2,
"selected": true,
"text": "ul"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13955999/"
] |
74,312,145 | <p>My application has a user token and it expires after some time the user login. I got response code 401 and want to navigate to the login page, I am using dio and flutter_secure_storage to save tokens.</p>
<pre><code>else if (e.response?.statusCode == 401) {
//here I want to show the dialog box or navigate to the login page
}
print(getDioException(e));
throw Exception(getDioException(e));
}
</code></pre>
| [
{
"answer_id": 74312234,
"author": "whatISboolean",
"author_id": 13955999,
"author_profile": "https://Stackoverflow.com/users/13955999",
"pm_score": 0,
"selected": false,
"text": "<div class=\"overflow-auto body-overflow\" data-bind=\"foreach:PatrolList\">\n <div class=\"timeline-date\" data-bind=\"text: DateAdd\"><i class=\"fa fa-calendar text-success\"></i> 28 Dec</div>\n <ul data-bind=\"foreach: $data.sessionList\">\n <li class=\"timeline-content\" data-bind=\"text: $data\"></li>\n </ul>\n </div>\n"
},
{
"answer_id": 74312251,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 2,
"selected": true,
"text": "ul"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6796288/"
] |
74,312,149 | <p>Im trying to print the first character after an element that occurs in each line.</p>
<p>w.txt:</p>
<blockquote>
<p>USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT</p>
<p>osboxes tty7 :0 22:23 42:15 2.27s 0.23s
cinnamon-session --session cinnamon</p>
<p>osboxes pts/1 192.168.1.17 22:25 1:26 0.06s 0.00s nano
urandom.py</p>
<p>osboxes pts/3 192.168.1.17 22:25 1:26 0.06s 0.00s nano
urandom.py</p>
<p>osboxes pts/0 192.168.56.117 22:25 1:26 0.06s 0.00s nano
urandom.py</p>
</blockquote>
<p>f = open("w.txt", "r")
w = f.read()</p>
<pre><code>tty = (w.split('/')[1])print(tty[0])
</code></pre>
<p>The above returns the id of the first pts</p>
<blockquote>
<p>1</p>
</blockquote>
<p>but I want it to do this for every line, and return all the integers seperated by a comma
eg:</p>
<blockquote>
<p>1,3,0</p>
</blockquote>
<p>Ive tried the following but just returns every character in the line after 1 a bunch of times.</p>
<pre><code>tty = w
for line in w:
print(tty.split('/')[1])
</code></pre>
<p>thanks:)</p>
| [
{
"answer_id": 74312234,
"author": "whatISboolean",
"author_id": 13955999,
"author_profile": "https://Stackoverflow.com/users/13955999",
"pm_score": 0,
"selected": false,
"text": "<div class=\"overflow-auto body-overflow\" data-bind=\"foreach:PatrolList\">\n <div class=\"timeline-date\" data-bind=\"text: DateAdd\"><i class=\"fa fa-calendar text-success\"></i> 28 Dec</div>\n <ul data-bind=\"foreach: $data.sessionList\">\n <li class=\"timeline-content\" data-bind=\"text: $data\"></li>\n </ul>\n </div>\n"
},
{
"answer_id": 74312251,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 2,
"selected": true,
"text": "ul"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20316235/"
] |
74,312,152 | <pre><code>with open('personnages.txt') as file:
my_file = file.read()
f = my_file.split('\n\n')
final_dict = {}
for row1 in f:
data = row1.strip().split('\n')
d = {}
for row2 in data:
key, value = row2.split(':')
d[key] = value
for row3 in d:
name_dict = {}
final_dict[d['nom']] = name_dict
name_dict['genre'] = d['genre']
name_dict['accessoires'] = d['accessoires']
name_dict['cheveux'] = d['cheveux']
name_dict['yeux'] = d['yeux']
name_dict['nez'] = d['nez']
name_dict['pilosite'] = d['pilosite']
</code></pre>
<p>If I print <code>final_dict</code> likeso:</p>
<pre><code>with open('personnages.txt') as file:
my_file = file.read()
f = my_file.split('\n\n')
final_dict = {}
for row1 in f:
data = row1.strip().split('\n')
d = {}
for row2 in data:
key, value = row2.split(':')
d[key] = value
for row3 in d:
name_dict = {}
final_dict[d['nom']] = name_dict
print(final_dict)
</code></pre>
<p>it gives</p>
<pre><code>{'Alex': {}, 'Alfred': {}, 'Anita': {}, 'Anne': {}, 'Bernard': {}, 'Bill': {}, 'Charles': {}, 'Claire': {}, 'David': {}, 'Eric': {}, 'Frans': {}, 'George': {}, 'Herman': {}, 'Joe': {}, 'Maria': {}, 'Max': {}, 'Paul': {}, 'Peter': {}, 'Philip': {}, 'Richard': {}, 'Robert': {}, 'Sam': {}, 'Susan': {}, 'Tom': {}}
</code></pre>
<p>Each bracket {} contains a dictionary where the key is <code>genre</code>, <code>accessoires</code> and value whats on the right. I dont know why its not going beetween the {}.</p>
<p>I'm looking to have this in the output :</p>
<pre><code>{'Alex': {'genre': 'homme', 'nez': 'petit', 'yeux': 'bruns'},
'Alfred': {'genre': 'homme', 'nez': 'gros', 'yeux': 'bleus'},
'Anita': {'genre': 'femme', 'nez': 'petit', 'yeux': 'bleus'},
'Anne': {'genre': 'femme', 'nez': 'gros', 'yeux': 'bruns'},
'Bernard': {'genre': 'homme', 'nez': 'gros', 'yeux': 'bruns'},
'Bill': {'genre': 'homme', 'nez': 'gros', 'yeux': 'bruns'}}
</code></pre>
| [
{
"answer_id": 74317191,
"author": "John Bollinger",
"author_id": 2402272,
"author_profile": "https://Stackoverflow.com/users/2402272",
"pm_score": 0,
"selected": false,
"text": " for row3 in d:\n name_dict = {}\n final_dict[d['nom']] = name_dict\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18163991/"
] |
74,312,169 | <p>In R, I try to divide <code>n=10000</code> iid observations into <code>100</code> blocks and each block with size <code>n/100=10</code>. Then for each block I want to choose the largest value for each block as a new dataset with size <code>100</code>. How to achieve this point in R?</p>
<p>For example,</p>
<pre><code>#sample data
n<-10000
exp_data=rexp(n, 1)
</code></pre>
| [
{
"answer_id": 74312259,
"author": "njp",
"author_id": 14278409,
"author_profile": "https://Stackoverflow.com/users/14278409",
"pm_score": 0,
"selected": false,
"text": "df = data.frame(values = exp_data,\n group = floor((1:length(exp_data))/100))\n"
},
{
"answer_id": 74312387,
"author": "TarJae",
"author_id": 13321647,
"author_profile": "https://Stackoverflow.com/users/13321647",
"pm_score": 2,
"selected": true,
"text": "tidyverse"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19054522/"
] |
74,312,180 | <p>I'm trying to make a vector of pointers whose elements are pointing to vector of int elements. (I'm solving a competitive programming-like problem, that's why it sounds kinda nonsense).</p>
<p>but here's the code:</p>
<pre><code>#include <bits/stdc++.h>
using namespace std;
int ct = 0;
vector<int> vec;
vector<int*> rf;
void addRef(int n){
vec.push_back(n);
rf.push_back(&vec[ct]);
ct++;
}
int main(){
addRef(1);
addRef(2);
addRef(5);
for(int i = 0; i < ct; i++){
cout << *rf[i] << ' ';
}
cout << endl;
for(int i = 0; i < ct; i++){
cout << vec[i] << ' ';
}
}
</code></pre>
<p>When I execute the code, it's showing weird behaviour that I don't understand. The first element of rf (<code>vector<int*></code>) seems not pointing to the vec's (<code>vector<int></code>) element, where the rest of the elements are pointing to it.</p>
<p>here's the output when I run it on Dev-C++:</p>
<pre><code>1579600 2 5
1 2 5
</code></pre>
<p>When I tried to run the code <a href="https://www.programiz.com/cpp-programming/online-compiler/" rel="nofollow noreferrer">here</a>, the output is even weirder:</p>
<pre><code>1197743856 0 5
1 2 5
</code></pre>
<p>The code is intended to have same output between the first line and the second.</p>
<p>Can you guys explain why it happens? Is there any mistake in my implementation?</p>
<p>thanks</p>
| [
{
"answer_id": 74312259,
"author": "njp",
"author_id": 14278409,
"author_profile": "https://Stackoverflow.com/users/14278409",
"pm_score": 0,
"selected": false,
"text": "df = data.frame(values = exp_data,\n group = floor((1:length(exp_data))/100))\n"
},
{
"answer_id": 74312387,
"author": "TarJae",
"author_id": 13321647,
"author_profile": "https://Stackoverflow.com/users/13321647",
"pm_score": 2,
"selected": true,
"text": "tidyverse"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7434294/"
] |
74,312,214 | <p>I have the following <code>data.frame</code>:</p>
<pre><code>> mydf=data.frame(ID=LETTERS, var1=rep(c('a','b'),each=13), var2=c(rep('x',10),rep('y',12),rep('z',4)))
> mydf
ID var1 var2
1 A a x
2 B a x
3 C a x
4 D a x
5 E a x
...
</code></pre>
<p>I want to make a list with the levels of each variable.</p>
<p>Each element in the list should be associated with a <code>names</code> attribute.</p>
<p>The names should be identical to the original element. Then I would want the values changed to variable name + original element.</p>
<p>Let me show you what I mean.</p>
<p>I first turn the <code>data.frame</code> into the <code>list</code> output I want:</p>
<pre><code>> mylist=lapply(mydf, unique)
> mylist
$ID
[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S"
[20] "T" "U" "V" "W" "X" "Y" "Z"
$var1
[1] "a" "b"
$var2
[1] "x" "y" "z"
</code></pre>
<p>Now, I want to add a <code>names</code> attribute to the elements, so that names are equal to the original elements, and the new elements are the variable name plus the original elements.</p>
<p>I focus on <code>var1</code>:</p>
<pre><code>> var1_names=mylist$var1
> var1_values=paste0('var1:',mylist$var1)
> mylist$var1=var1_values
> names(mylist$var1)=var1_names
> mylist
...
$var1
a b
"var1:a" "var1:b"
...
</code></pre>
<p>See how <code>var1</code> has changed from:</p>
<pre><code>$var1
[1] "a" "b"
</code></pre>
<p>to</p>
<pre><code>$var1
a b
"var1:a" "var1:b"
</code></pre>
<p>Note the <code>names</code> attribute and how the new values have changed to include the variable name.</p>
<p>Now I would like to do the same thing for each variable in the list.</p>
<p>Is it possible to do it in a simple way with an <code>apply</code> approach and preferably base functions? Thanks!</p>
<p><strong>EDIT:</strong> The final complete output would look like this (note the <code>names</code> attribute in each variable):</p>
<pre><code>> mylist
$ID
A B C D E F G H I J
"ID:A" "ID:B" "ID:C" "ID:D" "ID:E" "ID:F" "ID:G" "ID:H" "ID:I" "ID:J"
K L M N O P Q R S T
"ID:K" "ID:L" "ID:M" "ID:N" "ID:O" "ID:P" "ID:Q" "ID:R" "ID:S" "ID:T"
U V W X Y Z
"ID:U" "ID:V" "ID:W" "ID:X" "ID:Y" "ID:Z"
$var1
a b
"var1:a" "var1:b"
$var2
x y z
"var2:x" "var2:y" "var2:z"
</code></pre>
| [
{
"answer_id": 74312512,
"author": "TarJae",
"author_id": 13321647,
"author_profile": "https://Stackoverflow.com/users/13321647",
"pm_score": 2,
"selected": false,
"text": "mydf %>% summarise(across(everything(), ~ list(str_c(cur_column(), unique(.x), sep = \":\")))) \n\n# or \n\nimap(mydf, ~ str_c(.y, unique(.x), sep = \":\"))\n"
},
{
"answer_id": 74316061,
"author": "sindri_baldur",
"author_id": 4552295,
"author_profile": "https://Stackoverflow.com/users/4552295",
"pm_score": 2,
"selected": true,
"text": "lapply(names(mydf), \\(x) paste(x, unique(mydf[[x]]), sep = \":\"))\n\n[[1]]\n [1] \"ID:A\" \"ID:B\" \"ID:C\" \"ID:D\" \"ID:E\" \"ID:F\" \"ID:G\" \"ID:H\" \"ID:I\" \"ID:J\" \"ID:K\" \"ID:L\" \"ID:M\" \"ID:N\" \"ID:O\" \"ID:P\" \"ID:Q\" \"ID:R\" \"ID:S\" \"ID:T\" \"ID:U\" \"ID:V\" \"ID:W\" \"ID:X\" \"ID:Y\" \"ID:Z\"\n\n[[2]]\n[1] \"var1:a\" \"var1:b\"\n\n[[3]]\n[1] \"var2:x\" \"var2:y\" \"var2:z\"\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2573168/"
] |
74,312,222 | <p>I am trying to figure out array and pointer relations in C and wrote a program as below:</p>
<pre><code>#include <stdio.h>
void printd(char *v[]);
int main()
{
char *lineptr[] = {"hello", "c", "world"};
printd(lineptr);
return 0;
}
void printd(char *lineptr[])
{
printf("%s\n", *lineptr++);
printf("%s\n", lineptr[0]);
}
</code></pre>
<p>After run this program, I got "hello" printed first and then "c". By the defintion in <code>main()</code>, <code>lineptr</code> is an array of pointers.</p>
<p>After passing this array name to the function, I take this array name as a pointer and operate this pointer with <code>*lineptr++</code> to dereference it in the first <code>printf</code>. In the second <code>printf</code>, I use the <code>lineptr[0]</code>, I got the string "c".</p>
<p>Intuitively, I think this should be an array and <code>lineptr[0]</code> will give us the first element (pointer) in this array. But the result is the second pointer. It seems my understanding is wrong somehow.</p>
<p>Based on the result, as a pointer, <code>lineptr</code> was increased by <code>lineptr++</code> in the first <code>printf</code>, it will move to the second element. In the second <code>printf</code>, <code>lineptr[0]</code> is actually equal to <code>*(lineptr + 0)</code>. So it will print out "c" but not "hello". Am I understand it correctly this way? Why can we not take <code>lineptr</code> as an array anymore as the definition?</p>
| [
{
"answer_id": 74312439,
"author": "Allan Wind",
"author_id": 9706,
"author_profile": "https://Stackoverflow.com/users/9706",
"pm_score": 0,
"selected": false,
"text": "*lineptr++"
},
{
"answer_id": 74313165,
"author": "Support Ukraine",
"author_id": 4386427,
"author_profile": "https://Stackoverflow.com/users/4386427",
"pm_score": 1,
"selected": false,
"text": "*(lineptr + 0)"
},
{
"answer_id": 74314532,
"author": "Lundin",
"author_id": 584518,
"author_profile": "https://Stackoverflow.com/users/584518",
"pm_score": 1,
"selected": false,
"text": "*lineptr++"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19382491/"
] |
74,312,235 | <p>I have two text files <code>eg1.txt</code> and <code>eg2.txt</code>.
I need to compare <code>eg1.txt</code> with respect to <code>eg2.txt</code> and create another file named <code>out.txt</code> .</p>
<p><code>eg1.txt:</code></p>
<pre><code>000b423573 bdbaskbjejbajbkjfsjba
00036713dc sjgdjgdgdjadgygdeg263
00123fd351 heqgrg63u1quidg87gduq
0105517f52 vgfeeyguuiduiueyruuur
</code></pre>
<p><code>eg2.txt</code></p>
<pre><code>0105517f52 vgfeeyguuiduiueyruuur
000b423573 bdbaskbjejbajbkjfsjba
7736001772 absjueui3ryhfuhuffh3u
00123fd351 heqgrg63u1quidg87gduq
</code></pre>
<p>output file <code>out.txt</code></p>
<pre><code>0105517f52 vgfeeyguuiduiueyruuur "Matching with eg1.txt"
000b423573 bdbaskbjejbajbkjfsjba "Matching with eg1.txt"
7736001772 absjueui3ryhfuhuffh3u "Not Matching with eg1.txt"
00123fd351 heqgrg63u1quidg87gduq "Matching with eg1.txt"
</code></pre>
<p>This is my current attempt:</p>
<pre><code>file_1 = None
file_2 = None
with open("eg2.txt") as fin_1:
file_1 = [line.strip() for line in fin_1.readlines()]
with open("eg1.txt") as fin_2:
file_2 = [line.strip() for line in fin_2.readlines()]
file_3 = []
for line in file_2:
if line not in file_1:
file_3.append(line)
file_3 = '\n'.join(file_3)
with open("out.txt", "w") as fout:
fout.write(file_3)
print(f"Wrote file:\n{file_3}")
</code></pre>
| [
{
"answer_id": 74312439,
"author": "Allan Wind",
"author_id": 9706,
"author_profile": "https://Stackoverflow.com/users/9706",
"pm_score": 0,
"selected": false,
"text": "*lineptr++"
},
{
"answer_id": 74313165,
"author": "Support Ukraine",
"author_id": 4386427,
"author_profile": "https://Stackoverflow.com/users/4386427",
"pm_score": 1,
"selected": false,
"text": "*(lineptr + 0)"
},
{
"answer_id": 74314532,
"author": "Lundin",
"author_id": 584518,
"author_profile": "https://Stackoverflow.com/users/584518",
"pm_score": 1,
"selected": false,
"text": "*lineptr++"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20273554/"
] |
74,312,237 | <p>I can used <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection" rel="nofollow noreferrer"><code>window.getSelection</code></a> to get selected words.</p>
<pre><code><div id="content">
<p class="todo">If you don't know, you can <a href="https://google.com">google</a></p>
</div>
<script>
let selectionObj = null;
let selectedText = "";
function getCurrentSelect() {
if (window.getSelection) {
selectionObj = window.getSelection();
selectedText = selectionObj.toString();
return {
selectText: selectedText
}
}
}
window.onload = function (){
document.body.addEventListener('mouseup', function(){
// if (selectOb) console.log(getCurrentSelect()===selectOb);
// selectOb = getCurrentSelect();
console.log('onmouseup');
console.log(getCurrentSelect());
})
}
</script>
</code></pre>
<p>if have two or more identical elements.</p>
<pre><code><div id="content">
<p class="todo">If you don't know, you can <a href="https://google.com">google</a></p>
<p class="todo">If you don't know, you can <a href="https://google.com">google</a></p>
<p class="todo">If you don't know, you can <a href="https://google.com">google</a></p>
</div>
</code></pre>
<p>how to know which element selected?</p>
<p>I want to be able to return an <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element" rel="nofollow noreferrer">element</a> object when selecting text.But I don't know what to do.</p>
| [
{
"answer_id": 74312336,
"author": "dangerousmanleesanghyeon",
"author_id": 14527497,
"author_profile": "https://Stackoverflow.com/users/14527497",
"pm_score": -1,
"selected": false,
"text": " let selectionObj = null;\n let selectedText = \"\";\n \n window.onload = function (){\n document.body.addEventListener('mouseup', function(e){\n // if (selectOb) console.log(getCurrentSelect()===selectOb);\n // selectOb = getCurrentSelect();\n\n console.log('onmouseup');\n console.log(e.target.innerText);\n })\n }"
},
{
"answer_id": 74312398,
"author": "score30",
"author_id": 12521653,
"author_profile": "https://Stackoverflow.com/users/12521653",
"pm_score": 0,
"selected": false,
"text": "window.getSelection()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18192801/"
] |
74,312,242 | <p>I'm trying to access keys from an object via a function, and if the value doesn't exist, check the next object. I understand the error, but I'm not sure how to handle this situation properly, for example allowing TS to access a missing property.</p>
<pre><code>// constants with transformed values
const firstList = { foo: "a value" }
const secondList = { bar: "another value" }
function getValue( key: keyof typeof firstList | keyof typeof secondList ) {
let val = firstList[key]
if (val != undefined) return val
return secondList[key]
}
</code></pre>
<blockquote>
<p>Element implicitly has an 'any' type because expression of type '"foo"
| "bar"' can't be used to index type '{ foo: string; }'. Property
'bar' does not exist on type '{ foo: string; }'.</p>
</blockquote>
| [
{
"answer_id": 74312277,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "function isKeyIn<K extends string, T extends object>(key: K, value: T): key is keyof T & K {\n return key in value;\n}\n\nfunction getValue( key: keyof typeof firstList | keyof typeof secondList ) {\n return isKeyIn(key, firstList) ? firstList[key] : secondList[key];\n}\n"
},
{
"answer_id": 74313630,
"author": "captain-yossarian from Ukraine",
"author_id": 8495254,
"author_profile": "https://Stackoverflow.com/users/8495254",
"pm_score": 2,
"selected": false,
"text": "// constants with transformed values\nconst firstList = { foo: \"a value\" }\nconst secondList = { bar: \"another value\" }\n\nconst isAllowedKey = <Obj extends Record<PropertyKey, unknown>>(obj: Obj, prop: PropertyKey)\n : prop is keyof Obj =>\n Object.prototype.hasOwnProperty.call(obj, prop);\n\n\nfunction getValue(key: keyof typeof firstList | keyof typeof secondList) {\n\n if (isAllowedKey(firstList, key)) {\n let val = key\n\n if (val != undefined) {\n return val\n }\n } else {\n return secondList[key]\n\n }\n\n // We should cover all pathes\n return undefined\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9115010/"
] |
74,312,276 | <p>I am trying to append some fake data to Listview.builder for category display, but i don't want get data from API, so i just create my own json in dart</p>
<pre><code>final category = {
"Table": "Category",
"Result": [
{"Name": "Pants", "id": 1, "image": "cat1.png"},
{"Name": "T Shirts", "id": 2, "image": "cat2.png"},
{"Name": "Watches", "id": 3, "image": "cat3.png"}
]
};
</code></pre>
<p>I have create two classes also</p>
<pre><code>class CategoryList {
String table;
ResultCategory result;
CategoryList(this.table, this.result);
}
class ResultCategory {
String name;
String id;
String image;
ResultCategory(this.name, this.id, this.image);
}
</code></pre>
<p>So my question is how to append this data to Listview.builder</p>
<p>What i have done is</p>
<pre><code>Future<List<CategoryList>> _getCategory() async {
final category = {
"Table": "Category",
"Result": [
{"Name": "Pants", "id": 1, "image": "cat1.png"},
{"Name": "T Shirts", "id": 2, "image": "cat2.png"},
{"Name": "Watches", "id": 3, "image": "cat3.png"}
]
};
Map<String, dynamic> caregoryRes = json.decode(category);
List<CategoryList> categorys = [];
CategoryList categoryList = CategoryList(category.Table, category["Result"]);
categorys.add(categoryList);
return categorys;
}
</code></pre>
| [
{
"answer_id": 74312277,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "function isKeyIn<K extends string, T extends object>(key: K, value: T): key is keyof T & K {\n return key in value;\n}\n\nfunction getValue( key: keyof typeof firstList | keyof typeof secondList ) {\n return isKeyIn(key, firstList) ? firstList[key] : secondList[key];\n}\n"
},
{
"answer_id": 74313630,
"author": "captain-yossarian from Ukraine",
"author_id": 8495254,
"author_profile": "https://Stackoverflow.com/users/8495254",
"pm_score": 2,
"selected": false,
"text": "// constants with transformed values\nconst firstList = { foo: \"a value\" }\nconst secondList = { bar: \"another value\" }\n\nconst isAllowedKey = <Obj extends Record<PropertyKey, unknown>>(obj: Obj, prop: PropertyKey)\n : prop is keyof Obj =>\n Object.prototype.hasOwnProperty.call(obj, prop);\n\n\nfunction getValue(key: keyof typeof firstList | keyof typeof secondList) {\n\n if (isAllowedKey(firstList, key)) {\n let val = key\n\n if (val != undefined) {\n return val\n }\n } else {\n return secondList[key]\n\n }\n\n // We should cover all pathes\n return undefined\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17934416/"
] |
74,312,280 | <p>If I needed to listen for a notification, I've always done like so:</p>
<pre><code>NotificationCenter.default.addObserver(self, selector: #selector(foo), name: UIApplication.didEnterBackgroundNotification, object: nil)
</code></pre>
<p>But if I move that line within the body of an async method, the compiler suddenly wants that line to be marked with await:</p>
<pre><code>func setup() async {
let importantStuff = await someTask()
// store my important stuff, now setup is complete
// This line won't compile without the await keyword.
// But addObserver is not even an async method
await NotificationCenter.default.addObserver(self, selector: #selector(foo), name: UIApplication.didEnterBackgroundNotification, object: nil)
// But this works fine
listen()
}
func listen() {
NotificationCenter.default.addObserver(self, selector: #selector(foo), name: UIApplication.didEnterBackgroundNotification, object: nil)
}
</code></pre>
<p><strong>Minimal Example</strong></p>
<p>This code does not compile (compiler wants to add <code>await</code> on the addObserver call).</p>
<pre><code>class Test {
func thisFailsToCompile() async {
let stuff = try! await URLSession.shared.data(from: URL(string: "https://google.com")!)
NotificationCenter.default.addObserver(self, selector: #selector(foo), name: UIApplication.didEnterBackgroundNotification, object: nil)
}
@objc func foo() {
}
}
</code></pre>
<p>What's going on here?</p>
| [
{
"answer_id": 74319691,
"author": "Rob Napier",
"author_id": 97337,
"author_profile": "https://Stackoverflow.com/users/97337",
"pm_score": 3,
"selected": true,
"text": "@MainActor"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5606659/"
] |
74,312,308 | <p>I am building a shared dataset in Power BI used for sales analysis. Our sales are either external (To customers) or internal (Between stores)</p>
<p>The business would like all measures to reflect external sales only, unless one actively filters on or uses TransactionType (internal/external) in a report.</p>
<p>I can set up a measure to do this just fine</p>
<pre><code>Invoiced Amount =
CALCULATE(
SUM(fact_sales_invoice_line[InvoicedAmount]),
'dim_transaction_type'[TransactionTypeCode] = SELECTEDVALUE(dim_transaction_type[TransactionTypeCode], "Eksternal")
)
</code></pre>
<p>the only issue I have is that when using this measure with transaction code, it does not produce the desired total</p>
<p><a href="https://i.stack.imgur.com/VmUEG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VmUEG.png" alt="enter image description here" /></a></p>
<p>What am I missing in my DAX code that will allow me to have it total the entire dataset when using transaction code in either filter or report?</p>
| [
{
"answer_id": 74319691,
"author": "Rob Napier",
"author_id": 97337,
"author_profile": "https://Stackoverflow.com/users/97337",
"pm_score": 3,
"selected": true,
"text": "@MainActor"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6366642/"
] |
74,312,314 | <p>I have a data table and I want to show it by a directed graph. My table is following:</p>
<pre><code>point,previous_point
"A","-"
"B","-"
"C","A"
"D","B"
"E","C"
"F","C"
"G","D,E"
"H","F,G"
</code></pre>
<p>And I need a graph drawn using by the above data. The graph I want is:
<a href="https://i.stack.imgur.com/3RBte.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3RBte.png" alt="enter image description here" /></a></p>
<p>I have tried with the networkx package. But the result is not good. Someone can help me improve the graph? Besides, I also want to automatically draw with input data like the above table.</p>
<pre><code>import networkx as nx
import matplotlib.pyplot as plt
G = nx.DiGraph()
G.add_edges_from(
[('Start','A'),('Start','B'),
('A','C'),('B','D'),('C','E'),('C','F'),
('D','G'),('E','G'),('F','H'),('G','H'),
('H','End')])
nx.draw(G, with_labels=True)
plt.show()
</code></pre>
| [
{
"answer_id": 74316538,
"author": "SultanOrazbayev",
"author_id": 10693596,
"author_profile": "https://Stackoverflow.com/users/10693596",
"pm_score": -1,
"selected": false,
"text": "networkx"
},
{
"answer_id": 74317072,
"author": "AveragePythonEnjoyer",
"author_id": 16293191,
"author_profile": "https://Stackoverflow.com/users/16293191",
"pm_score": 2,
"selected": false,
"text": "import matplotlib.pyplot as plt\nimport networkx as nx\nimport pydot\nfrom networkx.drawing.nx_pydot import graphviz_layout\n\nG = nx.DiGraph()\n\nG.add_edges_from(\n[('Start','A'),('Start','B'),\n('A','C'),('B','D'),('C','E'),('C','F'),\n('D','G'),('E','G'),('F','H'),('G','H'),\n('H','End')])\n\npos = graphviz_layout(G, prog=\"dot\")\nfor k,v in pos.items():\n pos[k]=(-v[1],v[0])\n\nnx.draw_networkx_nodes(G,pos = pos, node_shape = 's', node_size = 200, \n node_color = 'none', edgecolors='k')\nnx.draw_networkx_edges(G,pos = pos, \n node_shape = 's', width = 1, node_size = 200)\nnx.draw_networkx_labels(G,pos = pos, font_size = 5)\n\nplt.show()\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18158583/"
] |
74,312,363 | <p>I've tried to wrap my head around the logic of how quotes work, but I cannot find any official documentation from Microsoft that really explains this in depth. I think the logic behind this code works but of course it doesn't.
Here's my logic:
The double quotes in front of UPDATE start the string and the double quotes behind Sector ends the string. Variables and strings must be separated by an ampersand. Done. Now I need to continue the string so I wrap WHERE ID to concatenate it to the variable, and rst!ID is not a string so it needs no quotes. STILL WRONG. Please help me understand where my logic is off here? Note: test is a string variable.</p>
<p>Thank you!</p>
<pre><code>DoCmd.RunSQL "UPDATE MyTable SET MyField = 'Sector'" & test & "WHERE ID =" rst!ID
</code></pre>
| [
{
"answer_id": 74313632,
"author": "Max",
"author_id": 2760773,
"author_profile": "https://Stackoverflow.com/users/2760773",
"pm_score": 1,
"selected": false,
"text": "DoCmd.RunSQL \"UPDATE MyTable SET MyField = 'Sector\" & test & \"' WHERE ID =\" rst!ID\n"
},
{
"answer_id": 74314002,
"author": "mikasa",
"author_id": 17953147,
"author_profile": "https://Stackoverflow.com/users/17953147",
"pm_score": 0,
"selected": false,
"text": "DoCmd.RunSQL \"UPDATE [MyTable] a SET [MyField] = 'Sector\" & test & \"' WHERE a.[ID] =\"& rst!ID\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13282145/"
] |
74,312,365 | <p>I don't understand. I wrote a "hello world" program and run it, console only shows up immediately and turns itself off. <a href="https://i.stack.imgur.com/ytyyn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ytyyn.png" alt="I enter 5 case in console, but when i press "5", ENTER, the console not printing the fifth case, it's turn off :>" /></a>
You guys can help me please
<a href="https://i.stack.imgur.com/UZCpM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UZCpM.png" alt="This is my launch.json" /></a></p>
<p>I want to use vscode console to input the result then print it with the line "press any key to countinue" like DevC++. I want it to not turn itself off when I haven't entered all the cases</p>
| [
{
"answer_id": 74313632,
"author": "Max",
"author_id": 2760773,
"author_profile": "https://Stackoverflow.com/users/2760773",
"pm_score": 1,
"selected": false,
"text": "DoCmd.RunSQL \"UPDATE MyTable SET MyField = 'Sector\" & test & \"' WHERE ID =\" rst!ID\n"
},
{
"answer_id": 74314002,
"author": "mikasa",
"author_id": 17953147,
"author_profile": "https://Stackoverflow.com/users/17953147",
"pm_score": 0,
"selected": false,
"text": "DoCmd.RunSQL \"UPDATE [MyTable] a SET [MyField] = 'Sector\" & test & \"' WHERE a.[ID] =\"& rst!ID\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20318871/"
] |
74,312,366 | <p>I've two tables tblOrder and tblOrderDetails. I want to get order no, total price per order (Quantity*UnitCost) and OrderDate as given below.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Order No</th>
<th>Total</th>
<th>OrderDate</th>
</tr>
</thead>
<tbody>
<tr>
<td>ORD 1</td>
<td>3000</td>
<td>01/01/2021</td>
</tr>
<tr>
<td>ORD 2</td>
<td>2750</td>
<td>01/03/2021</td>
</tr>
</tbody>
</table>
</div>
<p><strong>What I've tried is giving me quantity is not a part of aggregate function.</strong></p>
<p>SELECT tblOrder.OrderNo, tblOrderDetails.UnitCost*tblOrderDetails.Quantity AS Total, OrderDate
FROM tblOrderDetails INNER JOIN tblOrder ON tblOrderDetails.OrderId = tblOrder .OrderId
GROUP BY tblOrder.OrderNo;</p>
<p>Table structures and data</p>
<p>Table tblOrder:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>OrderId</th>
<th>OrderNo</th>
<th>OrderDate</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>ORD 1</td>
<td>01/01/2021</td>
</tr>
<tr>
<td>2</td>
<td>ORD 2</td>
<td>01/03/2021</td>
</tr>
</tbody>
</table>
</div>
<p>Table tblOrderDetails:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>OrderDetailId</th>
<th>Quantity</th>
<th>UnitCost</th>
<th>OrderId</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>100</td>
<td>30</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>50</td>
<td>40</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>10</td>
<td>15</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>20</td>
<td>30</td>
<td>2</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74313632,
"author": "Max",
"author_id": 2760773,
"author_profile": "https://Stackoverflow.com/users/2760773",
"pm_score": 1,
"selected": false,
"text": "DoCmd.RunSQL \"UPDATE MyTable SET MyField = 'Sector\" & test & \"' WHERE ID =\" rst!ID\n"
},
{
"answer_id": 74314002,
"author": "mikasa",
"author_id": 17953147,
"author_profile": "https://Stackoverflow.com/users/17953147",
"pm_score": 0,
"selected": false,
"text": "DoCmd.RunSQL \"UPDATE [MyTable] a SET [MyField] = 'Sector\" & test & \"' WHERE a.[ID] =\"& rst!ID\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11178760/"
] |
74,312,392 | <p>I have a string, it looks like a array but not a real array. So my question is how to make it to a real array.</p>
<pre><code>let string = "["abc", "cde"]";
// how to make string become an array
</code></pre>
<p>change string to an array</p>
| [
{
"answer_id": 74312525,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 1,
"selected": false,
"text": "\"[\"abc\", \"cde\"]\" // invalid\n\"[abc, cde]\" // invalid\n\"[11, 22]\" // valid,if you do not want to use quote to wrap it,then the elements need to be number\n\"['abc', 'cde']\" // valid\n"
},
{
"answer_id": 74312551,
"author": "RA17H45M40S",
"author_id": 14906909,
"author_profile": "https://Stackoverflow.com/users/14906909",
"pm_score": 1,
"selected": true,
"text": "let data = \"['abc', 'pqr', 'xxx']\";\ndata = data.replace(/'/g, '\"');\nconsole.log(data)\nconst convertedArray = JSON.parse(data);\nconsole.log(convertedArray)"
},
{
"answer_id": 74312757,
"author": "Rohìt Jíndal",
"author_id": 4116300,
"author_profile": "https://Stackoverflow.com/users/4116300",
"pm_score": 0,
"selected": false,
"text": "let string = \"[\\\"abc\\\", \\\"cde\\\"]\";\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414069/"
] |
74,312,403 | <p>So I made this login in form for a practice but i ran into a problem when creating the button at a smaller screen it cases the entire form to animate a little and i dont know why i tried putting transition none on @media query I made for wider screen size and tried putting the transition none
on it but it did not work i even tried putting it on the container it self but it did not work.</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>* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 65.5%;
font-family: 'Times New Roman', Times, serif;
}
body {
line-height: 1.4;
font-size: 1.5rem;
}
.learn {
display: grid;
place-items: center;
grid-template-columns: 1fr;
height: 100vh;
}
@media(min-width:85rem) {
.learn .bg-color-container {
max-width: 40rem;
width: 100%;
}
.bg-color-container button {
max-width: 100%;
width: 420px;
padding: 2rem 0;
}
}
form .input__data {
display: flex;
flex-direction: column;
padding: 1rem 0;
position: relative;
top: -2.1rem;
width: 100%;
}
.bg-color-container {
background-color: rgb(236, 244, 243);
width: 100%;
max-width: 400px;
padding: 5rem 1.8rem;
border-radius: 1.2rem;
box-shadow: 0 8px 8px 5px rgb(0, 0, 0, 0.5);
}
.dec-adder h1 {
position: relative;
top: -3rem;
max-width: 250px;
font-size: 3.1rem;
}
input {
padding: 1.2rem;
margin-top: .4rem;
}
[type=email],
[type=password] {
background: #ffffff;
border: none;
border-radius: .5rem;
}
.separate-content {
position: relative;
top: -2.1rem;
}
.separate-content input {
margin-right: 0.5rem;
font-weight: bolder;
}
form button {
max-width: 100%;
width: 320px;
padding: 1.5rem 0;
border-radius: 1rem;
border: none;
background: #fff;
transition: 2s ease-in;
cursor: pointer;
color: black;
}
form button:hover {
background-color: #7c47c0;
color: #fff;
}
form label {
font-weight: bold;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><section class="learn">
<div class="bg-color-container dec-adder">
<h1>Sign in with your credentials</h1>
<form action="#" method="post">
<div class="input__data">
<label for="Email">Email Address</label>
<input type="email" name="email" id="Email" autofocus required placeholder="Your Address">
</div>
<div class="input__data">
<label for="lg-password">Enter Passward</label>
<input type="password" name="Security-Passcode" id="lg-password" required>
</div>
<label class="separate-content" for="lg-remember">
<input type="checkbox" name="lg-remember" id="lg-remember" required> Remember Me
</label>
<div><button type="submit ">Sign Up</button></div>
</form>
</div>
</section></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74312546,
"author": "Saad1430",
"author_id": 19199222,
"author_profile": "https://Stackoverflow.com/users/19199222",
"pm_score": 1,
"selected": false,
"text": "max-width: 600px"
},
{
"answer_id": 74313629,
"author": "John",
"author_id": 11111119,
"author_profile": "https://Stackoverflow.com/users/11111119",
"pm_score": 3,
"selected": true,
"text": "padding: 2rem 0;"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17958243/"
] |
74,312,449 | <p>How to write 4th , 5th as a string in the way that we write in the paper by using dart ?</p>
<p>I tried but couldn't get the answer.</p>
<p><a href="https://i.stack.imgur.com/i1bKq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i1bKq.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/Nadzw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nadzw.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74312638,
"author": "Himani",
"author_id": 18416001,
"author_profile": "https://Stackoverflow.com/users/18416001",
"pm_score": 2,
"selected": false,
"text": "RichText(\n text: TextSpan(children: [\n TextSpan(\n text: 'The 4',\n style: TextStyle(color: Colors.white)),\n WidgetSpan(\n child: Transform.translate(\n offset: const Offset(2, -4),\n child: Text(\n 'th',\n //superscript is usually smaller in size\n textScaleFactor: 0.7,\n style: TextStyle(color: Colors.white),\n ),\n ),\n )\n ]),\n ),\n"
},
{
"answer_id": 74312864,
"author": "Krish Bhanushali",
"author_id": 13220817,
"author_profile": "https://Stackoverflow.com/users/13220817",
"pm_score": 1,
"selected": true,
"text": "Text(\n '4th',\n style: TextStyle(\n fontFeatures: [\n FontFeature.enable('sups'),\n ],\n ),\n ),\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17901892/"
] |
74,312,460 | <p>Here's my code.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let mapOptions = []
let mapOption = {}
let averagelist=[1,2]
for(let i=0; i<averagelist.length; i++){
mapOption.center = averagelist[i]
mapOption.level = 3
mapOptions.push(mapOption)
console.log(mapOptions)
}</code></pre>
</div>
</div>
</p>
<p>In the Snippet the result comes like strange so I'll tell you what I got.
From that code I wanted to get <code>mapOptions=[{"center":1,"level":3},{"center":2,"level":3}]</code>
But the result comes like mapOptions=<code>[{"center":2,"level":3},{"center":2,"level":3}]</code>
Where did the 1 go? I tried lots of things but can't solve this.
Could anybody help me? The browser I'm using is Chrome.</p>
| [
{
"answer_id": 74312489,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 1,
"selected": false,
"text": "let averagelist = [1,2];\nlet mapOptions = averagelist.map(i=>({center: i, level: 3}));\nconsole.log(mapOptions);"
},
{
"answer_id": 74312492,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 0,
"selected": false,
"text": "let mapOption = {}"
},
{
"answer_id": 74312531,
"author": "Rohìt Jíndal",
"author_id": 4116300,
"author_profile": "https://Stackoverflow.com/users/4116300",
"pm_score": 1,
"selected": true,
"text": "let mapOptions = []\nlet mapOption = {}\n\nlet averagelist = [1, 2];\n\nfor(let i=0; i< averagelist.length; i++){\n mapOption = {center: averagelist[i], level: 3}\n mapOptions.push(mapOption)\n}\n\nconsole.log(mapOptions)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16616376/"
] |
74,312,470 | <p>I would like to know the way to activate and underline a specific tab/item in the Nav Bar when a button <strong>outside the Nav Bar</strong> is clicked in ReactJS</p>
<p>Currently, this is what I did to activate and underline the item in the Nav Bar when a Nav Bar item is clicked.</p>
<p>Navbar.jsx</p>
<pre><code><Navbar bg="light" variant="light" sticky="top">
<Container fluid>
<Navbar.Brand href="home" style={{ width: "20%" }}>
<img
className="logo"
src="/images/logo.png"
width={50}
height={50}
alt=""
style={{
margin: "auto",
display: "flex",
justifyContent: "center",
}}
/>
</Navbar.Brand>
<Nav style={{ width: "100%", justifyContent: "space-evenly" }}>
<Nav.Link
className="navLink"
style={{ width: "20%", textAlign: "center" }}
onClick={() => {
navigate("/home");
sessionStorage.setItem("navItem", "home");
}}
>
<span
style={
sessionStorage.getItem("navItem") === "home"
? { borderBottom: "2px solid #FFC0CB" }
: {}
}
>
Home
</span>
</Nav.Link>
<Nav.Link
className="navLink"
style={{ width: "20%", textAlign: "center" }}
onClick={() => {
navigate("/booking");
sessionStorage.setItem("navItem", "booking");
}}
>
<span
style={
sessionStorage.getItem("navItem") === "booking"
? { borderBottom: "2px solid #FFC0CB" }
: {}
}
>
Booking
</span>
</Nav.Link>
</Nav>
</Container>
</Navbar>
</code></pre>
<p>I was wondering how it should be done in a case where I have a button somewhere in the Body. For example, a "Manage Booking" button, so when I click that button, it should activate and underline the "Booking" item in the Nav Bar. Currently, when clicking the "Manage Booking" button, it navigates to the Booking page but the "Home" item in the Nav bar is still underlined.</p>
<pre><code> <button
className="bookingBtn"
onClick={() => navigate("/booking")}>
Manage Booking
</button>
</code></pre>
| [
{
"answer_id": 74312489,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 1,
"selected": false,
"text": "let averagelist = [1,2];\nlet mapOptions = averagelist.map(i=>({center: i, level: 3}));\nconsole.log(mapOptions);"
},
{
"answer_id": 74312492,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 0,
"selected": false,
"text": "let mapOption = {}"
},
{
"answer_id": 74312531,
"author": "Rohìt Jíndal",
"author_id": 4116300,
"author_profile": "https://Stackoverflow.com/users/4116300",
"pm_score": 1,
"selected": true,
"text": "let mapOptions = []\nlet mapOption = {}\n\nlet averagelist = [1, 2];\n\nfor(let i=0; i< averagelist.length; i++){\n mapOption = {center: averagelist[i], level: 3}\n mapOptions.push(mapOption)\n}\n\nconsole.log(mapOptions)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18082984/"
] |
74,312,500 | <p>I have a <code>QWidget</code> containing some buttons and others <code>QWidgets</code>, how do I make a stylesheet applied to the <code>QWidget</code> <strong>parent</strong> to affect <strong>only</strong> her <code>QWidget</code> children?</p>
<p>Some options I tried:</p>
<pre><code>QWidget[objectName!="widget_1"] {
max-width: 200;
max-height: 200;
}
QWidget > QWidget {
max-width: 200;
max-height: 200;
}
QWidget QWidget {
max-width: 200;
max-height: 200;
}
</code></pre>
<p>In all options, the style is also applied to the parent.</p>
<p>I was reading the Selector Types: <a href="https://doc.qt.io/qt-6/stylesheet-syntax.html#selector-types" rel="nofollow noreferrer">https://doc.qt.io/qt-6/stylesheet-syntax.html#selector-types</a></p>
<p>but I still couldn't figure out how to do it.</p>
| [
{
"answer_id": 74312489,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 1,
"selected": false,
"text": "let averagelist = [1,2];\nlet mapOptions = averagelist.map(i=>({center: i, level: 3}));\nconsole.log(mapOptions);"
},
{
"answer_id": 74312492,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 0,
"selected": false,
"text": "let mapOption = {}"
},
{
"answer_id": 74312531,
"author": "Rohìt Jíndal",
"author_id": 4116300,
"author_profile": "https://Stackoverflow.com/users/4116300",
"pm_score": 1,
"selected": true,
"text": "let mapOptions = []\nlet mapOption = {}\n\nlet averagelist = [1, 2];\n\nfor(let i=0; i< averagelist.length; i++){\n mapOption = {center: averagelist[i], level: 3}\n mapOptions.push(mapOption)\n}\n\nconsole.log(mapOptions)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19325180/"
] |
74,312,504 | <p>I have a column in my dataset consisting of lists of strings like below:</p>
<p>column</p>
<p>['tablet', 'mobile', 'man']</p>
<p>['people', 'house']</p>
<p>. . .</p>
<p>['people', 'computer']</p>
<p>['computer', 'laptop']</p>
<p>How can I get a list of lists with the elements of this column? I want the output like this:</p>
<p>[['tablet', 'mobile', 'man'],['people', 'house'],. . .,['people', 'computer'],['computer', 'laptop']]</p>
| [
{
"answer_id": 74312545,
"author": "Faisal Nazik",
"author_id": 13959139,
"author_profile": "https://Stackoverflow.com/users/13959139",
"pm_score": 0,
"selected": false,
"text": "df"
},
{
"answer_id": 74313756,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74326862,
"author": "theabc50111",
"author_id": 13874745,
"author_profile": "https://Stackoverflow.com/users/13874745",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\nresult_list = []\n\ndf = pd.read_csv(\"file_name\")\nseries_1 = df.loc[::, \"column_name\"]\n\nfor s in series_1:\n list1 = s.strip(\"[]\").replace(\" \", \"\").replace(\"'\", \"\").split(\",\")\n result_list.append(s)\n\nprint(result_list)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5251558/"
] |
74,312,505 | <p>I am familar with excel but still quite new to VBAs.
I have a report with multiple sheets that i want to export a specific range and save the files into seperate CSV files.</p>
<p>I have been able to export the and save the files with the below code. Now i want to add the code to export the sheets with the range("E6:V100").</p>
<p>How can i add this in with my below code.</p>
<p>Any help is appreciated.</p>
<pre><code>
Option Explicit
Sub WriteCSVs()
Dim mySheet As Worksheet
Dim myPath As String
myPath = SelectFolder
Application.DisplayAlerts = False
For Each mySheet In ActiveWorkbook.Worksheets
If mySheet.Visible = xlSheetVisible Then
'MsgBox CStr(mySheet.Visible)
ActiveWorkbook.Sheets(mySheet.Index).Copy
'ActiveWorkbook.SaveAs Filename:=myPath & mySheet.Name, FileFormat:=xlCSV, CreateBackup:=True
ActiveWorkbook.SaveAs Filename:=myPath & mySheet.Range("B2"), FileFormat:=xlCSV
ActiveWorkbook.Close
End If
Next mySheet
Application.DisplayAlerts = True
End Sub
Function SelectFolder() As String
Dim FldrPicker As FileDialog
Dim myFolder As String
'Have User Select Folder to Save to with Dialog Box
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)
With FldrPicker
.Title = "Select A Target Folder"
.AllowMultiSelect = False
If .Show <> -1 Then Exit Function
SelectFolder = .SelectedItems(1) & "\"
End With
End Function
</code></pre>
| [
{
"answer_id": 74312545,
"author": "Faisal Nazik",
"author_id": 13959139,
"author_profile": "https://Stackoverflow.com/users/13959139",
"pm_score": 0,
"selected": false,
"text": "df"
},
{
"answer_id": 74313756,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74326862,
"author": "theabc50111",
"author_id": 13874745,
"author_profile": "https://Stackoverflow.com/users/13874745",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\nresult_list = []\n\ndf = pd.read_csv(\"file_name\")\nseries_1 = df.loc[::, \"column_name\"]\n\nfor s in series_1:\n list1 = s.strip(\"[]\").replace(\" \", \"\").replace(\"'\", \"\").split(\",\")\n result_list.append(s)\n\nprint(result_list)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13574039/"
] |
74,312,506 | <p>I can use <code>svn update -r 1000</code> to update to revision 1000, but if I submitted a file in r1001 it will roll back my file to revision 1000. How can I update to a specific revision without making any of my files go back in time?</p>
<p>I have a build system that's generating an exe for my project. I wrote a script to download the exe and svn update to the revision the exe was built on. But it rolls back people's work if they run the script right after submitting.</p>
| [
{
"answer_id": 74312545,
"author": "Faisal Nazik",
"author_id": 13959139,
"author_profile": "https://Stackoverflow.com/users/13959139",
"pm_score": 0,
"selected": false,
"text": "df"
},
{
"answer_id": 74313756,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74326862,
"author": "theabc50111",
"author_id": 13874745,
"author_profile": "https://Stackoverflow.com/users/13874745",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\nresult_list = []\n\ndf = pd.read_csv(\"file_name\")\nseries_1 = df.loc[::, \"column_name\"]\n\nfor s in series_1:\n list1 = s.strip(\"[]\").replace(\" \", \"\").replace(\"'\", \"\").split(\",\")\n result_list.append(s)\n\nprint(result_list)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79125/"
] |
74,312,520 | <p>I got following error whie executing the code.</p>
<p>Code:install.packages("ithir", repos="http://R-Forge.R-project.org")</p>
<p>Error:</p>
<pre><code>WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/cloud-user/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
installing the source package ‘ithir’
trying URL 'http://R-Forge.R-project.org/src/contrib/ithir_1.0.tar.gz'
Content type 'application/x-gzip' length 4534681 bytes (4.3 MB)
downloaded 4.3 MB
* installing *source* package 'ithir' ...
** using staged installation
** R
** data
** byte-compile and prepare package for lazy loading
Error: objects 'ripras', 'as.ppp', 'delaunay' are not exported by 'namespace:spatstat'
Execution halted
ERROR: lazy loading failed for package 'ithir'
* removing 'C:/Users/cloud-user/AppData/Local/R/win-library/4.2/ithir'
Warning in install.packages :
installation of package ‘ithir’ had non-zero exit status
</code></pre>
<p>I was trying to install a package ithir.</p>
| [
{
"answer_id": 74312545,
"author": "Faisal Nazik",
"author_id": 13959139,
"author_profile": "https://Stackoverflow.com/users/13959139",
"pm_score": 0,
"selected": false,
"text": "df"
},
{
"answer_id": 74313756,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74326862,
"author": "theabc50111",
"author_id": 13874745,
"author_profile": "https://Stackoverflow.com/users/13874745",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\nresult_list = []\n\ndf = pd.read_csv(\"file_name\")\nseries_1 = df.loc[::, \"column_name\"]\n\nfor s in series_1:\n list1 = s.strip(\"[]\").replace(\" \", \"\").replace(\"'\", \"\").split(\",\")\n result_list.append(s)\n\nprint(result_list)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20228112/"
] |
74,312,543 | <p><code>while party!='R' and party!='D':</code></p>
<p>can this be shortened to</p>
<p><code>while party!='R' and 'D':</code></p>
<p><code>while party!=('R' and 'D'):</code></p>
<p>or the like? (that is, is there any equivalent expression with only one party!=)</p>
| [
{
"answer_id": 74312545,
"author": "Faisal Nazik",
"author_id": 13959139,
"author_profile": "https://Stackoverflow.com/users/13959139",
"pm_score": 0,
"selected": false,
"text": "df"
},
{
"answer_id": 74313756,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74326862,
"author": "theabc50111",
"author_id": 13874745,
"author_profile": "https://Stackoverflow.com/users/13874745",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\nresult_list = []\n\ndf = pd.read_csv(\"file_name\")\nseries_1 = df.loc[::, \"column_name\"]\n\nfor s in series_1:\n list1 = s.strip(\"[]\").replace(\" \", \"\").replace(\"'\", \"\").split(\",\")\n result_list.append(s)\n\nprint(result_list)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13710962/"
] |
74,312,560 | <p><a href="https://i.stack.imgur.com/7hFZn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7hFZn.png" alt="enter image description here" /></a></p>
<p>as you can see in the above images I am make two different screens in .kv files
so suppose I have more screens and I don't want to make mess in the same .kv files
so like is there a way we can write these aboutScreen and HomeScreen in different .kv file and than
import it to one .kv file for code modularization.</p>
<p>I tried to directly import the files but seems it doesn't work like that ?
<a href="https://i.stack.imgur.com/2A9x4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2A9x4.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74312545,
"author": "Faisal Nazik",
"author_id": 13959139,
"author_profile": "https://Stackoverflow.com/users/13959139",
"pm_score": 0,
"selected": false,
"text": "df"
},
{
"answer_id": 74313756,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74326862,
"author": "theabc50111",
"author_id": 13874745,
"author_profile": "https://Stackoverflow.com/users/13874745",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\nresult_list = []\n\ndf = pd.read_csv(\"file_name\")\nseries_1 = df.loc[::, \"column_name\"]\n\nfor s in series_1:\n list1 = s.strip(\"[]\").replace(\" \", \"\").replace(\"'\", \"\").split(\",\")\n result_list.append(s)\n\nprint(result_list)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20409888/"
] |
74,312,563 | <pre><code>@extends('master') @section("content") <h1>Upload</h1> <form action="upload" method="POST" enctype="multipart/form-data">
@csrf
<div class="form-group">
<label>Name</label>
<input type="name" name="name" class="form-control" placeholder="Enter Name">
</div>
<div class="form-group">
<label>Price</label>
<input type="price" name="price" class="form-control" placeholder="Enter price">
</div>
<label>Category</label>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Choose
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Item</a>
<br><a class="dropdown-item" href="#">Diamond</a>
<br><a class="dropdown-item" href="#">Akun</a>
</div>
</div>
</div>
<div>
<input type="file" name="file"><br><br></div>
<div>
<button type="submit"> Sell Item</button>
</div> </form> @endsection ```
</code></pre>
<pre><code>function upload(Request $req)
{
$products = new Product;
$products->name=$req->name;
$products->price=$req->price;
$products = $req->file('file')->store('Products');
$req->product()->upload([
'file'=> $products
]);
return redirect ('/');
} ```
</code></pre>
<p>i cannot upload it to database. its says</p>
<blockquote>
<p>BadMethodCallException
Method Illuminate\Http\Request::product does not exist.</p>
</blockquote>
<p>i want upload from form to database. before im using product database with seeder</p>
| [
{
"answer_id": 74314634,
"author": "Nathan Mwamba",
"author_id": 15436605,
"author_profile": "https://Stackoverflow.com/users/15436605",
"pm_score": 0,
"selected": false,
"text": "<form method=\"POST\" action=\"/upload\" enctype=\"multipart/form-data\">\n @csrf\n <div class=\"form-group\">\n <label>Name</label>\n <input type=\"name\" name=\"name\" class=\"form-control\" placeholder=\"Enter Name\">\n </div>\n <div class=\"form-group\">\n <label>Price</label>\n <input type=\"price\" name=\"price\" class=\"form-control\" placeholder=\"Enter price\">\n </div>\n <label>Category</label>\n <div class=\"dropdown\">\n <button class=\"btn btn-secondary dropdown-toggle\" type=\"button\" id=\"dropdownMenuButton\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n Choose\n </button>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownMenuButton\">\n <a class=\"dropdown-item\" href=\"#\">Item</a>\n <br><a class=\"dropdown-item\" href=\"#\">Diamond</a>\n <br><a class=\"dropdown-item\" href=\"#\">Akun</a>\n </div>\n </div>\n </div>\n <div>\n <input type=\"file\" name=\"file\"><br><br></div>\n <div>\n <button type=\"submit\"> Sell Item</button>\n </div>\n </form>\n"
},
{
"answer_id": 74317143,
"author": "Amit Kumar",
"author_id": 20379294,
"author_profile": "https://Stackoverflow.com/users/20379294",
"pm_score": 0,
"selected": false,
"text": "public function upload(Request $request){\n $products = new Product;\n $products->name = $request->name;\n $products->price = $request->price;\n\n if ($request->file('file')) {\n $file = $request->file('file');\n $path = public_path() . '/uploads';\n $filename = time() . '_' . $file->getClientOriginalName();\n if ($file->move($path, $filename)) {\n $products->file= $filename;\n } \n } \n\n $products->save(); \n return redirect('/');\n}\n"
},
{
"answer_id": 74372895,
"author": "kaamrul",
"author_id": 10418084,
"author_profile": "https://Stackoverflow.com/users/10418084",
"pm_score": 1,
"selected": false,
"text": "use Illuminate\\Http\\Request;\npublic function upload(Request $request){\n $request->validate([\n 'file' => 'required|mimes:csv,txt,,xlx,xls,pdf|max:2048'\n ]);\n $products = new Product;\n $products->name = $request->name;\n $products->price = $request->price;\n\n if ($request->file('file')) {\n $fileName = time().'.'.$request->file->extension();\n $request->file->move(public_path('/upload'), $fileName);\n $products->file= $filename;\n } \n\n $products->save(); \n return redirect('/');\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414188/"
] |
74,312,585 | <p>There is a String variable that comes value like the following.</p>
<pre><code>"COMPANY=10^INVOICE_ID=100021^"
</code></pre>
<p>I need to get this into two variables like Company and InvoieId.</p>
<p>What will be possible ways to do that JS?</p>
| [
{
"answer_id": 74314634,
"author": "Nathan Mwamba",
"author_id": 15436605,
"author_profile": "https://Stackoverflow.com/users/15436605",
"pm_score": 0,
"selected": false,
"text": "<form method=\"POST\" action=\"/upload\" enctype=\"multipart/form-data\">\n @csrf\n <div class=\"form-group\">\n <label>Name</label>\n <input type=\"name\" name=\"name\" class=\"form-control\" placeholder=\"Enter Name\">\n </div>\n <div class=\"form-group\">\n <label>Price</label>\n <input type=\"price\" name=\"price\" class=\"form-control\" placeholder=\"Enter price\">\n </div>\n <label>Category</label>\n <div class=\"dropdown\">\n <button class=\"btn btn-secondary dropdown-toggle\" type=\"button\" id=\"dropdownMenuButton\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n Choose\n </button>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownMenuButton\">\n <a class=\"dropdown-item\" href=\"#\">Item</a>\n <br><a class=\"dropdown-item\" href=\"#\">Diamond</a>\n <br><a class=\"dropdown-item\" href=\"#\">Akun</a>\n </div>\n </div>\n </div>\n <div>\n <input type=\"file\" name=\"file\"><br><br></div>\n <div>\n <button type=\"submit\"> Sell Item</button>\n </div>\n </form>\n"
},
{
"answer_id": 74317143,
"author": "Amit Kumar",
"author_id": 20379294,
"author_profile": "https://Stackoverflow.com/users/20379294",
"pm_score": 0,
"selected": false,
"text": "public function upload(Request $request){\n $products = new Product;\n $products->name = $request->name;\n $products->price = $request->price;\n\n if ($request->file('file')) {\n $file = $request->file('file');\n $path = public_path() . '/uploads';\n $filename = time() . '_' . $file->getClientOriginalName();\n if ($file->move($path, $filename)) {\n $products->file= $filename;\n } \n } \n\n $products->save(); \n return redirect('/');\n}\n"
},
{
"answer_id": 74372895,
"author": "kaamrul",
"author_id": 10418084,
"author_profile": "https://Stackoverflow.com/users/10418084",
"pm_score": 1,
"selected": false,
"text": "use Illuminate\\Http\\Request;\npublic function upload(Request $request){\n $request->validate([\n 'file' => 'required|mimes:csv,txt,,xlx,xls,pdf|max:2048'\n ]);\n $products = new Product;\n $products->name = $request->name;\n $products->price = $request->price;\n\n if ($request->file('file')) {\n $fileName = time().'.'.$request->file->extension();\n $request->file->move(public_path('/upload'), $fileName);\n $products->file= $filename;\n } \n\n $products->save(); \n return redirect('/');\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8936504/"
] |
74,312,598 | <p>I am working on LeetCode problem <a href="https://leetcode.com/problems/remove-nth-node-from-end-of-list/submissions/" rel="nofollow noreferrer">19. Remove Nth Node From End of List</a>:</p>
<blockquote>
<p>Given the <code>head</code> of a linked list, remove the nth node from the end of the list and return its head.</p>
<h3>Example 1:</h3>
<pre><code>Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]
</code></pre>
<h3>Constraints:</h3>
<ul>
<li>The number of nodes in the list is <code>sz</code>.</li>
<li><code>1 <= sz <= 30</code></li>
<li><code>0 <= Node.val <= 100</code></li>
<li><code>1 <= n <= sz</code></li>
</ul>
</blockquote>
<p>This is my code:</p>
<pre><code>class Solution {
public:
ListNode* removeNthFromEnd(ListNode* head, int n) {
ListNode *p=head,*q=head,*t=NULL;
long long c=0;
while(p!=0){
c++;
p=p->next;
}
c=c-n;
while(q!=NULL && c>0){
t=q;
q=q->next;
c--;
}
t->next=q->next;
delete q;
return head;
}
};
</code></pre>
<p>I get this error when one of the test cases is run:</p>
<pre class="lang-none prettyprint-override"><code>Line 26: Char 12: runtime error:
member access within null pointer of type 'ListNode' (solution.cpp)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior prog_joined.cpp:35:12
</code></pre>
<p>Not sure why I'm getting this error, because according to what I think, both <code>t</code> and <code>q</code> are not <code>NULL</code> here at the moment. So, I shouldn't have gotten this error.</p>
| [
{
"answer_id": 74314634,
"author": "Nathan Mwamba",
"author_id": 15436605,
"author_profile": "https://Stackoverflow.com/users/15436605",
"pm_score": 0,
"selected": false,
"text": "<form method=\"POST\" action=\"/upload\" enctype=\"multipart/form-data\">\n @csrf\n <div class=\"form-group\">\n <label>Name</label>\n <input type=\"name\" name=\"name\" class=\"form-control\" placeholder=\"Enter Name\">\n </div>\n <div class=\"form-group\">\n <label>Price</label>\n <input type=\"price\" name=\"price\" class=\"form-control\" placeholder=\"Enter price\">\n </div>\n <label>Category</label>\n <div class=\"dropdown\">\n <button class=\"btn btn-secondary dropdown-toggle\" type=\"button\" id=\"dropdownMenuButton\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n Choose\n </button>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownMenuButton\">\n <a class=\"dropdown-item\" href=\"#\">Item</a>\n <br><a class=\"dropdown-item\" href=\"#\">Diamond</a>\n <br><a class=\"dropdown-item\" href=\"#\">Akun</a>\n </div>\n </div>\n </div>\n <div>\n <input type=\"file\" name=\"file\"><br><br></div>\n <div>\n <button type=\"submit\"> Sell Item</button>\n </div>\n </form>\n"
},
{
"answer_id": 74317143,
"author": "Amit Kumar",
"author_id": 20379294,
"author_profile": "https://Stackoverflow.com/users/20379294",
"pm_score": 0,
"selected": false,
"text": "public function upload(Request $request){\n $products = new Product;\n $products->name = $request->name;\n $products->price = $request->price;\n\n if ($request->file('file')) {\n $file = $request->file('file');\n $path = public_path() . '/uploads';\n $filename = time() . '_' . $file->getClientOriginalName();\n if ($file->move($path, $filename)) {\n $products->file= $filename;\n } \n } \n\n $products->save(); \n return redirect('/');\n}\n"
},
{
"answer_id": 74372895,
"author": "kaamrul",
"author_id": 10418084,
"author_profile": "https://Stackoverflow.com/users/10418084",
"pm_score": 1,
"selected": false,
"text": "use Illuminate\\Http\\Request;\npublic function upload(Request $request){\n $request->validate([\n 'file' => 'required|mimes:csv,txt,,xlx,xls,pdf|max:2048'\n ]);\n $products = new Product;\n $products->name = $request->name;\n $products->price = $request->price;\n\n if ($request->file('file')) {\n $fileName = time().'.'.$request->file->extension();\n $request->file->move(public_path('/upload'), $fileName);\n $products->file= $filename;\n } \n\n $products->save(); \n return redirect('/');\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18142963/"
] |
74,312,619 | <p>I am trying to rotate an array according to the user input, I want to take the array from the user and number of positions to shift from, from the user, and the direction to shift in i.e., left or right from the user(which can be taken as 0 for left and 1 for right) So far I could do this</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const numList = [1, 2, 3, 4, 5, 6]
const p = 3
function changeArray(arr, shift) {
for (let i = 0; i < shift; i++) {
arr.unshift(arr.pop())
console.log(`${i+1}:`, arr)
}
}
console.log(changeArray(numList, p))</code></pre>
</div>
</div>
I am doing this to take inputs from user:</p>
<pre><code>const numList= prompt("Type your array")
const p=prompt("Type your position")
</code></pre>
<p>Please tell me how can I take the input from the user.</p>
<p>this gives me the expected output but I want to take the inputs from user and when I try that it says, <code>arr.pop()</code> is not a function. I also couldn't add the direction functionality to it, could anyone tell me what can be done here?</p>
| [
{
"answer_id": 74314634,
"author": "Nathan Mwamba",
"author_id": 15436605,
"author_profile": "https://Stackoverflow.com/users/15436605",
"pm_score": 0,
"selected": false,
"text": "<form method=\"POST\" action=\"/upload\" enctype=\"multipart/form-data\">\n @csrf\n <div class=\"form-group\">\n <label>Name</label>\n <input type=\"name\" name=\"name\" class=\"form-control\" placeholder=\"Enter Name\">\n </div>\n <div class=\"form-group\">\n <label>Price</label>\n <input type=\"price\" name=\"price\" class=\"form-control\" placeholder=\"Enter price\">\n </div>\n <label>Category</label>\n <div class=\"dropdown\">\n <button class=\"btn btn-secondary dropdown-toggle\" type=\"button\" id=\"dropdownMenuButton\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n Choose\n </button>\n <div class=\"dropdown-menu\" aria-labelledby=\"dropdownMenuButton\">\n <a class=\"dropdown-item\" href=\"#\">Item</a>\n <br><a class=\"dropdown-item\" href=\"#\">Diamond</a>\n <br><a class=\"dropdown-item\" href=\"#\">Akun</a>\n </div>\n </div>\n </div>\n <div>\n <input type=\"file\" name=\"file\"><br><br></div>\n <div>\n <button type=\"submit\"> Sell Item</button>\n </div>\n </form>\n"
},
{
"answer_id": 74317143,
"author": "Amit Kumar",
"author_id": 20379294,
"author_profile": "https://Stackoverflow.com/users/20379294",
"pm_score": 0,
"selected": false,
"text": "public function upload(Request $request){\n $products = new Product;\n $products->name = $request->name;\n $products->price = $request->price;\n\n if ($request->file('file')) {\n $file = $request->file('file');\n $path = public_path() . '/uploads';\n $filename = time() . '_' . $file->getClientOriginalName();\n if ($file->move($path, $filename)) {\n $products->file= $filename;\n } \n } \n\n $products->save(); \n return redirect('/');\n}\n"
},
{
"answer_id": 74372895,
"author": "kaamrul",
"author_id": 10418084,
"author_profile": "https://Stackoverflow.com/users/10418084",
"pm_score": 1,
"selected": false,
"text": "use Illuminate\\Http\\Request;\npublic function upload(Request $request){\n $request->validate([\n 'file' => 'required|mimes:csv,txt,,xlx,xls,pdf|max:2048'\n ]);\n $products = new Product;\n $products->name = $request->name;\n $products->price = $request->price;\n\n if ($request->file('file')) {\n $fileName = time().'.'.$request->file->extension();\n $request->file->move(public_path('/upload'), $fileName);\n $products->file= $filename;\n } \n\n $products->save(); \n return redirect('/');\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19336351/"
] |
74,312,646 | <p>I'm trying to move those two buttons to the right side of my header but I don't know why I cannot. I literally tried everything.</p>
<p>I tried creating a div to insert both buttons, tried to add a specific class to those buttons, and align them to the right and neither of those worked.</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>header {
display: flex;
border-bottom: solid 1px black;
padding: 10px;
align-items: center;
}
.allButtons {
display: flex;
float: right;
}
.headerButtons {
margin: 10px;
background-color: #0A99FE;
padding: 9px;
opacity: 60%;
border-radius: 10px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><header class="headerItens">
<svg width="164" height="54" viewBox="0 0 164 54" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M34.6341 38.347C30.0324 40.0528 23.3232 39.2311 20.4862 37.9192C17.6411 36.6026 14.062 40.1065 18.1966 41.7563C22.3304 43.4058 29.3089 43.0965 34.6369 41.8034" fill="#0A99FE"/>
<path d="M34.6341 38.347C30.0324 40.0528 23.3232 39.2311 20.4862 37.9192C17.6411 36.6026 14.062 40.1065 18.1966 41.7563C22.3304 43.4058 29.3089 43.0965 34.6369 41.8034" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M37.3815 47.4288L35.3135 48.5538L33.8293 44.4007L35.8464 34.7222L32.7996 26.0337L36.9103 18.2146L48.8209 17.9628L51.3387 19.6712L54.0802 21.4771L54.9769 23.9681L53.8602 26.0206L52.7914 28.2193L53.5284 30.5154L51.6277 31.2494L48.2777 37.5047L42.3556 44.1037L39.9187 45.5867L37.3815 47.4288Z" fill="#0A99FE"/>
<path d="M49.8828 17.3271C53.6701 25.5104 52.6224 34.6247 45.3759 44.9323C51.416 45.9056 47.6171 50.3048 40.1762 45.8149" fill="#0A99FE"/>
<path d="M49.8828 17.3271C53.6701 25.5104 52.6224 34.6247 45.3759 44.9323C51.416 45.9056 47.6171 50.3048 40.1762 45.8149" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M33.2819 26.0334C35.8281 34.3033 35.9591 42.0565 31.6789 48.8662C35.5428 55.442 39.6209 50.6029 36.4317 48.3576" fill="#0A99FE"/>
<path d="M33.2819 26.0334C35.8281 34.3033 35.9591 42.0565 31.6789 48.8662C35.5428 55.442 39.6209 50.6029 36.4317 48.3576" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M47.7151 33.3036C46.3229 39.2472 42.4295 43.9228 36.4671 48.3316L47.7151 33.3036Z" fill="#0A99FE"/>
<path d="M47.7151 33.3036C46.3229 39.2472 42.4295 43.9228 36.4671 48.3316" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M50.6031 19.0504C55.364 21.167 56.3238 24.2183 53.0232 28.3173C54.9823 30.5633 53.4137 31.7456 51.7063 30.7128" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M33.0049 29.0136L38.6542 30.8666C39.1103 41.5652 29.7687 37.7605 35.5809 33.702C20.314 32.3437 20.5906 28.8259 35.275 19.8782L45.3531 16.9391L47.4802 19.4782" fill="#0A99FE"/>
<path d="M33.0049 29.0136L38.6542 30.8666C39.1103 41.5652 29.7687 37.7605 35.5809 33.702C20.314 32.3437 20.5906 28.8259 35.275 19.8782L45.3531 16.9391L47.4802 19.4782" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M41.3332 24.6116L31.4328 29.8635L41.3332 24.6116Z" fill="#0A99FE"/>
<path d="M41.3332 24.6116L31.4328 29.8635" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M15.4239 4.30242C14.809 7.49465 14.0051 9.26857 10.0159 11.0189C6.6965 12.4488 0.889192 13.9475 0.0136247 17.6953C4.50403 20.0811 10.5996 22.2078 19.8948 19.5555C27.2064 17.4693 32.1783 21.6527 40.451 22.1748C38.4454 17.5598 37.1082 15.3508 34.6809 13.7268C30.626 13.5208 28.1016 8.65118 24.1513 6.68459C20.8398 5.036 19.9526 4.91399 15.4239 4.30242Z" fill="black"/>
<path d="M32.2778 2.95281C32.2518 2.6826 32.4969 2.5817 32.7189 2.77121L34.98 4.70148L37.2412 6.63179C37.4632 6.8213 37.4956 7.15902 37.2995 7.23976L35.3024 8.06176L33.3053 8.8838C33.1092 8.96449 32.8317 8.72759 32.8058 8.45739L32.5418 5.70508L32.2778 2.95281Z" fill="#0A99FE"/>
<path d="M32.2778 2.95281C32.2518 2.6826 32.4969 2.5817 32.7189 2.77121L34.98 4.70148L37.2412 6.63179C37.4632 6.8213 37.4956 7.15902 37.2995 7.23976L35.3024 8.06176L33.3053 8.8838C33.1092 8.96449 32.8317 8.72759 32.8058 8.45739L32.5418 5.70508L32.2778 2.95281Z" stroke="black" stroke-width="2" stroke-miterlimit="10" stroke-linecap="round"/>
<path d="M43.4032 1.38483C43.4997 1.12527 43.784 1.11048 43.915 1.35823L45.2494 3.88157L46.5838 6.40482C46.7148 6.65257 46.5942 6.97705 46.3668 6.9889L44.0499 7.10931L41.7331 7.2298C41.5056 7.24161 41.3418 6.93191 41.4383 6.67235L42.4207 4.02865L43.4032 1.38483Z" fill="#0A99FE"/>
<path d="M43.4032 1.38483C43.4997 1.12527 43.784 1.11048 43.915 1.35823L45.2494 3.88157L46.5838 6.40482C46.7148 6.65257 46.5942 6.97705 46.3668 6.9889L44.0499 7.10931L41.7331 7.2298C41.5056 7.24161 41.3418 6.93191 41.4383 6.67235L42.4207 4.02865L43.4032 1.38483Z" stroke="black" stroke-width="2" stroke-miterlimit="10" stroke-linecap="round"/>
<path d="M52.6317 13.1373C52.5355 18.1552 47.8016 22.1548 42.0581 22.0708C36.3146 21.9868 31.7365 17.851 31.8327 12.8332C31.9288 7.81534 36.6628 3.81572 42.4063 3.89972C48.1498 3.98372 52.7278 8.11954 52.6317 13.1373Z" fill="#0A99FE"/>
<path d="M52.6317 13.1373C52.5355 18.1552 47.8016 22.1548 42.0581 22.0708C36.3146 21.9868 31.7365 17.851 31.8327 12.8332C31.9288 7.81534 36.6628 3.81572 42.4063 3.89972C48.1498 3.98372 52.7278 8.11954 52.6317 13.1373Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M40.0902 8.01892C42.6114 13.6259 46.6678 12.0728 43.6248 7.43546" stroke="black" stroke-miterlimit="10" stroke-linecap="round"/>
<path d="M44.9714 7.21087C47.0745 12.7384 50.5785 10.8353 46.8276 6.65171" stroke="black" stroke-miterlimit="10" stroke-linecap="round"/>
<path d="M47.0793 12.4942L48.3819 15.1063" stroke="black" stroke-width="2" stroke-miterlimit="10" stroke-linecap="round"/>
<path d="M50.2585 15.8632L48.4904 15.2581L47.774 17.0972" stroke="black" stroke-width="2" stroke-miterlimit="10" stroke-linecap="round"/>
<path d="M73.9091 23.7609C73.8097 23.4153 73.67 23.1099 73.4901 22.8447C73.3101 22.5748 73.09 22.3475 72.8295 22.1629C72.5739 21.9735 72.2803 21.8291 71.9489 21.7296C71.6222 21.6302 71.2599 21.5805 70.8622 21.5805C70.1188 21.5805 69.4654 21.7652 68.902 22.1345C68.3433 22.5038 67.9077 23.0412 67.5952 23.7467C67.2827 24.4474 67.1264 25.3045 67.1264 26.3177C67.1264 27.331 67.2803 28.1927 67.5881 28.9029C67.8958 29.6132 68.3314 30.1553 68.8949 30.5294C69.4583 30.8987 70.1236 31.0833 70.8906 31.0833C71.5866 31.0833 72.1809 30.9602 72.6733 30.714C73.1705 30.4631 73.5492 30.1103 73.8097 29.6558C74.0748 29.2012 74.2074 28.6638 74.2074 28.0436L74.8324 28.1359H71.0824V25.8206H77.169V27.6529C77.169 28.9313 76.8991 30.0298 76.3594 30.9484C75.8196 31.8622 75.0762 32.5677 74.1293 33.0649C73.1823 33.5573 72.098 33.8035 70.8764 33.8035C69.5128 33.8035 68.3149 33.5028 67.2827 32.9015C66.2505 32.2955 65.4455 31.4361 64.8679 30.3234C64.295 29.206 64.0085 27.8802 64.0085 26.3461C64.0085 25.1671 64.179 24.116 64.5199 23.1927C64.8655 22.2647 65.3485 21.4787 65.9688 20.8348C66.589 20.1908 67.3111 19.7008 68.1349 19.3646C68.9588 19.0284 69.8513 18.8603 70.8125 18.8603C71.6364 18.8603 72.4034 18.9811 73.1136 19.2225C73.8239 19.4593 74.4536 19.7955 75.0028 20.2311C75.5568 20.6667 76.009 21.1851 76.3594 21.7865C76.7098 22.3831 76.9347 23.0412 77.0341 23.7609H73.9091ZM84.3938 33.8177C83.2717 33.8177 82.3058 33.5904 81.4961 33.1359C80.6912 32.6766 80.0709 32.0279 79.6353 31.1899C79.1997 30.3471 78.9819 29.3504 78.9819 28.1998C78.9819 27.0777 79.1997 26.0928 79.6353 25.2453C80.0709 24.3977 80.6841 23.7372 81.4748 23.2637C82.2702 22.7903 83.203 22.5535 84.2731 22.5535C84.9928 22.5535 85.6628 22.6695 86.283 22.9015C86.908 23.1288 87.4525 23.4721 87.9165 23.9313C88.3853 24.3906 88.7499 24.9683 89.0103 25.6643C89.2707 26.3556 89.4009 27.1653 89.4009 28.0933V28.9242H80.1893V27.0492H86.5529C86.5529 26.6136 86.4582 26.2278 86.2688 25.8916C86.0794 25.5554 85.8166 25.2926 85.4805 25.1032C85.149 24.9091 84.7631 24.812 84.3228 24.812C83.8635 24.812 83.4563 24.9186 83.1012 25.1316C82.7508 25.34 82.4762 25.6217 82.2773 25.9768C82.0785 26.3272 81.9767 26.7178 81.9719 27.1487V28.9313C81.9719 29.4711 82.0714 29.9375 82.2702 30.3305C82.4738 30.7235 82.7603 31.0265 83.1296 31.2396C83.4989 31.4527 83.9369 31.5592 84.4435 31.5592C84.7797 31.5592 85.0875 31.5118 85.3668 31.4171C85.6462 31.3224 85.8853 31.1804 86.0842 30.991C86.283 30.8016 86.4345 30.5696 86.5387 30.295L89.337 30.4796C89.195 31.152 88.9038 31.7391 88.4634 32.241C88.0278 32.7382 87.4644 33.1264 86.7731 33.4058C86.0865 33.6804 85.2934 33.8177 84.3938 33.8177ZM96.3469 33.8177C95.2248 33.8177 94.2589 33.5904 93.4492 33.1359C92.6443 32.6766 92.024 32.0279 91.5884 31.1899C91.1528 30.3471 90.935 29.3504 90.935 28.1998C90.935 27.0777 91.1528 26.0928 91.5884 25.2453C92.024 24.3977 92.6372 23.7372 93.4279 23.2637C94.2234 22.7903 95.1561 22.5535 96.2262 22.5535C96.9459 22.5535 97.6159 22.6695 98.2362 22.9015C98.8612 23.1288 99.4057 23.4721 99.8697 23.9313C100.338 24.3906 100.703 24.9683 100.963 25.6643C101.224 26.3556 101.354 27.1653 101.354 28.0933V28.9242H92.1424V27.0492H98.506C98.506 26.6136 98.4113 26.2278 98.2219 25.8916C98.0326 25.5554 97.7698 25.2926 97.4336 25.1032C97.1022 24.9091 96.7163 24.812 96.2759 24.812C95.8166 24.812 95.4094 24.9186 95.0543 25.1316C94.704 25.34 94.4293 25.6217 94.2305 25.9768C94.0316 26.3272 93.9298 26.7178 93.9251 27.1487V28.9313C93.9251 29.4711 94.0245 29.9375 94.2234 30.3305C94.427 30.7235 94.7134 31.0265 95.0827 31.2396C95.4521 31.4527 95.89 31.5592 96.3967 31.5592C96.7328 31.5592 97.0406 31.5118 97.32 31.4171C97.5993 31.3224 97.8384 31.1804 98.0373 30.991C98.2362 30.8016 98.3877 30.5696 98.4918 30.295L101.29 30.4796C101.148 31.152 100.857 31.7391 100.417 32.241C99.9809 32.7382 99.4175 33.1264 98.7262 33.4058C98.0397 33.6804 97.2466 33.8177 96.3469 33.8177ZM106.07 30.4654L106.077 26.8362H106.517L110.012 22.6956H113.485L108.79 28.1785H108.073L106.07 30.4654ZM103.328 33.6046V19.0592H106.354V33.6046H103.328ZM110.147 33.6046L106.936 28.8532L108.953 26.7154L113.691 33.6046H110.147Z" fill="#1E1E1E"/>
<path d="M118.165 33.6046L114.188 19.0592H115.978L119.017 30.9058H119.159L122.256 19.0592H124.245L127.341 30.9058H127.483L130.523 19.0592H132.313L128.336 33.6046H126.517L123.307 22.0137H123.194L119.983 33.6046H118.165ZM137.696 33.8319C136.712 33.8319 135.847 33.5975 135.104 33.1288C134.365 32.66 133.788 32.0043 133.371 31.1615C132.959 30.3187 132.753 29.3338 132.753 28.2069C132.753 27.0706 132.959 26.0786 133.371 25.2311C133.788 24.3835 134.365 23.7254 135.104 23.2566C135.847 22.7879 136.712 22.5535 137.696 22.5535C138.681 22.5535 139.543 22.7879 140.282 23.2566C141.025 23.7254 141.603 24.3835 142.015 25.2311C142.431 26.0786 142.64 27.0706 142.64 28.2069C142.64 29.3338 142.431 30.3187 142.015 31.1615C141.603 32.0043 141.025 32.66 140.282 33.1288C139.543 33.5975 138.681 33.8319 137.696 33.8319ZM137.696 32.3262C138.444 32.3262 139.06 32.1345 139.543 31.751C140.026 31.3674 140.383 30.8632 140.615 30.2382C140.847 29.6132 140.963 28.9361 140.963 28.2069C140.963 27.4778 140.847 26.7983 140.615 26.1686C140.383 25.5388 140.026 25.0298 139.543 24.6416C139.06 24.2533 138.444 24.0592 137.696 24.0592C136.948 24.0592 136.333 24.2533 135.85 24.6416C135.367 25.0298 135.009 25.5388 134.777 26.1686C134.545 26.7983 134.429 27.4778 134.429 28.2069C134.429 28.9361 134.545 29.6132 134.777 30.2382C135.009 30.8632 135.367 31.3674 135.85 31.751C136.333 32.1345 136.948 32.3262 137.696 32.3262ZM145.198 33.6046V22.6956H146.817V24.3433H146.931C147.13 23.8035 147.49 23.3655 148.011 23.0294C148.531 22.6932 149.119 22.5251 149.772 22.5251C149.895 22.5251 150.049 22.5275 150.234 22.5322C150.418 22.5369 150.558 22.544 150.653 22.5535V24.2581C150.596 24.2438 150.466 24.2225 150.262 24.1941C150.063 24.161 149.853 24.1444 149.63 24.1444C149.1 24.1444 148.626 24.2557 148.21 24.4782C147.798 24.696 147.471 24.9991 147.229 25.3873C146.993 25.7708 146.874 26.2088 146.874 26.7012V33.6046H145.198ZM156.427 33.8319C155.518 33.8319 154.715 33.6023 154.019 33.143C153.323 32.679 152.779 32.0256 152.386 31.1828C151.993 30.3352 151.796 29.3338 151.796 28.1785C151.796 27.0327 151.993 26.0384 152.386 25.1956C152.779 24.3528 153.326 23.7017 154.026 23.2424C154.727 22.7831 155.537 22.5535 156.455 22.5535C157.165 22.5535 157.727 22.6719 158.138 22.9086C158.555 23.1406 158.872 23.4058 159.09 23.7041C159.313 23.9976 159.486 24.2391 159.609 24.4285H159.751V19.0592H161.427V33.6046H159.808V31.9285H159.609C159.486 32.1274 159.31 32.3783 159.083 32.6813C158.856 32.9796 158.531 33.2472 158.11 33.4839C157.689 33.7159 157.128 33.8319 156.427 33.8319ZM156.654 32.3262C157.326 32.3262 157.895 32.151 158.359 31.8007C158.823 31.4456 159.175 30.9555 159.417 30.3305C159.658 29.7008 159.779 28.974 159.779 28.1501C159.779 27.3357 159.661 26.6231 159.424 26.0123C159.187 25.3968 158.837 24.9186 158.373 24.5777C157.909 24.232 157.336 24.0592 156.654 24.0592C155.944 24.0592 155.352 24.2415 154.879 24.6061C154.41 24.9659 154.057 25.456 153.82 26.0762C153.588 26.6918 153.472 27.3831 153.472 28.1501C153.472 28.9266 153.591 29.6321 153.827 30.2666C154.069 30.8963 154.424 31.3982 154.893 31.7723C155.366 32.1416 155.953 32.3262 156.654 32.3262Z" fill="#0A99FE"/>
</svg>
<div class="allButtons">
<div class="headerButtons">Products</div>
<div class="headerButtons">Contatos</div>
</div>
</header></code></pre>
</div>
</div>
</p>
<p>Can you guys please explain to me what I'm missing?</p>
| [
{
"answer_id": 74312746,
"author": "Adam",
"author_id": 12571484,
"author_profile": "https://Stackoverflow.com/users/12571484",
"pm_score": 0,
"selected": false,
"text": "width:100%"
},
{
"answer_id": 74313030,
"author": "tacoshy",
"author_id": 14072420,
"author_profile": "https://Stackoverflow.com/users/14072420",
"pm_score": 1,
"selected": false,
"text": "float"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414289/"
] |
74,312,655 | <p>I have some code that I am trying to execute:</p>
<pre><code>function createOrAppendFile(in_Folder, in_FileName, in_Content ) {
var fileName=in_FileName;
//var folderName=in_Folder;
var folderName="TRADEARCHIVE";
var content = in_Content;
// get list of folders with matching name
var folderList = DriveApp.getFoldersByName(folderName);
if (folderList.hasNext()) {
// found matching folder
var folder = folderList.next();
// search for files with matching name
var fileList = folder.getFilesByName(fileName);
[... snip ...]
</code></pre>
<p>I have the following defined in <strong>appscript.json</strong></p>
<pre><code>{
"timeZone": "America/Chicago",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"webapp": {
"executeAs": "USER_DEPLOYING",
"access": "ANYONE_ANONYMOUS"
},
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/drive"
]
}
</code></pre>
<p>I am getting the following error:</p>
<pre><code>Nov 4, 2022, 12:28:53 AM Error Exception: You do not have permission to call DriveApp.getFoldersByName. Required permissions: (https://www.googleapis.com/auth/drive.readonly || https://www.googleapis.com/auth/drive)
at createOrAppendFile(Code:33:29)
at deleteRows(Code:173:11)
at onMyEdit(Code:390:29)
</code></pre>
<p>What am I doing wrong? Any help, hints or advice would be greatly appreciated.</p>
<p>TIA</p>
| [
{
"answer_id": 74312746,
"author": "Adam",
"author_id": 12571484,
"author_profile": "https://Stackoverflow.com/users/12571484",
"pm_score": 0,
"selected": false,
"text": "width:100%"
},
{
"answer_id": 74313030,
"author": "tacoshy",
"author_id": 14072420,
"author_profile": "https://Stackoverflow.com/users/14072420",
"pm_score": 1,
"selected": false,
"text": "float"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2707727/"
] |
74,312,674 | <p>I working on a chart using Chart.js and Blazor wasm. Therefor I need a JSON configuration object as an anonymous type. Like this:</p>
<pre><code>var config = new
{
Type = "line",
Options = new
{
Responsive = true,
},
Data = new
{
Labels = Labels,
DataSets = new object[]
{
new
{
Label = "Line 1",
Data = Values,
Fill = false,
BorderColor = "red",
Tension = 0.1
}
}
},
};
</code></pre>
<p>This is just a simple example, my config file will grow up a lot. So, making mistakes by setting or missing commas is most likely and it will be difficult to find the mistake. Also Visual Studio has problems to format this properly. Sometime a restart is required to get it properly formatted.</p>
<p>Is there a way to improve this? How can I validate the config object?</p>
| [
{
"answer_id": 74312746,
"author": "Adam",
"author_id": 12571484,
"author_profile": "https://Stackoverflow.com/users/12571484",
"pm_score": 0,
"selected": false,
"text": "width:100%"
},
{
"answer_id": 74313030,
"author": "tacoshy",
"author_id": 14072420,
"author_profile": "https://Stackoverflow.com/users/14072420",
"pm_score": 1,
"selected": false,
"text": "float"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4958473/"
] |
74,312,690 | <p>I'm exploring using azure event hub as an event consumer.</p>
<p>So my .NET application sends events to the azure event hub. The event hub by default has 4 partitions.</p>
<p>I want the events to be stored in the azure blob storage and also be passed to another .NET application.</p>
<p>This question is to ask - whether the azure event hub has the ability to push the events to the blob and to my .NET application, or will the subscriber (blob and .NET application) need to pull the data from the azure event hub partition?</p>
<p>Or will my .NET subscriber need to pull events from the azure blob?</p>
| [
{
"answer_id": 74312828,
"author": "Sajeetharan",
"author_id": 1749403,
"author_profile": "https://Stackoverflow.com/users/1749403",
"pm_score": 2,
"selected": false,
"text": "// Read from the default consumer group: $Default\nstring consumerGroup = EventHubConsumerClient.DefaultConsumerGroupName;\n\n// Create a blob container client that the event processor will use \nstorageClient = new BlobContainerClient(blobStorageConnectionString, blobContainerName);\n\n// Create an event processor client to process events in the event hub\nprocessor = new EventProcessorClient(storageClient, consumerGroup, ehubNamespaceConnectionString, eventHubName);\n\n// Register handlers for processing events and handling errors\nprocessor.ProcessEventAsync += ProcessEventHandler;\nprocessor.ProcessErrorAsync += ProcessErrorHandler;\n\n// Start the processing\nawait processor.StartProcessingAsync();\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1779091/"
] |
74,312,752 | <p>I am trying to make a copy button, where If <strong>I click on the button it will copy the current browser URL and will show an alert that the URL copied.</strong></p>
<p>I tried this</p>
<pre><code><a id="copy" href="javascript:void(0);"><i onclick="myFunction()" class="fa fa-files-o" aria-hidden="true"></i></a>
<script>
var url = window.location.href;
function myFunction() {
return navigator.clipboard.writeText(url);
// Alert the copied text
alert("Copied the URL: " + url);
}
</script>
</code></pre>
<p>Here the <code>alert</code> is not working, where I am making mistake?</p>
<p>I tried this, It's working on the Desktop but in mobile, only the alert function is executing, and <code>myFunction()</code> is not executing.</p>
<pre><code><a id="copy" href="javascript:void(0);"><i onclick="myFunction();,alertUrl();" class="fa fa-files-o" aria-hidden="true"></i></a>
<script>
var url = window.location.href;
function myFunction() {
return navigator.clipboard.writeText(url);
}
function alertUrl(){
// Alert the copied text
alert("Copied the URL: " + URL);
}
</script>
</code></pre>
| [
{
"answer_id": 74312763,
"author": "ray",
"author_id": 636077,
"author_profile": "https://Stackoverflow.com/users/636077",
"pm_score": 2,
"selected": false,
"text": "return"
},
{
"answer_id": 74313089,
"author": "Mohammad Fathi Rahman",
"author_id": 18411353,
"author_profile": "https://Stackoverflow.com/users/18411353",
"pm_score": 0,
"selected": false,
"text": "<a id=\"copy\" href=\"javascript:void(0);\"><i onclick=\"copyURL()\" class=\"fa fa-files-o\" aria-hidden=\"true\"></i></a>\n\n<script>\nvar url = window.location.href;\n\nfunction copyURL() {\n\nnavigator.clipboard.writeText(url).then(() => {\n alert(\"Copied the URL: \" + url);\n}, () => {\n\n try {\n\n window.prompt(\"Please copy this url\", url);\n\n } catch (error) {\n \n alert(\"Your browser doesn't support this function\");\n }\n \n});\n}\n\n</script>\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18411353/"
] |
74,312,778 | <p>my problem is to use elif in this ternary operator like i want to use 3 conditions in ternary operator</p>
<pre><code>a = 3
if a>0:
print("is odd" if a %2 !=0 else "is even")
</code></pre>
<p>Make a code which return 3 strings one for its odd one for its even and atlast for its zero</p>
| [
{
"answer_id": 74312809,
"author": "Martin Cook",
"author_id": 5789637,
"author_profile": "https://Stackoverflow.com/users/5789637",
"pm_score": 2,
"selected": false,
"text": "print(\"atlast\" if x == 0 else \"even\" if x%2 == 0 else \"odd\")\n"
},
{
"answer_id": 74312873,
"author": "Darshil Jani",
"author_id": 19232446,
"author_profile": "https://Stackoverflow.com/users/19232446",
"pm_score": 0,
"selected": false,
"text": "a=3\nprint(\"zero\" if a==0 else \"even\" if a%2==0 else \"odd\")\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414428/"
] |
74,312,784 | <pre><code>fn main() {
let marks: i8 = 90;
let mut grade: char = 'N';
if marks >= 90 {
// println!("{}", grade);
grade = 'A';
} else if marks >= 80 {
grade = 'B';
} else if marks >= 70 {
grade = 'C';
} else if marks >= 60 {
grade = 'D';
} else if marks >= 50 {
grade = 'F';
}
println!("obtain grade: {}", grade)
}
</code></pre>
<p>This does not give warrning but. below code give warrning when i remove <code>else if</code> in last.</p>
<pre><code>fn main() {
let marks: i8 = 90;
let mut grade: char = 'N';
if marks >= 90 {
// println!("{}", grade);
grade = 'A';
} else if marks >= 80 {
grade = 'B';
} else if marks >= 70 {
grade = 'C';
} else if marks >= 60 {
grade = 'D';
} else {
grade = 'F';
}
println!("obtain grade: {}", grade)
}
</code></pre>
<p><a href="https://i.stack.imgur.com/1AUs0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1AUs0.png" alt="warrning message" /></a></p>
<p>why is this happening. The code gives warrning on else</p>
| [
{
"answer_id": 74313645,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 1,
"selected": false,
"text": "let mut grade: char = 'N';"
},
{
"answer_id": 74313713,
"author": "Dogbert",
"author_id": 320615,
"author_profile": "https://Stackoverflow.com/users/320615",
"pm_score": 2,
"selected": false,
"text": "grade"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20275195/"
] |
74,312,799 | <p>I need to call one particular endpoint 18000 times using .NET Core 6. I need to log the response from each endpoint call.</p>
<p>The endpoint takes approx. 2 seconds to respond so I want to get all the requests sent quicker than that :)</p>
<p>Pretty sure <code>Task.WhenAll</code> is my friend here?</p>
| [
{
"answer_id": 74313645,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 1,
"selected": false,
"text": "let mut grade: char = 'N';"
},
{
"answer_id": 74313713,
"author": "Dogbert",
"author_id": 320615,
"author_profile": "https://Stackoverflow.com/users/320615",
"pm_score": 2,
"selected": false,
"text": "grade"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/920620/"
] |
74,312,801 | <p><a href="https://i.stack.imgur.com/8yL27.png" rel="nofollow noreferrer">See the Example image</a>
I am using the primeng component in my application it has css class p-component. Whenever I click on any field whether it is button or input or any other field It got highlited with blue color border. I don't need that So I tried to use outline:none but it doesn't work out.</p>
| [
{
"answer_id": 74313645,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 1,
"selected": false,
"text": "let mut grade: char = 'N';"
},
{
"answer_id": 74313713,
"author": "Dogbert",
"author_id": 320615,
"author_profile": "https://Stackoverflow.com/users/320615",
"pm_score": 2,
"selected": false,
"text": "grade"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414439/"
] |
74,312,818 | <p>can we group array of objects in multilevel. This is my array of objects with common date and places, but different timings.</p>
<pre><code>[
{
"ID": 2104221,
"date": "2022-11-18T00:00:00",
"day": "18",
"weekDay": "Fri",
"month": "Nov",
"Placeid": 2293,
"Place": "AAAAAA",
"address": "25 SSSSSS",
"city": "RRRRR",
"state": "WWWW",
"Time": "8:00 PM"
},
{
"ID": 2104344,
"date": "2022-11-15T00:00:00",
"day": "15",
"weekDay": "Tue",
"month": "Nov",
"Placeid": 3478,
"Place": "BIG",
"address": "1433 The ADDDD,",
"city": "CA",
"state": "",
"zipCode": "95126",
"Time": "03:00 PM"
},
{
"ID": 2104345,
"date": "2022-11-15T00:00:00",
"day": "15",
"weekDay": "Tue",
"month": "Nov",
"Placeid": 3478,
"Place": "BIG",
"address": "1433 The ADDDD,",
"city": "CA",
"state": "",
"zipCode": "95126",
"Time": "06:00 PM"
},
{
"ID": 2104346,
"date": "2022-11-15T00:00:00",
"day": "15",
"weekDay": "Tue",
"month": "Nov",
"Placeid": 3478,
"Place": "BIG",
"address": "1433 The ADDDD,",
"city": "CA",
"state": "",
"zipCode": "95126",
"Time": "09:00 PM"
},
{
"ID": 2104347,
"date": "2022-11-15T00:00:00",
"day": "15",
"weekDay": "Tue",
"month": "Nov",
"Placeid": 2464,
"Place": "ATheaters",
"address": "2901 Capital",
"city": "C",
"state": "TT",
"Time": "06:00 PM"
},
{
"ID": 2104348,
"date": "2022-11-15T00:00:00",
"day": "15",
"weekDay": "Tue",
"month": "Nov",
"Placeid": 2464,
"Place": "ATheaters",
"address": "2901 Capital",
"city": "ANNNN",
"state": "TT",
"Time": "10:00 PM"
},
{
"ID": 2103857,
"date": "2022-11-05T16:30:00",
"day": "5",
"weekDay": "Sat",
"month": "Nov",
"Placeid": 34771,
"Place": "Playhouse",
"address": "525 Palace",
"city": "BBBB",
"state": "YYYYY",
"Time": " 4:30 PM"
},
{
"ID": 2103858,
"date": "2022-11-05T23:30:00",
"day": "5",
"weekDay": "Sat",
"month": "Nov",
"Placeid": 34771,
"Place": "Playhouse",
"address": "525 Palace",
"city": "BBBB",
"state": "YYYYY",
"Time": "11:30 PM"
},
{
"ID": 2103862,
"date": "2022-11-15T23:00:00",
"day": "15",
"weekDay": "Tue",
"month": "Nov",
"Placeid": 34771,
"Place": "Playhouse",
"address": "525 Palace",
"city": "BBBB",
"state": "YYYYY",
"Time": "11:00 PM"
}
</code></pre>
<p>]</p>
<p>I would like to group based on day and places. my desired output will be</p>
<pre><code>[
{
"day": "18",
"date": "2022-11-18T00:00:00",
"weekDay": "Fri",
"month": "Nov",
"Places": [
{
"Placeid": 2293,
"Place": "AAAAAA",
"address": "25 SSSSSS",
"city": "RRRRR",
"state": "WWWW",
"Timings": [
{
"ID": 2104221,
"Time": "8:00 PM"
}
]
}
]
},
{
"day": "15",
"date": "2022-11-15T23:00:00",
"weekDay": "Tue",
"month": "Nov",
"Places": [
{
"Placeid": 3478,
"Place": "BIG",
"address": "1433 The ADDDD,",
"city": "CA",
"state": "",
"Timings": [
{
"ID": 2104344,
"Time": "03:00 PM"
},
{
"ID": 2104345,
"Time": "06:00 PM"
},
{
"ID": 2104346,
"Time": "09:00 PM"
}
]
},
{
"Placeid": 2464,
"Place": "ATheaters",
"address": "2901 Capital",
"city": "ANNNN",
"state": "TT",
"Timings": [
{
"ID": 2104347,
"Time": "06:00 PM"
},
{
"ID": 2104348,
"Time": "10:00 PM"
}
]
},
{
"Placeid": 34771,
"Place": "Playhouse",
"address": "525 Palace",
"city": "BBBB",
"Timings": [
{
"ID": 2103862,
"Time": "11:00 PM"
}
]
}
]
},
{
"day": "5",
"date": "2022-11-05T16:30:00",
"weekDay": "Sat",
"month": "Nov",
"Places": [
{
"Placeid": 34771,
"Place": "Playhouse",
"address": "525 Palace",
"city": "BBBB",
"state": "YYYYY",
"Timings": [
{
"ID": 2103857,
"Time": " 4:30 PM"
},
{
"ID": 2103858,
"Time": "11:30 PM"
}
]
}
]
}
]
</code></pre>
<p>Is it possible to group like this using javascript? i tried with below code to group. but i didnt get my desired output.</p>
<pre><code> const MultiLevelGrouping=(data,['day','Placeid'])=>{
var getEmpty = () => ({ _: [] }),
result = data
.reduce((q, o) => {
groups
.reduce((r, k) => {
const v = o[k];
if (!v) return r;
if (!r[v]) r._.push({ [k]: v, [k + 'Detail']: (r[v] = getEmpty())._ });
return r[v];
}, q)
._
.push(o);
return q;
}, getEmpty())
._;
return result;
}
</code></pre>
<p>Can Someone help me out ?</p>
| [
{
"answer_id": 74313197,
"author": "adiga",
"author_id": 3082296,
"author_profile": "https://Stackoverflow.com/users/3082296",
"pm_score": 2,
"selected": false,
"text": "push"
},
{
"answer_id": 74314358,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 1,
"selected": false,
"text": "const data = [{ID:2104221,date:\"2022-11-18T00:00:00\",day:\"18\",weekDay:\"Fri\",month:\"Nov\",Placeid:2293,Place:\"AAAAAA\",address:\"25 SSSSSS\",city:\"RRRRR\",state:\"WWWW\",Time:\"8:00 PM\"},{ID:2104344,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"03:00 PM\"},{ID:2104345,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"06:00 PM\"},{ID:2104346,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"09:00 PM\"},{ID:2104347,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:2464,Place:\"ATheaters\",address:\"2901 Capital\",city:\"C\",state:\"TT\",Time:\"06:00 PM\"},{ID:2104348,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:2464,Place:\"ATheaters\",address:\"2901 Capital\",city:\"ANNNN\",state:\"TT\",Time:\"10:00 PM\"},{ID:2103857,date:\"2022-11-05T16:30:00\",day:\"5\",weekDay:\"Sat\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\" 4:30 PM\"},{ID:2103858,date:\"2022-11-05T23:30:00\",day:\"5\",weekDay:\"Sat\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\"11:30 PM\"},{ID:2103862,date:\"2022-11-15T23:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\"11:00 PM\"}]\nlet r = Object.values(data.reduce((a,\n {day, date, weekDay, month})=>(a[`|${day}`]??={day, date, weekDay, month,\n Places: Object.values(data.filter(i=>i.day===day).reduce((b, {\n Placeid, Place, address, city, state})=>(b[`${day}|${Placeid}`]??={\n Placeid, Place, address, city, state,\n Timings: data.filter(j=>j.day===day && j.Placeid===Placeid)\n .map(j=>({ID: j.ID, Time: j.Time}))}, b), {}))}, a), {}));\nconsole.log(r);"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18398090/"
] |
74,312,819 | <p>I am trying to connect chainlink to the postgres db and for the same I am running both of them as docker images.</p>
<p>I start the postgres docker as:</p>
<pre><code>$ docker run --name some-postgres -e POSTGRES_PASSWORD=secret -p 5432:5432 -d postgres
</code></pre>
<p>This starts the postgres successfully.</p>
<p>However if I try to connect chainlink (as per the <a href="https://docs.chain.link/docs/running-a-chainlink-node/" rel="nofollow noreferrer">chainlink</a> doc) using the below .env
file</p>
<pre><code>ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=5
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
ALLOW_ORIGINS=*
ETH_URL=wss://eth-goerli.g.alchemy.com/v2/<API KEY>
DATABASE_URL=postgresql://some-postgres:secret@postgres:5432/postgres?sslmode=disable
</code></pre>
<p>I am trying to connect to the "some-postgres" instance with the password as "secret" and still it throws the error</p>
<pre><code>Cannot boot Chainlink: opening db: failed to open db: failed to connect to `host=postgres user=some-postgres database=postgres`: hostname resolving error (lookup postgres on 192.168.1.1:53: read udp 172.17.0.3:47766->192.168.1.1:53: i/o timeout) err=Cannot boot Chainlink: opening db: failed to open db: failed to connect to `host=postgres user=some-postgres database=postgres`: hostname resolving error (lookup postgres on 192.168.1.1:53: read udp 172.17.0.3:47766->192.168.1.1:53: i/o timeout) errVerbose=opening db: failed to open db: failed to connect to `host=postgres user=some-postgres database=postgres`: hostname resolving error (lookup postgres on 192.168.1.1:53: read udp 172.17.0.3:47766->192.168.1.1:53: i/o timeout)
Cannot boot Chainlink
</code></pre>
<p>I don't know why it does not connect chainlink docker to postgres docker.</p>
| [
{
"answer_id": 74313197,
"author": "adiga",
"author_id": 3082296,
"author_profile": "https://Stackoverflow.com/users/3082296",
"pm_score": 2,
"selected": false,
"text": "push"
},
{
"answer_id": 74314358,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 1,
"selected": false,
"text": "const data = [{ID:2104221,date:\"2022-11-18T00:00:00\",day:\"18\",weekDay:\"Fri\",month:\"Nov\",Placeid:2293,Place:\"AAAAAA\",address:\"25 SSSSSS\",city:\"RRRRR\",state:\"WWWW\",Time:\"8:00 PM\"},{ID:2104344,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"03:00 PM\"},{ID:2104345,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"06:00 PM\"},{ID:2104346,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"09:00 PM\"},{ID:2104347,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:2464,Place:\"ATheaters\",address:\"2901 Capital\",city:\"C\",state:\"TT\",Time:\"06:00 PM\"},{ID:2104348,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:2464,Place:\"ATheaters\",address:\"2901 Capital\",city:\"ANNNN\",state:\"TT\",Time:\"10:00 PM\"},{ID:2103857,date:\"2022-11-05T16:30:00\",day:\"5\",weekDay:\"Sat\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\" 4:30 PM\"},{ID:2103858,date:\"2022-11-05T23:30:00\",day:\"5\",weekDay:\"Sat\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\"11:30 PM\"},{ID:2103862,date:\"2022-11-15T23:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\"11:00 PM\"}]\nlet r = Object.values(data.reduce((a,\n {day, date, weekDay, month})=>(a[`|${day}`]??={day, date, weekDay, month,\n Places: Object.values(data.filter(i=>i.day===day).reduce((b, {\n Placeid, Place, address, city, state})=>(b[`${day}|${Placeid}`]??={\n Placeid, Place, address, city, state,\n Timings: data.filter(j=>j.day===day && j.Placeid===Placeid)\n .map(j=>({ID: j.ID, Time: j.Time}))}, b), {}))}, a), {}));\nconsole.log(r);"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/807817/"
] |
74,312,838 | <p>I recently wrote some code like this:</p>
<pre><code>function enum(tbl)
local length = #tbl
for i = 1, length do
local v = tbl[i]
tbl[v] = i
end
return tbl
end
eItemType = enum
{
"wpn",
"outf",
"helm",
"art",
"boost",
"bkpk",
"dev",
"ammo",
"none"
}
</code></pre>
<p>It works. But I would like to simplify it to this form:</p>
<pre><code>enum eItemType
{
"wpn",
"outf",
"helm",
"art",
"boost",
"bkpk",
"dev",
"ammo",
"none"
}
</code></pre>
<p>For the enum function to create a global variable eItemType in the file from which it is called.
I don't know how to implement this (convert eItemType to string in string code).
Functions from the debug library come to mind, namely getline, maybe it can handle it...</p>
| [
{
"answer_id": 74313197,
"author": "adiga",
"author_id": 3082296,
"author_profile": "https://Stackoverflow.com/users/3082296",
"pm_score": 2,
"selected": false,
"text": "push"
},
{
"answer_id": 74314358,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 1,
"selected": false,
"text": "const data = [{ID:2104221,date:\"2022-11-18T00:00:00\",day:\"18\",weekDay:\"Fri\",month:\"Nov\",Placeid:2293,Place:\"AAAAAA\",address:\"25 SSSSSS\",city:\"RRRRR\",state:\"WWWW\",Time:\"8:00 PM\"},{ID:2104344,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"03:00 PM\"},{ID:2104345,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"06:00 PM\"},{ID:2104346,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"09:00 PM\"},{ID:2104347,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:2464,Place:\"ATheaters\",address:\"2901 Capital\",city:\"C\",state:\"TT\",Time:\"06:00 PM\"},{ID:2104348,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:2464,Place:\"ATheaters\",address:\"2901 Capital\",city:\"ANNNN\",state:\"TT\",Time:\"10:00 PM\"},{ID:2103857,date:\"2022-11-05T16:30:00\",day:\"5\",weekDay:\"Sat\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\" 4:30 PM\"},{ID:2103858,date:\"2022-11-05T23:30:00\",day:\"5\",weekDay:\"Sat\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\"11:30 PM\"},{ID:2103862,date:\"2022-11-15T23:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\"11:00 PM\"}]\nlet r = Object.values(data.reduce((a,\n {day, date, weekDay, month})=>(a[`|${day}`]??={day, date, weekDay, month,\n Places: Object.values(data.filter(i=>i.day===day).reduce((b, {\n Placeid, Place, address, city, state})=>(b[`${day}|${Placeid}`]??={\n Placeid, Place, address, city, state,\n Timings: data.filter(j=>j.day===day && j.Placeid===Placeid)\n .map(j=>({ID: j.ID, Time: j.Time}))}, b), {}))}, a), {}));\nconsole.log(r);"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414467/"
] |
74,312,867 | <p>I am editing a form in Google Optimize that has both radio input "buttons" as well as a button made from a label. I am trying to make it so that when a the "one time purchase" radio input button is clicked, the "Delivery option" label's active class is removed. I'm sure this should be fairly simple but am new to JQuery and JS and I have been struggling to figure out how to do this. Can someone please help me figure out what I'm doing wrong?</p>
<p>Here is what I've tried so far:</p>
<pre><code>$('input:radio').click(function () {
if ($('.option-itemlabel[data-label="One-Time Purchase"]').is(':checked')) {
$('#radio-subscribe label').removeClass('active');
} else {
$('#radio-subscribe label').addClass('active');
}
});
</code></pre>
<pre><code> $('input:radio').click(function () {
$('#radio-subscribe label').removeClass("active");
if ($(this).is(":checked")) {
var label = $(this).attr("[data-label=One-Time Purchase]");
$('#radio-subscribe label').addClass("active");
}
});
</code></pre>
<pre><code>$('input:radio').on('click', function() {
if($(this).attr("data-label") == "One-Time Purchase"){
$('#radio-subscribe label').removeClass('active');}
else{
$('#radio-subscribe label').addClass('active');
$(this).removeClass('active');
});
</code></pre>
<p>Here is my CSS</p>
<pre><code>#radio-subscribe>label {
background-color : rgb(255, 255, 255);
}
#radio-subscribe label.active {
background-color : rgb(0, 0, 0);
color : rgb(255, 255, 255);
}
div.delivery-flex>div:nth-of-type(n)>label {
background-color : rgb(255, 255, 255);
}
.option-item[data-label] input[type="radio"]:checked + label {
background-color : rgb(0, 0, 0);
color : rgb(255, 255, 255);
}
</code></pre>
<p>Here is my html</p>
<pre><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="flex delivery-flex">
<div class="option-item df-radio-item" data-label="One-Time Purchase">
<input
data-label="One-Time Purchase"
class="form-radio "
type="radio"
id="attribute_rectangle__136_182"
name="attribute[136]"
value="182"
checked
data-default
>
<label class="form-option" for="attribute_rectangle__136_182" data-product-attribute-value="182">
<span class="form-option-variant">One-Time Purchase</span>
</label>
</div>
<div class="option-item df-radio-item" data-label="Every Week">
<input
data-label="Every Week"
class="form-radio "
type="radio"
id="attribute_rectangle__136_183"
name="attribute[136]"
value="183"
>
<label class="form-option" for="attribute_rectangle__136_183" data-product-attribute-value="183">
<span class="form-option-variant">Every Week</span>
</label>
</div>
<div class="option-item df-radio-item" data-label="Every 2 Weeks">
<input
data-label="Every 2 Weeks"
class="form-radio "
type="radio"
id="attribute_rectangle__136_184"
name="attribute[136]"
value="184"
>
<label class="form-option" for="attribute_rectangle__136_184" data-product-attribute-value="184">
<span class="form-option-variant">Every 2 Weeks</span>
</label>
</div>
<div class="option-item df-radio-item" data-label="Every Month">
<input
data-label="Every Month"
class="form-radio "
type="radio"
id="attribute_rectangle__136_185"
name="attribute[136]"
value="185"
>
<label class="form-option" for="attribute_rectangle__136_185" data-product-attribute-value="185">
<span class="form-option-variant">Every Month</span>
</label>
</div>
<div class="option-item df-radio-item subscribe-grp disabled" data-label="subscribe" id="radio-subscribe">
<input
data-label="Delivery Option"
class="form-radio "
type="radio"
id="attribute_rectangle__136_186"
name="attribute[136]"
value="186"
>
<label class="form-option" for="subscribe_list">
<strong class="form-option-variant">Delivery Option</strong>
<span class="form-option-variant">Save 10% on every shipment in your order</span>
</label>
</div>
</code></pre>
| [
{
"answer_id": 74313197,
"author": "adiga",
"author_id": 3082296,
"author_profile": "https://Stackoverflow.com/users/3082296",
"pm_score": 2,
"selected": false,
"text": "push"
},
{
"answer_id": 74314358,
"author": "Andrew Parks",
"author_id": 5898421,
"author_profile": "https://Stackoverflow.com/users/5898421",
"pm_score": 1,
"selected": false,
"text": "const data = [{ID:2104221,date:\"2022-11-18T00:00:00\",day:\"18\",weekDay:\"Fri\",month:\"Nov\",Placeid:2293,Place:\"AAAAAA\",address:\"25 SSSSSS\",city:\"RRRRR\",state:\"WWWW\",Time:\"8:00 PM\"},{ID:2104344,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"03:00 PM\"},{ID:2104345,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"06:00 PM\"},{ID:2104346,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:3478,Place:\"BIG\",address:\"1433 The ADDDD,\",city:\"CA\",state:\"\",zipCode:\"95126\",Time:\"09:00 PM\"},{ID:2104347,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:2464,Place:\"ATheaters\",address:\"2901 Capital\",city:\"C\",state:\"TT\",Time:\"06:00 PM\"},{ID:2104348,date:\"2022-11-15T00:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:2464,Place:\"ATheaters\",address:\"2901 Capital\",city:\"ANNNN\",state:\"TT\",Time:\"10:00 PM\"},{ID:2103857,date:\"2022-11-05T16:30:00\",day:\"5\",weekDay:\"Sat\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\" 4:30 PM\"},{ID:2103858,date:\"2022-11-05T23:30:00\",day:\"5\",weekDay:\"Sat\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\"11:30 PM\"},{ID:2103862,date:\"2022-11-15T23:00:00\",day:\"15\",weekDay:\"Tue\",month:\"Nov\",Placeid:34771,Place:\"Playhouse\",address:\"525 Palace\",city:\"BBBB\",state:\"YYYYY\",Time:\"11:00 PM\"}]\nlet r = Object.values(data.reduce((a,\n {day, date, weekDay, month})=>(a[`|${day}`]??={day, date, weekDay, month,\n Places: Object.values(data.filter(i=>i.day===day).reduce((b, {\n Placeid, Place, address, city, state})=>(b[`${day}|${Placeid}`]??={\n Placeid, Place, address, city, state,\n Timings: data.filter(j=>j.day===day && j.Placeid===Placeid)\n .map(j=>({ID: j.ID, Time: j.Time}))}, b), {}))}, a), {}));\nconsole.log(r);"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20014626/"
] |
74,312,883 | <p>I'm having a Column widget which contain a list of widgets. And this column is inside a SingleChildScrollView. For some reasons I need to autoscroll to the third child of the column while clicking the floating button.</p>
<p>My code looks somewhat like this.</p>
<pre><code>SingleChildScrollView(
child: Column(
children: [
Column(
children:[ getWidget1(), getWidget2(), getWidget3()],
),
],
),
),
</code></pre>
| [
{
"answer_id": 74312994,
"author": "Emre Faruk KOLAÇ",
"author_id": 12040178,
"author_profile": "https://Stackoverflow.com/users/12040178",
"pm_score": 3,
"selected": true,
"text": " final ItemScrollController itemScrollController = ItemScrollController();\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14668183/"
] |
74,312,913 | <p>I have a dataset with bunch of repeated observation like this.</p>
<pre><code> Id Date Group Diagnosis
1 8/16/2004 Red A
1 8/16/2004 Red B
1 8/16/2004 Red C
2 4/23/2010 Blue A
2 4/23/2010 Blue C
3 5/13/2006 Blue A
3 5/13/2006 Blue B
3 5/13/2006 Blue C
3 6/05/2011 Blue A
3 6/05/2011 Blue B
3 6/05/2011 Blue C
4 10/06/2009 Blue A
4 10/06/2009 Blue B
4 10/06/2009 Blue C
4 7/22/2010 Blue A
4 7/22/2010 Blue B
</code></pre>
<p>I like to create an new indicator value that tracks which observation have only one set of observations and which have two . Among those who have two sets of observations the indcator should indicate which is the 1st and 2nd so on.</p>
<pre><code>Expected output
Id Date Group Diagnosis I
1 8/16/2004 Red A 1-1
1 8/16/2004 Red B 1-1
1 8/16/2004 Red C 1-1
2 4/23/2010 Blue A 1-1
2 4/23/2010 Blue C 1-1
3 5/13/2006 Blue A 2-1
3 5/13/2006 Blue B 2-1
3 5/13/2006 Blue C 2-1
3 6/05/2011 Blue A 2-2
3 6/05/2011 Blue B 2-2
3 6/05/2011 Blue C 2-2
4 10/06/2009 Blue A 2-1
4 10/06/2009 Blue B 2-1
4 10/06/2009 Blue C 2-1
4 7/22/2010 Blue A 2-2
4 7/22/2010 Blue B 2-2
</code></pre>
<p>Values in column I is 1-1 for Id 1 and Id 2 because both these Ids have only once set of Diagnosis, Id 1 evaluated on 8/16/2004 and Id 2 evaluated on 4/23/2010</p>
<p>Values in column I is 2-1 for Id 3 and Id 4 because both these Ids have two sets of Diagnosis, Id 3 evaluated on 5/13/2006 and 6/05/2011, Id 4 evaluated on 10/06/2009 and 7/22/2010. The first set of observations for Id 3 and Id 4 were on 5/13/2006 and 10/06/2009 so 2-1. The second set of observations for Id 3 and Id 4 were on 6/05/2011 and 7/22/2010 so 2-2</p>
<p>I tried <code>n()</code> and <code>n_distinct</code> using <code>group_by( Id,Group, Diagnosis)</code> but this not working. So any suggestions or help is much appreciated. Thanks.</p>
| [
{
"answer_id": 74313048,
"author": "Just James",
"author_id": 19730031,
"author_profile": "https://Stackoverflow.com/users/19730031",
"pm_score": 3,
"selected": true,
"text": "library(dplyr)\n\ndf |> \n group_by(Id) |> \n mutate(I = paste0(n_distinct(Date), \"-\", match(Date, unique(Date)))) |> \n ungroup()\n"
},
{
"answer_id": 74313112,
"author": "Rui Barradas",
"author_id": 8245406,
"author_profile": "https://Stackoverflow.com/users/8245406",
"pm_score": 2,
"selected": false,
"text": "dplyr"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18795729/"
] |
74,312,933 | <p>I have a python 2D array like this:</p>
<pre><code>array = [('aaa', 20), ('bbb', 30), ('ccc', 40), ('ddd', 50)]
</code></pre>
<p>I want to filter this array based on the 2nd value in each set.
for example I want to keep only the items having the <strong>2nd item >= 40</strong></p>
<p><strong>Expected output:</strong></p>
<pre><code>filtered_array = [('ccc', 40), ('ddd', 50)]
</code></pre>
<p>I can achieve this with loops but is there an elegant way of filtering this?</p>
| [
{
"answer_id": 74313010,
"author": "DYZ",
"author_id": 4492932,
"author_profile": "https://Stackoverflow.com/users/4492932",
"pm_score": 0,
"selected": false,
"text": "filter"
},
{
"answer_id": 74313031,
"author": "Mateen Ulhaq",
"author_id": 365102,
"author_profile": "https://Stackoverflow.com/users/365102",
"pm_score": -1,
"selected": true,
"text": "[x for x in xs if x[1] >= 40]\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4654120/"
] |
74,312,953 | <p>I am loading images from <code>drawables</code> folder to the <code>buttons</code> with following code.</p>
<pre><code>Icon(
painter=painterResource(R.drawable.imageName),
modifier=Modifier.size(30.dp),
contentDescription="drawable icons",
tint=Color.Unspecified
)
</code></pre>
<p>But I want to use that code in a loop with a <code>string array</code> such as</p>
<pre><code>val imageNames = arrayOf("image1", "image2")
for (k in imageNames.indices) {
Icon(
painter=painterResource(R.drawable.imageNames[k]),
modifier=Modifier.size(30.dp),
contentDescription="drawable icons",
tint=Color.Unspecified
)
}
</code></pre>
| [
{
"answer_id": 74313020,
"author": "z.y",
"author_id": 19023745,
"author_profile": "https://Stackoverflow.com/users/19023745",
"pm_score": 3,
"selected": true,
"text": "String"
},
{
"answer_id": 74313076,
"author": "Syed Ibrahim",
"author_id": 15360188,
"author_profile": "https://Stackoverflow.com/users/15360188",
"pm_score": 0,
"selected": false,
"text": "@Composable\nfun ImageList() {\n\n//declare your list as resource types\nval imagesNames = arrayOf(R.drawable.image1,R.drawable.image2)\n\nColumn {\n imageNames.forEach { image ->\n Icon(\n painter=painterResource(image),\n modifier=Modifier.size(30.dp),\n contentDescription=\"drawable icons\",\n tint=Color.Unspecified\n )\n }\n }\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2692027/"
] |
74,312,956 | <p>I was wondering if it is possible to dynamically allocate a vector using new keyword, similar to an array.</p>
<p>what I mean is this:</p>
<pre><code>vector<int> *vptr = new vector<int>;
</code></pre>
<p>I could not find proper reference about this problem over the internet.
I would like to know what the below statement means. Both are valid syntax.
Also how to dereference the pointer here.</p>
<pre><code>vector<int> *vptr = new vector<int>[10];
vector<int> *vptr1 = new vector<int>(2,5);
</code></pre>
| [
{
"answer_id": 74313114,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 2,
"selected": false,
"text": "std::vector"
},
{
"answer_id": 74313430,
"author": "tcyla",
"author_id": 16527945,
"author_profile": "https://Stackoverflow.com/users/16527945",
"pm_score": 2,
"selected": true,
"text": "#include <iostream>\n#include <vector>\n\n\nusing namespace std;\n\nint main() {\n // v is pointer toward a vector<int>\n vector<int> *v = new vector<int>();\n // So we should use '->' to dereference\n // and use the method push_back\n v->push_back(1);\n v->push_back(2);\n v->push_back(3);\n for (auto i = 0u; i < v->size(); i++) {\n // we are using at method to access \n // elements as it is more readable \n // than (*v)[i]\n cout << v->at(i) << endl;\n }\n // v1 is an array of vector<int>\n vector<int> *v1 = new vector<int>[10];\n for (int i = 0; i < 10; i++) {\n // we access to the ith vector with \n // the [] operator same way we deal \n // with other arrays. v[i] is of type \n // vector so we use directly the push_back method\n v1[i].push_back(i);\n }\n for (int i = 0; i < 10; i++) {\n cout << v1[i][0] << endl;\n }\n delete [] v1;\n \n // same as v\n vector<int> *v2 = new vector<int>(2, 3);\n for (auto i = 0u; i < v2->size(); i++) {\n cout << v2->at(i) << endl;\n }\n\n return 0;\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17842249/"
] |
74,312,977 | <p>So I am trying to load one of these urls to <code>new Image</code> however all of them doesn't seem to load. I have an image.onload function but it doesn't go there. But if I remove the image.crossOrigin, it works. But the problem is if I remove the crossOrigin. I will get a canvas tainted error in my function inside the onload.</p>
<p>Here is a sample jsfiddle: <a href="https://jsfiddle.net/p3b7y8ns/2/" rel="nofollow noreferrer">https://jsfiddle.net/p3b7y8ns/2/</a></p>
<pre><code>const corrupt_svg = 'https://files.23point5.com/file?path=/artist-library/5119c74c-
c072-4913-9dca-89b616306f1c.svg'
const fixed_svg = 'https://dev-files.23point5.com/file?path=/artist-library/aaa4f68f-
02f1-49a4-bf21-fc3c54a28d23.svg'
const normal_image ='https://dev-files.23point5.com/file?path=/artist-
library/865a8f92-5c5b-466e-96e5-04a668bc3294.jpeg'
console.log('running')
const image = new Image()
image.crossOrigin = 'Anonymous'
image.onload = () => {
console.log('loaded')
console.log("image", image);
const canvas = document.createElement("canvas");
canvas.width = image.naturalWidth;
canvas.height = image.naturalHeight;
const ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
console.log("canvas", canvas);
canvas.toDataURL();
}
image.src = normal_image
</code></pre>
| [
{
"answer_id": 74400742,
"author": "John Lyle Pabilona",
"author_id": 15435618,
"author_profile": "https://Stackoverflow.com/users/15435618",
"pm_score": 2,
"selected": true,
"text": "<foreignObject></foreignObject>"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12543735/"
] |
74,312,995 | <p>The docs for <a href="https://docs.python.org/3/library/logging.html#logging.Logger.setLevel" rel="nofollow noreferrer"><code>logging.Logger.setLevel</code></a> state the following:</p>
<blockquote>
<p>When a logger is created, the level is set to NOTSET (which causes all messages to be processed when the logger is the root logger, or delegation to the parent when the logger is a non-root logger). Note that the root logger is created with level WARNING.</p>
<p>The term ‘delegation to the parent’ means that if a logger has a level of NOTSET, its chain of ancestor loggers is traversed until either an ancestor with a level other than NOTSET is found, or the root is reached.</p>
<p>If an ancestor is found with a level other than NOTSET, then that ancestor’s level is treated as the effective level of the logger where the ancestor search began, and is used to determine how a logging event is handled.</p>
<p>If the root is reached, and it has a level of NOTSET, then all messages will be processed. Otherwise, the root’s level will be used as the effective level.</p>
</blockquote>
<p>I ran into this issue recently trying to set a non-root logger's level to <code>NOTSET</code>, so that it would log everything I threw at it. Instead, it just cut off less severe messages to the default setting of the root logger.</p>
<p>How do I make a non-root logger log all messages of any severity <em>without</em> delegating to a parent at any point?</p>
| [
{
"answer_id": 74313096,
"author": "Mad Physicist",
"author_id": 2988730,
"author_profile": "https://Stackoverflow.com/users/2988730",
"pm_score": 0,
"selected": false,
"text": "NOTSET"
},
{
"answer_id": 74347374,
"author": "blues",
"author_id": 803194,
"author_profile": "https://Stackoverflow.com/users/803194",
"pm_score": 1,
"selected": false,
"text": "logger = logging.getLogger('name') # non-root logger\nlogger.propagate = False # never delegate to a parent\nlogger.setLevel(logging.DEBUG) # debug is the lowest existing log level, so this will log everything\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74312995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2988730/"
] |
74,313,002 | <p>I am trying to get the values of the data parameter from an emmitted value in my second component</p>
<p>Here is my code</p>
<p><em>Component 1 TS</em></p>
<pre><code>this.myService.emitChange({emitValue: 'openFunctionInSidePanel', data: data });
</code></pre>
<p><em>Component 2 Service file</em></p>
<pre><code>private emitChangeSource = new Subject<any>();
changeEmitted$ = this.emitChangeSource.asObservable();
emitChange(event) {
this.emitChangeSource.next(event);
}
</code></pre>
<p>Component 2 TS</p>
<pre><code>console.log(this.myService.emitChange);
</code></pre>
<p>So how would I get the actual data value in my component 2.ts file?</p>
<p>I currently see</p>
<pre><code>ƒ (event) {
this.emitChangeSource.next(event);
}
</code></pre>
| [
{
"answer_id": 74313096,
"author": "Mad Physicist",
"author_id": 2988730,
"author_profile": "https://Stackoverflow.com/users/2988730",
"pm_score": 0,
"selected": false,
"text": "NOTSET"
},
{
"answer_id": 74347374,
"author": "blues",
"author_id": 803194,
"author_profile": "https://Stackoverflow.com/users/803194",
"pm_score": 1,
"selected": false,
"text": "logger = logging.getLogger('name') # non-root logger\nlogger.propagate = False # never delegate to a parent\nlogger.setLevel(logging.DEBUG) # debug is the lowest existing log level, so this will log everything\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5853403/"
] |
74,313,022 | <p>My <strong>traversal</strong> argument is raising NoneType where I am expecting it to be a string</p>
<pre><code>class node(object):
def __init__(self,value):
self.value= value
self.left= None
self.right= None
class binarytree(object):
def __init__(self,root):
self.root=node(root)
def print_tree(self,traversal_type):
if traversal_type == "preorder":
return self.preorder_print(self.root,"")
else:
return f"Traversal type {traversal_type} not supported."
def preorder_print(self,start,traversal):
if start:
traversal += (str(start.value)+"-")
traversal= self.preorder_print(start.left,traversal)
traversal= self.preorder_print(start.right,traversal)
return traversal
tree=binarytree(1)
tree.root.left=node(2)
tree.root.right=node(3)
tree.root.left.left=node(4)
tree.root.left.right=node(5)
print(tree.print_tree("preorder"))
</code></pre>
<p>I was expecting string and got NoneType.
In line 12</p>
<pre><code>return self.preorder_print(self.root,"")
</code></pre>
<p>The "" is a str type but in line 16</p>
<pre><code>traversal += (str(start.value)+"-")
</code></pre>
<p>error occurs which says</p>
<pre><code>unsupported operand type(s) for +=: 'NoneType' and 'str'
</code></pre>
| [
{
"answer_id": 74313096,
"author": "Mad Physicist",
"author_id": 2988730,
"author_profile": "https://Stackoverflow.com/users/2988730",
"pm_score": 0,
"selected": false,
"text": "NOTSET"
},
{
"answer_id": 74347374,
"author": "blues",
"author_id": 803194,
"author_profile": "https://Stackoverflow.com/users/803194",
"pm_score": 1,
"selected": false,
"text": "logger = logging.getLogger('name') # non-root logger\nlogger.propagate = False # never delegate to a parent\nlogger.setLevel(logging.DEBUG) # debug is the lowest existing log level, so this will log everything\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414615/"
] |
74,313,025 | <p>I would like to retrieve the full height of the viewport on iOS Safari via JavaScript. <code>window.innerHeight</code> is unreliable because it changes as the UI contracts. On my iPhone 12, the following is reported:</p>
<ul>
<li>When the page loads, <code>window.innerHeight</code> is 664px.</li>
<li>As I scroll, <code>window.innerHeight</code> is increased (eg. 707px).</li>
<li>Once the UI has fully contracted, <code>window.innerHeight</code> is consistently 745px.</li>
</ul>
<p>In CSS, <code>100vh</code> gives me the full height of the viewport when the page loads. Thus I can insert an element to manually measure it:</p>
<pre class="lang-js prettyprint-override"><code>let d = document.createElement('div');
d.style.position = 'absolute';
d.style.width = '1px';
d.style.height = '100vh';
document.body.prepend(d);
dh = d.clientHeight; // 745px
</code></pre>
<p>Is it possible to get the value of <code>100vh</code> in pixels without inserting an element? There are <a href="https://dev.to/frehner/css-vh-dvh-lvh-svh-and-vw-units-27k4" rel="nofollow noreferrer">new CSS units</a> that accomodate for the changes to the viewport but I'm not sure if there are equivalents in JS.</p>
<p>Thanks for your time and apologies if this is a duplicate question, I could not find it asked before.</p>
| [
{
"answer_id": 74313096,
"author": "Mad Physicist",
"author_id": 2988730,
"author_profile": "https://Stackoverflow.com/users/2988730",
"pm_score": 0,
"selected": false,
"text": "NOTSET"
},
{
"answer_id": 74347374,
"author": "blues",
"author_id": 803194,
"author_profile": "https://Stackoverflow.com/users/803194",
"pm_score": 1,
"selected": false,
"text": "logger = logging.getLogger('name') # non-root logger\nlogger.propagate = False # never delegate to a parent\nlogger.setLevel(logging.DEBUG) # debug is the lowest existing log level, so this will log everything\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1564553/"
] |
74,313,037 | <p>Hello in my app when I click for the next page it takes one second and shows a white screen and then shows me my desired page why does this happen how to remove this delay, anyone, please??</p>
| [
{
"answer_id": 74313096,
"author": "Mad Physicist",
"author_id": 2988730,
"author_profile": "https://Stackoverflow.com/users/2988730",
"pm_score": 0,
"selected": false,
"text": "NOTSET"
},
{
"answer_id": 74347374,
"author": "blues",
"author_id": 803194,
"author_profile": "https://Stackoverflow.com/users/803194",
"pm_score": 1,
"selected": false,
"text": "logger = logging.getLogger('name') # non-root logger\nlogger.propagate = False # never delegate to a parent\nlogger.setLevel(logging.DEBUG) # debug is the lowest existing log level, so this will log everything\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17579670/"
] |
74,313,058 | <p>I have some coroutine that should be relaunched on each <code>onResume()</code> call of <code>Fragment</code>.</p>
<p>I have tried the following approach:</p>
<pre class="lang-kotlin prettyprint-override"><code>val renderer = ...
val outerFlow = ...
val lifecycleCoroutineScope = myFragment.viewLifecycleOwner.lifecycleScope
lifecycleCoroutineScope.launchWhenResumed {
outerFlow.onEach(renderer::render).launchIn(this)
}
</code></pre>
<p>But it only works until the <code>Fragment</code>'s view destroyed first time. I mean the second and the following <code>onResume()</code> calls became ignored.</p>
<p>So please help me to find out: <strong>how to properly launch my coroutine on each <code>onResume()</code> call?</strong></p>
| [
{
"answer_id": 74313145,
"author": "Sergio",
"author_id": 1731626,
"author_profile": "https://Stackoverflow.com/users/1731626",
"pm_score": 1,
"selected": false,
"text": "launchIn(this)"
},
{
"answer_id": 74315149,
"author": "Denis Perfomer",
"author_id": 5328992,
"author_profile": "https://Stackoverflow.com/users/5328992",
"pm_score": 1,
"selected": true,
"text": "LifecycleOwner"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5328992/"
] |
74,313,081 | <p>I have this component in react and even after the state has been changed react component is not re-rendering.</p>
<pre><code>import { useState, useEffect } from "react";
const Game = (props) =\> {
const [pokemonData, setPokemonData] = useState([]);
const shufflePokemon = () => {
console.log("pokemon is shuffling....")
let temp = pokemonData;
for (let i = temp.length - 1; i >= 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var t = temp[i];
temp[i] = temp[j];
temp[j] = t;
}
setPokemonData(temp);
console.log(pokemonData);
}
useEffect(() => {
setPokemonData(props.data);
}, [props.data])
return (
<div>
{console.log("rendering")}
{
pokemonData.length === 0 ? null :
pokemonData.map((curr) => {
return (
<div onClick={shufflePokemon} key={curr.id} >
<img src={curr.image} />
<p>{curr.name}</p>
</div>
)
})
}
</div>
)
}
</code></pre>
<p>I known that state has been changed because when i <code>console.log(pokemonData)</code> it shows me new shuffled list of pokemon data.
But component is not re rendering.</p>
<p>When i click on any div containing pokemon image i want them to shuffle as well but component is not re-rendering even though state is changed so they are not changining on change of state.</p>
| [
{
"answer_id": 74313145,
"author": "Sergio",
"author_id": 1731626,
"author_profile": "https://Stackoverflow.com/users/1731626",
"pm_score": 1,
"selected": false,
"text": "launchIn(this)"
},
{
"answer_id": 74315149,
"author": "Denis Perfomer",
"author_id": 5328992,
"author_profile": "https://Stackoverflow.com/users/5328992",
"pm_score": 1,
"selected": true,
"text": "LifecycleOwner"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18173928/"
] |
74,313,088 | <p>There is a from with various elements</p>
<pre><code><input name='id' value='123'/>
<input name='some_value' value='123'/>
<!-- thing that i want-->
<input name='array[key_1]' value='value_1'/>
<input name='array[key_2]' value='value_2'/>
<input name='array[key_3]' value='value_3'/>
<input name='array[key_4]' value='value_4'/>
</form>
</code></pre>
<p>If i've been used PHP, array data will be collected in $_POST["array"]
So the questions is, how to collect dict "array" in django views?</p>
| [
{
"answer_id": 74313280,
"author": "Sunderam Dubey",
"author_id": 17562044,
"author_profile": "https://Stackoverflow.com/users/17562044",
"pm_score": 0,
"selected": false,
"text": "name"
},
{
"answer_id": 74317073,
"author": "Mahammadhusain kadiwala",
"author_id": 19205926,
"author_profile": "https://Stackoverflow.com/users/19205926",
"pm_score": 1,
"selected": false,
"text": "def DemotimeView(request):\n if request.method == 'POST': \n data = dict(request.POST)\n del data['csrfmiddlewaretoken']\n print({i:j[0] for i,j in data.items()})\n return render(request, 'index.html',)\n"
},
{
"answer_id": 74321146,
"author": "Yuretz",
"author_id": 2797922,
"author_profile": "https://Stackoverflow.com/users/2797922",
"pm_score": 1,
"selected": true,
"text": "<input type=\"text\" name=\"name\" \n value='Yuretz'/>\n<input type=\"text\" name=\"last_name\" \n value='Oguretz'/>\n\n{% for line in print_values %}\n<div>\n <b>{{line.name}}</b><br/>\n <input type=\"text\" \n name=\"param__{{line.name}}\"\n value=\"{{line.value}}\"/>\n</div>\n{% endfor %}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2797922/"
] |
74,313,108 | <p>I've created some code as seen below for declaring the values of an array. However, I know there is another way to do this using if statements, would you be able to show me that way too? N,Q,L,R and K are the valid codes and the "default" one is when an invalid code (any letter except for the listed ones) is given.</p>
<p>Have put code below - also let me know if more info is needed:</p>
<pre><code>public void setInfo(string c)
{
switch (c)
{
case "K":
event_code = event_codes[0];
break;
case "L":
event_code = event_codes[1];
break;
case "R":
event_code = event_codes[2];
break;
case "Q":
event_code = event_codes[3];
break;
case "N":
event_code = event_codes[4];
break;
default:
event_code = "I";
break;
}
}
</code></pre>
| [
{
"answer_id": 74313280,
"author": "Sunderam Dubey",
"author_id": 17562044,
"author_profile": "https://Stackoverflow.com/users/17562044",
"pm_score": 0,
"selected": false,
"text": "name"
},
{
"answer_id": 74317073,
"author": "Mahammadhusain kadiwala",
"author_id": 19205926,
"author_profile": "https://Stackoverflow.com/users/19205926",
"pm_score": 1,
"selected": false,
"text": "def DemotimeView(request):\n if request.method == 'POST': \n data = dict(request.POST)\n del data['csrfmiddlewaretoken']\n print({i:j[0] for i,j in data.items()})\n return render(request, 'index.html',)\n"
},
{
"answer_id": 74321146,
"author": "Yuretz",
"author_id": 2797922,
"author_profile": "https://Stackoverflow.com/users/2797922",
"pm_score": 1,
"selected": true,
"text": "<input type=\"text\" name=\"name\" \n value='Yuretz'/>\n<input type=\"text\" name=\"last_name\" \n value='Oguretz'/>\n\n{% for line in print_values %}\n<div>\n <b>{{line.name}}</b><br/>\n <input type=\"text\" \n name=\"param__{{line.name}}\"\n value=\"{{line.value}}\"/>\n</div>\n{% endfor %}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19358944/"
] |
74,313,130 | <p>I've hosted WCFCore in .net 6 Console App. Code is below:</p>
<pre><code>[ServiceContract]
public interface IServiceAPI
{
[OperationContract(IsOneWay = true)]
void DoWork();
}
public class ServiceAPI : IServiceAPI
{
IServiceAPICallBack Callback
{
get
{
return OperationContext.Current.GetCallbackChannel<IServiceAPICallBack>();
}
}
public void DoWork()
{
Callback.Result(2);
}
}
</code></pre>
<p>Program.cs</p>
<pre><code> using CoreWCF;
using CoreWCF.Channels;
using CoreWCF.Configuration;
using CoreWCF.Description;
using System.Web.Services.Description;
using TestApp;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel((context, options) =>
{
options.AllowSynchronousIO = true;
});
// Add WSDL support
builder.Services.AddServiceModelServices().AddServiceModelMetadata();
builder.Services.AddSingleton<IServiceBehavior, UseRequestHeadersForMetadataAddressBehavior>();
var app = builder.Build();
var myWSHttpBinding = new WSHttpBinding(SecurityMode.Transport);
myWSHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
app.UseServiceModel(builder =>
{
builder.AddService<ServiceAPI>();
builder.AddServiceEndpoint<ServiceAPI, IServiceAPI>(new BasicHttpBinding(), "/ServiceAPI/basichttp");
builder.AddServiceEndpoint<ServiceAPI, IServiceAPI>(myWSHttpBinding, "/cowork");
});
var serviceMetadataBehavior = app.Services.GetRequiredService<ServiceMetadataBehavior>();
serviceMetadataBehavior.HttpGetEnabled = true;
app.Run();
</code></pre>
<p>When add Service reference from Client App I'm getting this error:</p>
<pre><code> info: CoreWCF.Channels.ServiceModelHttpMiddleware[0]
Mapping CoreWCF branch app for path /ServiceAPI/basichttp
info: CoreWCF.Channels.ServiceModelHttpMiddleware[0]
Mapping CoreWCF branch app for path /coedit
info: CoreWCF.Channels.MetadataMiddleware[0]
Configuring metadata to /ServiceAPI/basichttp
info: CoreWCF.Channels.MetadataMiddleware[0]
Configuring metadata to /coedit
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: D:\Perforce\CoeditPOc\UWPToOtherCommunication\TestApp\
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
CoreWCF.ProtocolException: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8. The client and service bindings may be mismatched.
at CoreWCF.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
at CoreWCF.Channels.HttpInput.ValidateContentType()
at CoreWCF.Channels.HttpInput.ParseIncomingMessageAsync()
at CoreWCF.Channels.AspNetCoreReplyChannel.HandleRequest(HttpContext context)
at CoreWCF.Channels.RequestDelegateHandler.HandleRequest(HttpContext context)
at CoreWCF.Channels.ServiceModelHttpMiddleware.InvokeAsync(HttpContext context)
at CoreWCF.Channels.MetadataMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
CoreWCF.ProtocolException: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8. The client and service bindings may be mismatched.
at CoreWCF.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
at CoreWCF.Channels.HttpInput.ValidateContentType()
at CoreWCF.Channels.HttpInput.ParseIncomingMessageAsync()
at CoreWCF.Channels.AspNetCoreReplyChannel.HandleRequest(HttpContext context)
at CoreWCF.Channels.RequestDelegateHandler.HandleRequest(HttpContext context)
at CoreWCF.Channels.ServiceModelHttpMiddleware.InvokeAsync(HttpContext context)
at CoreWCF.Channels.MetadataMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
CoreWCF.ProtocolException: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8. The client and service bindings may be mismatched.
at CoreWCF.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
at CoreWCF.Channels.HttpInput.ValidateContentType()
at CoreWCF.Channels.HttpInput.ParseIncomingMessageAsync()
at CoreWCF.Channels.AspNetCoreReplyChannel.HandleRequest(HttpContext context)
at CoreWCF.Channels.RequestDelegateHandler.HandleRequest(HttpContext context)
at CoreWCF.Channels.ServiceModelHttpMiddleware.InvokeAsync(HttpContext context)
at CoreWCF.Channels.MetadataMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
CoreWCF.ProtocolException: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8. The client and service bindings may be mismatched.
at CoreWCF.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
at CoreWCF.Channels.HttpInput.ValidateContentType()
at CoreWCF.Channels.HttpInput.ParseIncomingMessageAsync()
at CoreWCF.Channels.AspNetCoreReplyChannel.HandleRequest(HttpContext context)
at CoreWCF.Channels.RequestDelegateHandler.HandleRequest(HttpContext context)
at CoreWCF.Channels.ServiceModelHttpMiddleware.InvokeAsync(HttpContext context)
at CoreWCF.Channels.MetadataMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
CoreWCF.ProtocolException: Content Type application/soap+xml; charset=utf-8 was sent to a service expecting text/xml; charset=utf-8. The client and service bindings may be mismatched.
at CoreWCF.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
at CoreWCF.Channels.HttpInput.ValidateContentType()
at CoreWCF.Channels.HttpInput.ParseIncomingMessageAsync()
at CoreWCF.Channels.AspNetCoreReplyChannel.HandleRequest(HttpContext context)
at CoreWCF.Channels.RequestDelegateHandler.HandleRequest(HttpContext context)
at CoreWCF.Channels.ServiceModelHttpMiddleware.InvokeAsync(HttpContext context)
at CoreWCF.Channels.MetadataMiddleware.InvokeAsync(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
</code></pre>
<p><strong>I've tried add service reference from visual studio.</strong></p>
<p><code>appsettings.json</code></p>
<pre><code>{
"Urls": "http://localhost:5000;https://localhost:5001",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
</code></pre>
| [
{
"answer_id": 74313280,
"author": "Sunderam Dubey",
"author_id": 17562044,
"author_profile": "https://Stackoverflow.com/users/17562044",
"pm_score": 0,
"selected": false,
"text": "name"
},
{
"answer_id": 74317073,
"author": "Mahammadhusain kadiwala",
"author_id": 19205926,
"author_profile": "https://Stackoverflow.com/users/19205926",
"pm_score": 1,
"selected": false,
"text": "def DemotimeView(request):\n if request.method == 'POST': \n data = dict(request.POST)\n del data['csrfmiddlewaretoken']\n print({i:j[0] for i,j in data.items()})\n return render(request, 'index.html',)\n"
},
{
"answer_id": 74321146,
"author": "Yuretz",
"author_id": 2797922,
"author_profile": "https://Stackoverflow.com/users/2797922",
"pm_score": 1,
"selected": true,
"text": "<input type=\"text\" name=\"name\" \n value='Yuretz'/>\n<input type=\"text\" name=\"last_name\" \n value='Oguretz'/>\n\n{% for line in print_values %}\n<div>\n <b>{{line.name}}</b><br/>\n <input type=\"text\" \n name=\"param__{{line.name}}\"\n value=\"{{line.value}}\"/>\n</div>\n{% endfor %}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6176507/"
] |
74,313,135 | <p>When you create a new project in Android Studio selecting the template Jetpack Compose Material3 you get a project which defines following in themes.xml:</p>
<pre><code><style name="Theme.ComposeMaterial3" parent="android:Theme.Material.Light.NoActionBar" />
</code></pre>
<ol>
<li><p>Is this being used by the project at all since the Composables<br />
reference Material3 styles? (ComposeMaterial3Theme)</p>
</li>
<li><p>Why does this not set as parent "Theme.Material3..."?</p>
</li>
</ol>
| [
{
"answer_id": 74313580,
"author": "Gabriele Mariotti",
"author_id": 2016562,
"author_profile": "https://Stackoverflow.com/users/2016562",
"pm_score": 2,
"selected": false,
"text": "Theme.kt"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1690017/"
] |
74,313,148 | <pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.1d1 20130915//EN" "JATS-journalpublishing1.dtd"[]>
<article dtd-version="1.1d1" article-type="review-article" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xml:lang="en">
<front>
<?covid19?>
</code></pre>
<p>I need to find if the <code><?covid19?></code> processing instruction is present in the XML or not.</p>
<p>Pseudo-code in jQuery:</p>
<pre class="lang-js prettyprint-override"><code>$("<?covid19?>").length
</code></pre>
| [
{
"answer_id": 74324293,
"author": "Sebastian Simon",
"author_id": 4642212,
"author_profile": "https://Stackoverflow.com/users/4642212",
"pm_score": 1,
"selected": false,
"text": "XMLDocument"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7022857/"
] |
74,313,155 | <p>I've been trying to replace a list of substrings that can be present in a column in Hive:
Examples of such strings: "SA", "DE", "CV", "MI" etc.</p>
<p>I tried to replace them using the <code>regexp_replace</code> function in Hive. To test it out I wrote down the following query:</p>
<p><code>select regexp_replace(company_name," DE | SA | CV ", " "), company_name from table limit 20;</code></p>
<p>I thought it would tackle all cases but then I had the following output for the same:</p>
<p>ALCA SA DE CV ->>>>>>>>> ALCA DE CV</p>
<p>MEXICANA DE LAMINACION SA CV ->>>>>>>> MEXICANA LAMINACION CV</p>
<p>I tried inserting \s* at the start and front of the characters as well but the output was the same. Is there a way to replace them all in one go? Thank you</p>
| [
{
"answer_id": 74324293,
"author": "Sebastian Simon",
"author_id": 4642212,
"author_profile": "https://Stackoverflow.com/users/4642212",
"pm_score": 1,
"selected": false,
"text": "XMLDocument"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414714/"
] |
74,313,180 | <p>How to prevent floating-point being implicitly converted to integral value at function call?</p>
<pre><code>#include <iostream>
void fn(int x) {
std::cout<<"fn("<<x<<")\n";
}
int main() {
std::cout<<"Hello, this is 301014 :)\n";
fn(2);
fn(3.5);
return 0;
}
</code></pre>
<p>Here the outputs are 2 and 3 respectively.<br />
I am compiling with <code>g++ -std=c++11 31014.cpp -o 31014 -v</code>. And there is no mention of <strong>3.5</strong> being converted to <strong>3</strong>.<br />
Is there a way to prevent, or atleast detect, this?</p>
<p>Kindly help me out, please.</p>
| [
{
"answer_id": 74313261,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 4,
"selected": true,
"text": "fn"
},
{
"answer_id": 74313516,
"author": "Christian Halaszovich",
"author_id": 16920195,
"author_profile": "https://Stackoverflow.com/users/16920195",
"pm_score": 3,
"selected": false,
"text": "template<typename T> void fn(T)=delete;"
},
{
"answer_id": 74313658,
"author": "GAVD",
"author_id": 4983082,
"author_profile": "https://Stackoverflow.com/users/4983082",
"pm_score": 2,
"selected": false,
"text": "std::enable_if"
},
{
"answer_id": 74314343,
"author": "HolyBlackCat",
"author_id": 2752075,
"author_profile": "https://Stackoverflow.com/users/2752075",
"pm_score": 0,
"selected": false,
"text": "-Wconversion"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4743767/"
] |
74,313,186 | <p>I am new in shell script,</p>
<p>I want to pass two string arrays to function as an argument and want to access that in the function for further operation.</p>
<p>Please help me in that.</p>
<p>Thank you.</p>
| [
{
"answer_id": 74313261,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 4,
"selected": true,
"text": "fn"
},
{
"answer_id": 74313516,
"author": "Christian Halaszovich",
"author_id": 16920195,
"author_profile": "https://Stackoverflow.com/users/16920195",
"pm_score": 3,
"selected": false,
"text": "template<typename T> void fn(T)=delete;"
},
{
"answer_id": 74313658,
"author": "GAVD",
"author_id": 4983082,
"author_profile": "https://Stackoverflow.com/users/4983082",
"pm_score": 2,
"selected": false,
"text": "std::enable_if"
},
{
"answer_id": 74314343,
"author": "HolyBlackCat",
"author_id": 2752075,
"author_profile": "https://Stackoverflow.com/users/2752075",
"pm_score": 0,
"selected": false,
"text": "-Wconversion"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3522538/"
] |
74,313,212 | <p>Javascript Popup sample on page load, you can set timer also</p>
<pre><code> // alert('update')
if (confirm("Popup Shown here") == true) {
window.open("https://example.com/", '_blank');
}
</code></pre>
| [
{
"answer_id": 74313343,
"author": "Saad1430",
"author_id": 19199222,
"author_profile": "https://Stackoverflow.com/users/19199222",
"pm_score": 2,
"selected": false,
"text": "MP4"
},
{
"answer_id": 74326280,
"author": "Saad1430",
"author_id": 19199222,
"author_profile": "https://Stackoverflow.com/users/19199222",
"pm_score": 1,
"selected": false,
"text": "m3u8"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20080524/"
] |
74,313,234 | <p>I already have a stored procedure for the search filter but it's complex and long, how do enhance the stored procedure code?</p>
<p>I have 3 search filters: group, key and label, these search filters are related to one another.</p>
<p>My stored procedure code:</p>
<pre><code>IF (@group <> '' AND @key <> '' AND @label <> '')
BEGIN
SET @statement =
@statement + ' WHERE ([group] LIKE ''%' + @group + '%'' AND [key] LIKE ''%' + @key + '%'' AND [label] LIKE ''%' + @label + '%'')'
END
ELSE IF (@group <> '' AND @key <> '')
BEGIN
SET @statement =
@statement + ' WHERE ([group] LIKE ''%' + @group + '%'' AND [key] LIKE ''%' + @key + '%'')'
END
ELSE IF (@key <> '' AND @label <> '')
BEGIN
SET @statement =
@statement + ' WHERE ([key] LIKE ''%' + @key + '%'' AND [label] LIKE ''%' + @label + '%'')'
END
ELSE IF (@label <> '' AND @group <> '')
BEGIN
SET @statement =
@statement + ' WHERE ([label] LIKE ''%' + @label + '%'' AND [group] LIKE ''%' + @group + '%'')'
END
ELSE IF (@group <> '')
BEGIN
SET @statement
= @statement + ' WHERE [group] LIKE ''%' + @group + '%'''
END
ELSE IF (@key <> '')
BEGIN
SET @statement
= @statement + ' WHERE [key] LIKE ''%' + @key + '%'' '
END
ELSE IF (@label <> '')
BEGIN
SET @statement
= @statement + ' WHERE [label] LIKE ''%' + @label + '%'''
END
</code></pre>
<p>How do I modify the code to be simpler?</p>
| [
{
"answer_id": 74313447,
"author": "sanjay patel",
"author_id": 20299485,
"author_profile": "https://Stackoverflow.com/users/20299485",
"pm_score": 1,
"selected": false,
"text": " SET @statement = \n @statement + ' WHERE \n( (@group<>'' and [group] LIKE ''%' + @group + '%''') or (@group='' and 1=1))\n( (@key <>'' and [key] LIKE ''%' + @key + '%''') or (@key ='' and 1=1))\n( (@label <>'' and [label] LIKE ''%' + @label + '%''') or (@label ='' and 1=1))\n"
},
{
"answer_id": 74314539,
"author": "m-harding",
"author_id": 19843562,
"author_profile": "https://Stackoverflow.com/users/19843562",
"pm_score": 0,
"selected": false,
"text": "-- Procedure Input Arguments \nDECLARE \n @IntExample INT = NULL\n ,@StringExample VARCHAR(50) = NULL;\n\n\n-- Constants\nDECLARE @MinInt32 INT = (-2147483648), @MaxInt32 INT = 2147483647;\n\n-- Input Argument Validation\nDECLARE @IdMin INT = @MinInt32, @IdMax INT = @MaxInt32;\nIF (@IntExample IS NOT NULL)\nBEGIN\n SET @IdMin = @IntExample;\n SET @IdMax = @IntExample;\nEND\n\nDECLARE @DescFilter NVARCHAR(50) = '%';\nIF (@StringExample IS NOT NULL)\nBEGIN\n SET @DescFilter = '%' + @StringExample + '%';\nEND\n\n-- Procedure Query\nSELECT * \nFROM dbo.MyTable\nWHERE\n(\n Id BETWEEN @IdMin AND @IdMax\n AND [Description] LIKE @DescFilter\n);\n"
},
{
"answer_id": 74318988,
"author": "wnutt",
"author_id": 1665437,
"author_profile": "https://Stackoverflow.com/users/1665437",
"pm_score": 0,
"selected": false,
"text": "SELECT * \nFROM dbo.MyTable\nWHERE \n ((@group = '') OR ([group] LIKE '%' + @group + '%'))\nAND ((@key = '') OR ([key] LIKE '%' + @key + '%'))\nAND ((@label = '') OR ([label] LIKE '%' + @label + '%'))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20181689/"
] |
74,313,238 | <p>I want to get the sales from the past 10 weeks. I can do that with this method:</p>
<pre><code>def past_10_sales(yw)
past_sales = []
year_week = yw
10.times do
sales = Sales.where(year_week: year_week.previous)
past_sales << sales unless sales.empty?
year_week = year_week.previous
end
past_sales.flatten
end
</code></pre>
<p>But now I need this method somewhere else as well and wanted to put it in the <code>sales.rb</code> model, but i don't know what the best practice of this would be or if there is something in Rails that makes this better? It feels wrong calling <code>Sales.where</code> in the <code>sales.rb</code> model...</p>
<p>Edit:
<code>year_week</code> is a model with the current year and calendar week. So the current year_week would be 202244. Calling <code>year_week.previous</code> gives me <code>202243</code>. I'm getting all the sales from a specific calendar week.
This works fine btw.</p>
<p>Edit 2:
I have a model <code>sales.rb</code>. in this model i save all the sales. it only matters in which calendar week the sales were made, the exact date does not matter so it looks something like this:</p>
<pre><code>create_table "sales" do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "year_week_id"
etc...
end
</code></pre>
<p>i also have a model <code>year_week</code> which just saves the year and the calendarweek and the id is like this: yearweek (so 202244). there are methods like <code>def previous</code> that return the previous year_week.</p>
<p>What i now want is all the sales form the past 10 weeks. so i call this:</p>
<pre><code> sales = Sales.where(year_week: year_week.previous)
past_sales << sales unless sales.empty?
year_week = year_week.previous
</code></pre>
<p>10 times because this way it gets all the sales in the past 10 weeks but it just doesn't feel right and i was wondering if/what better way there is for this.</p>
| [
{
"answer_id": 74313775,
"author": "Amol Mohite",
"author_id": 12111186,
"author_profile": "https://Stackoverflow.com/users/12111186",
"pm_score": -1,
"selected": true,
"text": "def past_10_sales(yw)\n year_week = yw.previous\n past_sales = Sales.where(year_week: (year_week-9..year_week.to_a))\nend\n"
},
{
"answer_id": 74316386,
"author": "max",
"author_id": 544825,
"author_profile": "https://Stackoverflow.com/users/544825",
"pm_score": 0,
"selected": false,
"text": "starting_week = Time.current.advance(weeks: -10).strftime(\"%Y%V\").to_i\nSale.where(\n year_week: starting_week.. \n)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19940362/"
] |
74,313,242 | <p>I 'am getting this error in all my buttons
some times it do what in the code sometimes the errors come early</p>
<pre><code>DiscordAPIError[40060]: Interaction has already been acknowledged.
at SequentialHandler.runRequest (C:\Users\ryuuo\Desktop\ryuu\node_modules\@discordjs\rest\dist\index.js:659:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (C:\Users\ryuuo\Desktop\ryuu\node_modules\@discordjs\rest\dist\index.js:458:14)
at async REST.request (C:\Users\ryuuo\Desktop\ryuu\node_modules\@discordjs\rest\dist\index.js:902:22)
at async ButtonInteraction.deferReply (C:\Users\ryuuo\Desktop\ryuu\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:69:5)
at async Object.execute (C:\Users\ryuuo\Desktop\ryuu\Buttons\languague.js:11:5) {
requestBody: { files: undefined, json: { type: 5, data: { flags: 64 } } },
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1037980437043236884/aW50ZXJhY3Rpb246MTAzNzk4MDQzNzA0MzIzNjg4NDpteWUxWkVidG8xY1VsUkpOU3Jxb3JJSnp2b2JwSlFtUUVqVnFEb0FNeEg4UUZqc1JNMWdyMkYxU3JNMDdPR2RDMEV2U3Q0TzByMkMzY1lQTk1kS09SVHh5SjEwR1daOHF6OVhWbEh0bDJYd1B6UFpIYXdMYktwczF3RXRxNVFFTA/callback'
}
</code></pre>
<p>I 'am using :
Discord.js Version 14.6.0
Node.js Version 18.11.0</p>
<p>I tried with a simple reply like</p>
<pre><code>client.on(Events.InteractionCreate, async(interaction) => {
if(!interaction.isButton()) return;
if(interaction.customId === "test")
await interaction.reply({
content: "Test worked",
ephemeral: true
});
});
</code></pre>
<p>and getting the same error after the bot reply
I tried also with a buttons handler and same</p>
<pre><code></code></pre>
| [
{
"answer_id": 74313950,
"author": "DragosPV",
"author_id": 18253371,
"author_profile": "https://Stackoverflow.com/users/18253371",
"pm_score": -1,
"selected": false,
"text": "if(interaction.customId === \"test\")"
},
{
"answer_id": 74675465,
"author": "Ryuu Osamu",
"author_id": 20414807,
"author_profile": "https://Stackoverflow.com/users/20414807",
"pm_score": 1,
"selected": true,
"text": " if (!interaction.isChatInputCommand) return;\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414807/"
] |
74,313,246 | <p>I tried changing the i and j variables but it doesn't seem to work.</p>
<pre class="lang-java prettyprint-override"><code>public static void main(String[] args) {
double[] nameArray = {20.0,30.2,25.2,75.23,20.0,2.0,25.22};
double tempElement;
for (int i=0; i < nameArray.length; i++)
{
// This inner loop selects and compares each remaining values to the selected element by the outer for loop.
for (int j=i+1; j < nameArray.length; j++)
{
// This if loop compares the elements.
if (nameArray[i] > nameArray[j]);
{
// This if loop will only run if the next array element is smaller than
// the previous array element being compared.
// This tempElement is used for proper assigning of the variables.
tempElement = nameArray[i];
nameArray[i] = nameArray[j];
nameArray[j] = tempElement;
}
}
}
// This for loop assigns the sorted elements in the descending order to the other array.
for (int i = 0; i<nameArray.length; i++)
{
System.out.println(nameArray[i]);
}
}
</code></pre>
| [
{
"answer_id": 74313338,
"author": "berse2212",
"author_id": 20184128,
"author_profile": "https://Stackoverflow.com/users/20184128",
"pm_score": 1,
"selected": false,
"text": ";"
},
{
"answer_id": 74313633,
"author": "mohamed",
"author_id": 15021356,
"author_profile": "https://Stackoverflow.com/users/15021356",
"pm_score": 0,
"selected": false,
"text": "(int i=0; i < nameArray.length-1; i++) "
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414861/"
] |
74,313,254 | <p>I'm calling a api with another api like</p>
<p><strong>First api have list like a labels:-</strong></p>
<pre><code>{
"body": [
{
"label": "label one",
"inputVal": "input value one"
},
{
"label": "label two",
"inputVal": "input value two"
}
]
}
</code></pre>
<p><strong>Second api will validate each label and input as we are using in first api:-</strong>
so I'm calling second api two time (it may be more than two) because I need to validate two label and input as in first api.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const [inputVal, setInputVal] = useState([]);
async function firstApi() {
axios
.post('first_api_url', {
title: "title",
})
.then((res) => {
if (res) {
res.data.body.forEach((val) => {
secondApi();
});
}
});
}
async function secondApi() {
axios
.post('second_api_url', {
titleSecondApi: "titleSecondApi",
})
.then((res) => {
if (res.data.body.msg) {
setInputVal([res.data.body.msg]);
console.log(inputVal);
}
});
}</code></pre>
</div>
</div>
</p>
<p>Now I'm getting second api response only last response but I need all response in an array.</p>
<p>I'm using inputVal useState for that but not getting all the values in array how to get it?</p>
<p>Thanks for your efrorts!</p>
| [
{
"answer_id": 74313338,
"author": "berse2212",
"author_id": 20184128,
"author_profile": "https://Stackoverflow.com/users/20184128",
"pm_score": 1,
"selected": false,
"text": ";"
},
{
"answer_id": 74313633,
"author": "mohamed",
"author_id": 15021356,
"author_profile": "https://Stackoverflow.com/users/15021356",
"pm_score": 0,
"selected": false,
"text": "(int i=0; i < nameArray.length-1; i++) "
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7333403/"
] |
74,313,265 | <p>I am new to C coding, and am trying to implement standard matrix multiplication. My code works fine for square matrices, but refuses to accept a column vector. Here is my attempt at the code. Any help would be much appreciated.</p>
<pre><code>//---------------------------------------IMPORTING NECESSARY C PACKAGES AND DEFINING EXECUTION CONSTANTS-------------------------------------------//
#include <stdio.h> // Standard input output library
#include <math.h> // Mathematical function library
#include <stdlib.h> // General purpose standard library
#define true 1
#define false 0
typedef long double numeric; // Using the long double datatype to avoid overflows during computations
//-------------------------------------------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------FUNCTION DECLERATION-------------------------------------------------------------//
numeric **create_matrix(int x, int y); // To dynamically allocate memory and create a matrix
void input_matrix(numeric **matrix, int m, int n); // To accept a matrix
void print_matrix(numeric **l, int x, int y); // To print a matrix
numeric **standard_matrix_multiplication(int m, int n, int l); // To multiply two matrices
//-------------------------------------------------------------------------------------------------------------------------------------------------//
//------------------------------------------------------------------DRIVER CODE--------------------------------------------------------------------//
int main(int argc, char *argv[]) {
int m, n, l; int choice;
printf("Enter the matrix operation to be performed using the corresponding index number.\n");
printf("\n");
printf("1.\tMatrix Multiplication");
printf("\n");
scanf("%d", &choice);
switch(choice) {
case 1 :
printf("Enter the number of rows in the first matrix\n");
scanf("%d", &m);
printf("Enter the number of columns in the first matrix\n");
scanf("%d", &n);
printf("Enter the number of columns in the second matrix\n");
scanf("%d", &l);
printf("Enter both matrices.\n");
numeric **matrix_x;
matrix_x = create_matrix(m, l);
matrix_x = standard_matrix_multiplication(m, n, l);
print_matrix(matrix_x, m, l);
break;
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------MATRIX MULTIPLICATION IMPLEMENTATIONS--------------------------------------------------//
numeric **standard_matrix_multiplication(int m, int n, int l) {
numeric **matrix_a; numeric **matrix_b; numeric **matrix_k;
matrix_a = create_matrix(m, n);
matrix_b = create_matrix(n, l);
matrix_k = create_matrix(m, l);
input_matrix(matrix_a, m, n);
print_matrix(matrix_a, m, n);
input_matrix(matrix_b, n, l);
for(int i = 0; i < m; i++) {
for (int j = 0; j < n; j ++) {
for (int k = 0; k < l; k++) {
matrix_k[i][j] += matrix_a[i][k] * matrix_b[k][j];
}
}
}
return matrix_k;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------HELPER FUNCTIONS------------------------------------------------------------------//
numeric **create_matrix(int x, int y) {
numeric **matrix = (numeric**)malloc(x * sizeof(numeric*)); // Dynamically creating an array of pointers
for (int i = 0; i < y; i++) {
matrix[i] = (numeric*)malloc(y * sizeof(numeric)); // Dynamically allocating memory for each columns of the matrix
}
return matrix;
}
void input_matrix(numeric **matrix, int m, int n) {
printf("Enter the elements of the matrix, row wise.\n"); // Instructing the user on matrix entry
printf("For example, to enter the matrix\n");
printf("\t\t1\t2\n");
printf("\t\t3\t4\n");
printf("enter 1, 2, 3, and 4 in that order.\n");
for (int i = 0; i < m; i++) { // Iterating through the rows and columns of the matrix
for (int j = 0; j < n; j++) {
scanf("%Lf", &matrix[i][j]); // Accepting each element
}
}
}
void print_matrix(numeric **l, int x, int y) { // To print a matrix
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
printf("%0.10Lf\t", l[i][j]); // Printing numeric type values
}
printf("\n");
}
printf("\n");
}
</code></pre>
<p>As of now, I have only written one switch case, and that is for matrix multiplication. So I chose 1. I gave 2, 1, 2 as my inputs for the number of rows in the first matrix, number of columns in the first matrix, and number of columns in the second matrix respectively. I have given a print statement in line 52, and it isn't executing it for the above input, giving a segmentation fault instead. Could someone please help me out?</p>
| [
{
"answer_id": 74313338,
"author": "berse2212",
"author_id": 20184128,
"author_profile": "https://Stackoverflow.com/users/20184128",
"pm_score": 1,
"selected": false,
"text": ";"
},
{
"answer_id": 74313633,
"author": "mohamed",
"author_id": 15021356,
"author_profile": "https://Stackoverflow.com/users/15021356",
"pm_score": 0,
"selected": false,
"text": "(int i=0; i < nameArray.length-1; i++) "
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20414846/"
] |
74,313,269 | <p>I am trying to integrate stripe terminal code with my android app build using kotlin, unfortunately I am getting the following run time error which I could not able to fix</p>
<p><code>java.lang.IllegalStateException: initTerminal must be called before attempting to get the instance</code></p>
<p>The code I have added is used below</p>
<pre><code>override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_pay_screen)
onDiscoverReaders()
}
fun onDiscoverReaders() {
val config = DiscoveryConfiguration(
timeout = 0,
discoveryMethod = DiscoveryMethod.LOCAL_MOBILE,
isSimulated = false,
location = "xxxxxxxxxxxxxxx"
)
// Save this cancelable to an instance variable
discoveryCancelable = Terminal.getInstance().discoverReaders(config,
discoveryListener = object : DiscoveryListener {
override fun onUpdateDiscoveredReaders(readers: List<Reader>) {
}
}
, object : Callback {
override fun onSuccess() {
println("Finished discovering readers")
}
override fun onFailure(e: TerminalException) {
e.printStackTrace()
}
})
}
</code></pre>
<p>I have added this to one of my activity and my intention is to check if my phone is supporting <a href="https://stripe.com/docs/terminal/payments/connect-reader?terminal-sdk-platform=android&reader-type=tap-on-mobile" rel="nofollow noreferrer">stripe tap on mobile</a></p>
<p>I guess the issue could be calling onDiscoverReaders() from a wrong place, someone please help me to fix this issue</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 74313453,
"author": "Omkar",
"author_id": 6834114,
"author_profile": "https://Stackoverflow.com/users/6834114",
"pm_score": 1,
"selected": false,
"text": " // Create your listener object. Override any methods that you want to be notified about\nval listener = object : TerminalListener {\n}\n\n// Choose the level of messages that should be logged to your console\nval logLevel = LogLevel.VERBOSE\n\n// Create your token provider.\nval tokenProvider = TokenProvider()\n\n// Pass in the current application context, your desired logging level, your token provider, and the listener you created\nif (!Terminal.isInitialized()) {\n Terminal.initTerminal(applicationContext, logLevel, tokenProvider, listener)\n}\n\n// Since the Terminal is a singleton, you can call getInstance whenever you need it\nTerminal.getInstance()\n"
},
{
"answer_id": 74361274,
"author": "Pavel K",
"author_id": 7864454,
"author_profile": "https://Stackoverflow.com/users/7864454",
"pm_score": 2,
"selected": false,
"text": "class App : Application() {\n override fun onCreate() {\n super.onCreate()\n TerminalApplicationDelegate.onCreate(this)\n }\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7098307/"
] |
74,313,273 | <p>I have two collections <code>Categories</code> and <code>Subcategories</code> inside a <code>Categories</code> collection. I have an array that is storing the ids of subcategories that are stored in <code>Subcategories</code> collection. Below is my document structure:</p>
<p><strong>Categories collection</strong></p>
<pre><code>{
id:65,
title:"Automotive",
active:true,
subcategories:[35,28,30]
}
</code></pre>
<p><strong>subcategories collection</strong></p>
<pre><code>{
id:35,
title:"Automotive technology",
category_id:65,
active:true
},
{
id:28,
title:"Automotive coatings",
category_id:65,
active:true
},
{
id:30,
title:"Machinery and equipments",
category_id:65,
active:true
}
</code></pre>
<p>As seen in above collection 3 documents from subcategories collection have been associated with the category document. I want to fetch data in below format on single API hit.</p>
<p>API response should be in below format:</p>
<pre><code>{
data:{
category:{
id:65,
title:"Automotive",
subcategories:[{
id:35,
name:"Automotive technology",
},
{
id:28,
name:"Automotive coatings",
},
{
id:30,
name:"Machinery and equipments",
}]
},
category:{
id:66,
title:"Food",
subcategories:[{
id:23,
name:"Drinks",
},
{
id:2,
name:"Additives",
}]
},
},
messsage:"Success",
code:200
}
</code></pre>
<p>As of now I am able to get data in 2 api hits that is like first getting all the categories</p>
<pre><code> const category = await db.categories.find({});
</code></pre>
<p>Then on click of some particular category fetching all the sub categories based on the category id.</p>
<pre><code>const subCategories = await db.SubCategories.find({category_id:id});
</code></pre>
<p>How can I get the above data in desired format in single API hit?</p>
| [
{
"answer_id": 74313453,
"author": "Omkar",
"author_id": 6834114,
"author_profile": "https://Stackoverflow.com/users/6834114",
"pm_score": 1,
"selected": false,
"text": " // Create your listener object. Override any methods that you want to be notified about\nval listener = object : TerminalListener {\n}\n\n// Choose the level of messages that should be logged to your console\nval logLevel = LogLevel.VERBOSE\n\n// Create your token provider.\nval tokenProvider = TokenProvider()\n\n// Pass in the current application context, your desired logging level, your token provider, and the listener you created\nif (!Terminal.isInitialized()) {\n Terminal.initTerminal(applicationContext, logLevel, tokenProvider, listener)\n}\n\n// Since the Terminal is a singleton, you can call getInstance whenever you need it\nTerminal.getInstance()\n"
},
{
"answer_id": 74361274,
"author": "Pavel K",
"author_id": 7864454,
"author_profile": "https://Stackoverflow.com/users/7864454",
"pm_score": 2,
"selected": false,
"text": "class App : Application() {\n override fun onCreate() {\n super.onCreate()\n TerminalApplicationDelegate.onCreate(this)\n }\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7780102/"
] |
74,313,292 | <p>I have two arrays <strong>array a = [1, 2, 3, 4, 5]</strong> and <strong>array b = [6, 5, 4, 3, 2]</strong> and i am returning a array list which contains a count where i taking elements of <strong>array b</strong> and checking what elements of <strong>array a</strong> are greater than or equal to the each element of <strong>array b</strong>, and i am storing this in <strong>count</strong> varible and later adding each <strong>count</strong> to the list so the output will be <strong>list = [0, 1, 2, 3, 4]</strong>, but the code i've written is lacking in the performance for larger sets of input and not giving supposed answer's in the expected way any idea of how can i improve my code to improve the performance</p>
<pre><code>static List<Integer> giantArmy(int a[],int b[]){
List<Integer> list = new ArrayList<Integer>();
if (a.length == 1 && a[0] == 0) {
list.add(0);
return list;
}
int count = 0;
for (int i = 0; i < b.length; i++) {
for (int j = 0; j < a.length; j++) {
if (a[j] >= b[i]) {
count++;
}
}
list.add(count);
count = 0;
}
return list;
}
</code></pre>
| [
{
"answer_id": 74313710,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "O(n log n)"
},
{
"answer_id": 74346930,
"author": "Anand",
"author_id": 2265587,
"author_profile": "https://Stackoverflow.com/users/2265587",
"pm_score": 0,
"selected": false,
"text": "static List<Integer> giantArmy(Integer a[],Integer b[]){\n TreeSet<Integer> ts = new TreeSet<>();\n List<Integer> aList = Arrays.asList(a);\n\n ts.addAll(aList);\n Integer[] count = new Integer[b.length];\n\n for (int i = 0; i < b.length; i++) {\n Set<Integer> tail_set = ts.tailSet(b[i]);\n \n count[i] = tail_set.size();\n }\n\n return Arrays.asList(count);\n \n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13337068/"
] |
74,313,308 | <p>I have this code:</p>
<pre><code>router.post('/BWreport', async function(req, res, next){
try{
var cname = await corporate.find().select('corporateID username');
cname.forEach(function(cname, await){
cname["totalcases"] = 1;
});
return res.json({ response:true, data:cname });
}catch(err){
return res.json({ response:false, data:err });
}
});
</code></pre>
<p>As you can see in the output, <code>totalcases</code> is not getting added:</p>
<pre><code> "response": true,
"data": [
{
"_id": "61d3f90340b6cad5974ca50a",
"username": "SB Demo",
"corporateID": "SB00001"
},
{
"_id": "62266f20fa0eb7a8fbe7d82a",
"corporateID": "SB00002",
"username": "NeoGrowth"
}]
</code></pre>
<p>as you can see new key/value pair not getting in output, can anyone tell me why?
desired output below</p>
<pre><code> "response": true,
"data": [
{
"_id": "61d3f90340b6cad5974ca50a",
"username": "SB Demo",
"corporateID": "SB00001",
"totalcases": "1"
},
{
"_id": "62266f20fa0eb7a8fbe7d82a",
"corporateID": "SB00002",
"username": "NeoGrowth",
"totalcases": "1"
}]
</code></pre>
| [
{
"answer_id": 74313407,
"author": "Drashti Kheni",
"author_id": 10535718,
"author_profile": "https://Stackoverflow.com/users/10535718",
"pm_score": 2,
"selected": true,
"text": ".lean()"
},
{
"answer_id": 74313511,
"author": "Syed Jawad",
"author_id": 20414919,
"author_profile": "https://Stackoverflow.com/users/20414919",
"pm_score": 0,
"selected": false,
"text": "router.post('/BWreport', async function(req, res, next){\n try{\n var cname = await corporate.find().select('corporateID username');\n cname.forEach((elem, ind, arr) => {\n arr[ind]['totalcases'] = 1;\n });\n return res.json({ response:true, data:cname });\n }catch(err){\n return res.json({ response:false, data:err });\n }\n});\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16174361/"
] |
74,313,313 | <p>See the code below</p>
<pre><code>queue<function<void()> > tasks;
void add_job(function<void(void*)> func, void* arg) {
function<void()> f = bind(func, arg)();
tasks.push( f );
}
</code></pre>
<p><code>func</code> is the function I want to add to the <code>tasks</code> which has argument is <code>arg</code>.</p>
<p>How can I do to use <code>std::bind</code> to bind its argument so that it can be assigned to the object of <code>std::function<void()></code>?</p>
| [
{
"answer_id": 74313401,
"author": "GAVD",
"author_id": 4983082,
"author_profile": "https://Stackoverflow.com/users/4983082",
"pm_score": 0,
"selected": false,
"text": "function<void()> f = bind(func, arg);\ntasks.push( f );\n"
},
{
"answer_id": 74313489,
"author": "JeJo",
"author_id": 9609840,
"author_profile": "https://Stackoverflow.com/users/9609840",
"pm_score": 3,
"selected": true,
"text": "std::bind"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19252975/"
] |
74,313,346 | <p>I'm creating a custom file up-loader for my project. I want to add "cancel file upload feature" also. Assume that I've already dragged and dropped some 4 or 5 file into the component. this files are stored in <code>file</code> variable. When I click on "Upload" button from the UI following method will be called:</p>
<pre><code>uploadFiles() {
const formData = new FormData();
formData.append('excel', this.file);
const headers = new HttpHeaders({
'x-request-id': 'file_upload_' + new Date().getTime(),
});
this.http
.post('http://localhost:8090/service/fileprocess/upload', formData, {
headers: headers,
responseType: 'json',
})
.pipe(catchError((err) => this.handleError(err)))
.subscribe((res: any) => {
// show success message to the user
});
}
</code></pre>
<p>Let's say I pressed the upload button but there is one file which is taking longer than expected. Then the user should be able to cancel that particular upload by clicking on its respective ban icon. This is my template:</p>
<pre><code><div class="row mt-1" *ngFor="let item of files; let indexOfelement=index;">
<div class="col-lg-1">
<p-progressSpinner *ngIf="fileUploading"></p-progressSpinner>
</div>
<div class="col-lg-3">
{{ item.relativePath }}
</div>
<div class="col-lg-6">
<p-progressBar *ngIf="fileFound" [value]="variable"></p-progressBar>
</div>
<div class="col-lg-2 text-end">
<i class="fa fa-ban" *ngIf="fileUploading" (click)="stopThisUpload(indexOfelement)"></i>
</div>
</div>
</code></pre>
<p>The UI looks like this:
<a href="https://i.stack.imgur.com/J2d7F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J2d7F.png" alt="enter image description here" /></a></p>
<p>Can someone please guide me on this.</p>
| [
{
"answer_id": 74313459,
"author": "Fábio BC Souza",
"author_id": 7660260,
"author_profile": "https://Stackoverflow.com/users/7660260",
"pm_score": 0,
"selected": false,
"text": "AbortController"
},
{
"answer_id": 74313561,
"author": "Fabian Strathaus",
"author_id": 17298437,
"author_profile": "https://Stackoverflow.com/users/17298437",
"pm_score": 1,
"selected": false,
"text": "unsubscribe"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11163977/"
] |
74,313,353 | <p>Currently, I am working on a flutter project that uses Realtime Database in Firebase. This app has an update functionality for the details of the user. I have successfully implemented the updating functionality as it is being stored in the database right after the update. However, when I go back to the View Profile Page, the details that are being displayed are not yet updated. I need to go to some other tab first and then go back to the View Profile page where the updated data will then be loaded. Why there are delays, shouldn't it be real-time, once I updated the data? Any help will be much appreciated. Thanks!</p>
<p><strong>Here is my code for displaying the current user's information:</strong></p>
<pre><code>static void readCurrentOnlineUserInfo() async
{
final FirebaseAuth fAuth = FirebaseAuth.instance;
User? currentFirebaseUser;
currentFirebaseUser = fAuth.currentUser;
DatabaseReference userRef = FirebaseDatabase.instance
.ref()
.child("passengers")
.child(currentFirebaseUser!.uid);
userRef.once().then((snap)
{
if(snap.snapshot.value != null)
{
userModelCurrentInfo = UserModel.fromSnapshot(snap.snapshot);
print("name" + userModelCurrentInfo!.first_name.toString());
print("username" + userModelCurrentInfo!.username.toString());
}
});
}
</code></pre>
<p><strong>On the other hand, this is the code that I am using for displaying the data into my app:</strong></p>
<pre><code>import 'package:firebase_database/firebase_database.dart';
class UserModel
{
String? first_name;
String? last_name;
String? id;
String? email;
String? username;
String? password;
String? phoneNum;
UserModel({this.first_name, this.last_name, this.id, this.email, this.username, this.password, this.phoneNum});
UserModel.fromSnapshot(DataSnapshot snap)
{
first_name = (snap.value as dynamic)["first_name"];
last_name = (snap.value as dynamic)["last_name"];
id = snap.key;
email = (snap.value as dynamic)["email"];
username = (snap.value as dynamic)["username"];
password = (snap.value as dynamic)["password"];
phoneNum = (snap.value as dynamic)["phoneNum"];
}
}
</code></pre>
<p><strong>I display the above information in widgets like this:</strong></p>
<pre><code>UserAccountsDrawerHeader(
decoration: BoxDecoration(
color: Color(0xFFFED90F),
),
accountName: new Text(userCurrentModelInfo!.first_name,
style: TextStyle( color: Colors.white,
fontSize: 15,
fontFamily: "Montserrat",
fontWeight: FontWeight.w600,),
),
</code></pre>
| [
{
"answer_id": 74313459,
"author": "Fábio BC Souza",
"author_id": 7660260,
"author_profile": "https://Stackoverflow.com/users/7660260",
"pm_score": 0,
"selected": false,
"text": "AbortController"
},
{
"answer_id": 74313561,
"author": "Fabian Strathaus",
"author_id": 17298437,
"author_profile": "https://Stackoverflow.com/users/17298437",
"pm_score": 1,
"selected": false,
"text": "unsubscribe"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17269853/"
] |
74,313,362 | <p>I´ve got a <strong>Request-Object</strong> which contains FirstName, LastName and Birthday. When ever a Client sends more Data than the object has, I want this properties written into <strong>JsonExtensionData</strong> property to track them and may extend the API. Therefor I´ve also a Controller which has the Request as parameter. But when I use the given <code>Swagger</code> the AdditionalData Property is present as Request Property and every additional Property is deleted on Request.</p>
<p>This the Request Class:</p>
<pre><code>public class Request
{
public DateTime BirthDay { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
[JsonExtensionData]
public Dictionary<string, object> AdditionalData { get; set; }
}
</code></pre>
<p>EDIT:</p>
<p>In this <a href="https://www.jerriepelser.com/blog/using-jsonextensiondata-with-jsonnet/" rel="nofollow noreferrer">Block</a> its saying:</p>
<p>What this allows you to do is to serialize elements of a JSON document which does not have matching properties on the destination object to the dictionary which is decorated with the [JsonExtensionData] attribute. (Also see the JSON.NET documentation on the various Serialization Attributes)</p>
| [
{
"answer_id": 74313766,
"author": "Felix Arnold",
"author_id": 4350189,
"author_profile": "https://Stackoverflow.com/users/4350189",
"pm_score": 0,
"selected": false,
"text": "NewtonsoftJson´s JsonExtensionData"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74313362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4350189/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.