qid
int64 4
22.2M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
74,482,865
|
<p>I'm trying to capture the 2 lines below from beginning to before the AJ sign.</p>
<pre class="lang-none prettyprint-override"><code>TSA01-19AUG80/F/LEE/ANGIE/JEAN AJ 17NOV 2124Z
TSA01-19AUG80/F/LEE/ANGIE/JEAN MARIE AJ 17NOV 2124Z
</code></pre>
<p>The end of the line (<code>AJ 17NOV 2124Z</code>) is not constant and may be different every time.</p>
<p>I was able to capture this line by using this format - <code>TSA01-([^\s]+)</code></p>
<pre class="lang-none prettyprint-override"><code>TSA01-19AUG80/F/LEE/ANGIE/JEAN AJ 17NOV 2124Z
</code></pre>
<p>But I'm stuck on if someone has an extra space in their first name, like below. How do I capture the 2nd name without capturing the <code>AJ 17NOV 2124Z</code>?</p>
<pre class="lang-none prettyprint-override"><code>TSA01-19AUG80/F/LEE/ANGIE/JEAN MARIE AJ 17NOV 2124Z
</code></pre>
|
[
{
"answer_id": 74483152,
"author": "Sushanth --",
"author_id": 941272,
"author_profile": "https://Stackoverflow.com/users/941272",
"pm_score": 1,
"selected": false,
"text": "section"
},
{
"answer_id": 74486171,
"author": "Carsten Massmann",
"author_id": 2610061,
"author_profile": "https://Stackoverflow.com/users/2610061",
"pm_score": 0,
"selected": false,
"text": "<section>"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74482865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534449/"
] |
74,482,872
|
<p>I have been asked to solve a problem using any front-end framework ( reactjs in my case ) . Basically there is a form for adding a car and there can be say a type of car like 'SUV','semitruck','racecar' and so on...</p>
<p>In the form there needs to be different components rendered based on the type of car you want to add ( e.g. SUV has 2 inputs , racecar has 5 inputs ) how can i dynamically render these components and get their input values without doing if statements?</p>
<p>So pretty much i want to avoid doing this :</p>
<pre><code>{typeSelection == "SUV" && (
<SVUInput
size={sizeInput}
changeSize={(str) => setSizeInput(str)}
/>
)}
{typeSelection == "Bus" && (
<WeightInput
Weight={weightInput}
changeWeight={(str) => setWeightInput(str)}
/>
)}
{typeSelection == "Semitruck" && (
<DimensionInput
wheels={wheels}
length={length}
changeWheels={(n) => setWheels(n)}
changeLength={(str) => setLength(str)}
/>
)}
</code></pre>
<p>I tried doing this but doesnt work ( im guessing react doesnt re-render here )</p>
<pre><code> const [dynamicInputs, setDynamicInputs] = React.useState<any>({
SUV: <SUVInput size={sizeInput} changeSize={(str) => setSizeInput(str)} />,
bus: <BusInput weight={weightInput} changeSize={(n) => setSizeInput(n)} />,
semitruck: <SemitruckInput wheels={wheelsInput} changeWheels={(n) => setWheelsInput(n)}
color={colorInput} changeColor={(n) => setColorInput(n)} />,
});
</code></pre>
<p>Instead the above code although renders the component , the input does not change when i type into it, it remains blank , i assume it doesnt trigger react to re-render the state</p>
<p>So pretty much instead of making many if statements that would slow down the front-end , Im trying to make it dynamic so that it only takes O(1) time to render the correct form inputs.</p>
|
[
{
"answer_id": 74482935,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 3,
"selected": true,
"text": "useState"
},
{
"answer_id": 74483050,
"author": "JustDankas",
"author_id": 16678496,
"author_profile": "https://Stackoverflow.com/users/16678496",
"pm_score": 0,
"selected": false,
"text": " React.useEffect(() => {\n setDynamicInputs({\n SUV: (\n <SUV size={sizeInput} changeSize={(str) => setSizeInput(str)} />\n ),\n bus: (\n <WeightInput\n Weight={weightInput}\n changeWeight={(str) => setWeightInput(str)}\n />\n ),\n });\n }, [dynamicInputs]);\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74482872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16678496/"
] |
74,482,884
|
<p>Are there any CSS gurus out there up to the challenge of representing one of Edgar Poe's cryptographic texts? It uses inverted and backwards characters, which would have driven his type composer crazy. The image file tyler.jpg appears about 3/5 of the way down the linked page: <a href="https://www.howtoreadpoe.com/content/k-secret_writing/sw03.htm" rel="nofollow noreferrer">Secret Writing 03</a></p>
<p>Trying to find CSS examples across the 'net but not much success.</p>
|
[
{
"answer_id": 74483324,
"author": "Alohci",
"author_id": 42585,
"author_profile": "https://Stackoverflow.com/users/42585",
"pm_score": 2,
"selected": true,
"text": "body {\n display:flex;\n flex-wrap: wrap;\n}\nspan::before {\n content: 'P';\n}\nspan:nth-child(2n) {\n scale: -1;\n}\nspan:nth-child(n+3) {\n transform: rotateY(180deg);\n}"
},
{
"answer_id": 74503048,
"author": "Jack DeLand",
"author_id": 6462161,
"author_profile": "https://Stackoverflow.com/users/6462161",
"pm_score": 0,
"selected": false,
"text": " span.horizontal {\n display: inline-block;\n -moz-transform: scale(-1, 1);\n -webkit-transform: scale(-1, 1);\n -o-transform: scale(-1, 1);\n -ms-transform: scale(-1, 1);\n transform: scale(-1, 1);\n }\n\n span.vertical {\n display: inline-block;\n -moz-transform: scale(1, -1);\n -webkit-transform: scale(1, -1);\n -o-transform: scale(1, -1);\n -ms-transform: scale(1, -1);\n transform: scale(1, -1);\n }\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74482884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6462161/"
] |
74,482,897
|
<p>I'm new to C++ and smart pointers, especially the behavior of unique_ptr. Below is a piece of code that I'm experimenting:</p>
<pre><code>unique_ptr<int> u1 = make_unique<int>(2);
unique_ptr<int> u2 = make_unique<int>();
u2.reset(u1.get());
</code></pre>
<p>unique_ptr, by definition, is a kind of smart pointer which doesn't share the ownership of the object that it is pointing to with other smart pointers. However, why doesn't the above code return an error?
In fact, if I try to print the value of u1 and u2 out, they turn out to indeed point to the same memory address:</p>
<pre><code>cout<<u1.get()<<endl;
cout<<u2.get()<<endl;
</code></pre>
<p>Show these on the Console:</p>
<pre><code>0x55800839ceb0
0x55800839ceb0
free(): double free detected in tcache 2 // finally the error appears at the end of the program's execution
</code></pre>
<p>But if I say:</p>
<pre><code>cout<<(*u1)<<endl;
(*u1)=5;
cout<<(*u2)<<endl;
</code></pre>
<p>The change doesn't affect (*u2), as if they are in different memory addresses.</p>
<p>Any help would be appreciated!
Thank you for your time!</p>
|
[
{
"answer_id": 74482938,
"author": "nanofarad",
"author_id": 1424875,
"author_profile": "https://Stackoverflow.com/users/1424875",
"pm_score": 3,
"selected": false,
"text": "get()"
},
{
"answer_id": 74482956,
"author": "Nicol Bolas",
"author_id": 734069,
"author_profile": "https://Stackoverflow.com/users/734069",
"pm_score": 3,
"selected": false,
"text": "unique_ptr::reset"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74482897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19852327/"
] |
74,482,912
|
<p>Basically I have this code and it is very ugly, I'm a beginner at HTML, CSS and JS so bare with me,</p>
<pre><code><button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E2.mp4';getElementById('s2').innerHTML='Season 2 Episode 2'">
Episode 2
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E3.mp4';getElementById('s2').innerHTML='Season 2 Episode 3'">
Episode 3
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E4.mp4';getElementById('s2').innerHTML='Season 2 Episode 4'">
Episode 4
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E5.mp4';getElementById('s2').innerHTML='Season 2 Episode 5'">
Episode 5
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E6.mp4';getElementById('s2').innerHTML='Season 2 Episode 6'">
Episode 6
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E7.mp4';getElementById('s2').innerHTML='Season 2 Episode 7'">
Episode 7
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E8.mp4';getElementById('s2').innerHTML='Season 2 Episode 8'">
Episode 8
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E9.mp4';getElementById('s2').innerHTML='Season 2 Episode 9'">
Episode 9
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E10.mp4';getElementById('s2').innerHTML='Season 2 Episode 10'">
Episode 10
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E11.mp4';getElementById('s2').innerHTML='Season 2 Episode 11'">
Episode 11
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E12.mp4';getElementById('s2').innerHTML='Season 2 Episode 12'">
Episode 12
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E13.mp4';getElementById('s2').innerHTML='Season 2 Episode 13'">
Episode 13
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E14.mp4';getElementById('s2').innerHTML='Season 2 Episode 14'">
Episode 14
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E15.mp4';getElementById('s2').innerHTML='Season 2 Episode 15'">
Episode 15
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E16.mp4';getElementById('s2').innerHTML='Season 2 Episode 16'">
Episode 16
</button>
<button type="button" class="buttons" onclick="document.getElementById('my-video2_html5_api').src = 'S2E17.mp4';getElementById('s2').innerHTML='Season 2 Episode 17'">
Episode 17
</button>
</code></pre>
<p>And it looks so clumped up, and from searching I cant find a way to simplify this code with JS scripts?</p>
<p>I could set a variable let x = document blah blah but that still clumps everything up</p>
|
[
{
"answer_id": 74482982,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 0,
"selected": false,
"text": "<button type=\"button\" class=\"buttons episode\" data-src=\"S2E2.mp4\" data-title=\"Season 2 Episode 2\">\nEpisode 2\n"
},
{
"answer_id": 74482991,
"author": "human bean",
"author_id": 17186475,
"author_profile": "https://Stackoverflow.com/users/17186475",
"pm_score": 0,
"selected": false,
"text": "document.getElementById(\"dropdown\").addEventListener(\"change\", (e) => {\n console.log(`user selected ${e.target.value}`);\n})"
},
{
"answer_id": 74483025,
"author": "Kinglish",
"author_id": 1772933,
"author_profile": "https://Stackoverflow.com/users/1772933",
"pm_score": 0,
"selected": false,
"text": "let episodes = [{\n video: 'S2E1.mp4',\n title: 'Season 2 Episode 1'\n },\n {\n video: 'S2E2.mp4',\n title: 'Season 2 Episode 2'\n }\n];\n\ndocument.addEventListener('DOMContentLoaded', () => {\n let container = document.querySelector('#episodes');\n let api_div = document.getElementById('my-video2_html5_api')\n let title_display = document.getElementById('s2');\n let output = '';\n episodes.forEach(ep => {\n let btitle = ep.title.split(\" \").slice(-2).join(\" \");\n output += `<button \n class=\"buttons episode-btn\" \n data-video=\"${ep.video}\" \n data-title=\"${ep.title}\">\n ${btitle}\n </button>`\n })\n container.innerHTML = output;\n\n document.querySelectorAll('.episode-btn').forEach(btn => btn.addEventListener('click', e => {\n\n // for demonstration:\n return console.log(`play ${e.target.dataset.title}, video: ${e.target.dataset.video}`);\n\n // real code\n api_div.src = e.target.dataset.video;\n title_display.innerHTML = e.target.dataset.title\n }))\n\n})"
},
{
"answer_id": 74483043,
"author": "Mohamed EL-Gendy",
"author_id": 4000130,
"author_profile": "https://Stackoverflow.com/users/4000130",
"pm_score": 0,
"selected": false,
"text": "data-(name)"
},
{
"answer_id": 74483101,
"author": "damonholden",
"author_id": 17670742,
"author_profile": "https://Stackoverflow.com/users/17670742",
"pm_score": -1,
"selected": false,
"text": ".map()"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74482912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19393512/"
] |
74,482,958
|
<p>im calling an object from the pokeapi, exactly the name property and on first render after saving the file i get the name but i dont know why, re render and then the propertie is null and i get an error</p>
<p>this is my component card</p>
<pre><code>import {
EditOutlined,
EllipsisOutlined,
SettingOutlined,
} from "@ant-design/icons";
import { Avatar, Card, Col, Row } from "antd";
function Pokecard(values: any) {
const { response} = values;
const { Meta } = Card;
return (
<Row gutter={[10, 10]}>
<Col>
<Card
style={{ width: 300 }}
cover={
<img
alt={"" }
src={response && response['sprites']['front_default']}
/>
}
actions={[
<SettingOutlined key="setting" />,
<EditOutlined key="edit" />,
<EllipsisOutlined key="ellipsis" />,
]}
>
<Meta
avatar={<Avatar src="https://joeschmoe.io/api/v1/random" />}
title={response.name}
description=""
/>
</Card>
</Col>
</Row>
);
}
export default Pokecard;
</code></pre>
<p>this is my view</p>
<pre><code>import { Methods } from "../interfaces/request";
import { useEffect, useState } from "react";
import Pokecard from "../components/pokecard/Pokecard";
import useAxios from "../plugins/Useaxios";
function App2() {
const { response, loading, error } = useAxios({
method: Methods["get"],
url: "/ditto",
body: JSON.stringify({}),
headers: JSON.stringify({}),
});
const [data, setData] = useState([]);
useEffect(() => {
if (response !== null) {
setData(response);
}
}, [response]);
let args: any = {
response,
};
return (
<>
<Pokecard {...args} />;
</>
);
}
export default App2;
</code></pre>
<p>and this is my plugin axios</p>
<pre><code>import axios from "axios";
import Request from "../interfaces/request";
import { useState, useEffect } from "react";
enum Methods {
get = "get",
post = "post",
default = "get",
}
const useAxios = ({ url, method, body, headers }: Request) => {
axios.defaults.baseURL = "https://pokeapi.co/api/v2/pokemon";
const [response, setResponse] = useState(null);
const [error, setError] = useState("");
const [loading, setloading] = useState(true);
const fetchData = () => {
axios[method](url, JSON.parse(headers), JSON.parse(body))
.then((res: any) => {
setResponse(res.data);
})
.catch((err: any) => {
setError(err);
})
.finally(() => {
setloading(false);
});
};
useEffect(() => {
fetchData();
}, [method, url, body, headers]);
return { response, error, loading };
};
export default useAxios;
</code></pre>
<p>im learning to destructuring objects</p>
<p>im tried saving the object in the store but i got an Undifined</p>
<p>sorry for my english</p>
|
[
{
"answer_id": 74482982,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 0,
"selected": false,
"text": "<button type=\"button\" class=\"buttons episode\" data-src=\"S2E2.mp4\" data-title=\"Season 2 Episode 2\">\nEpisode 2\n"
},
{
"answer_id": 74482991,
"author": "human bean",
"author_id": 17186475,
"author_profile": "https://Stackoverflow.com/users/17186475",
"pm_score": 0,
"selected": false,
"text": "document.getElementById(\"dropdown\").addEventListener(\"change\", (e) => {\n console.log(`user selected ${e.target.value}`);\n})"
},
{
"answer_id": 74483025,
"author": "Kinglish",
"author_id": 1772933,
"author_profile": "https://Stackoverflow.com/users/1772933",
"pm_score": 0,
"selected": false,
"text": "let episodes = [{\n video: 'S2E1.mp4',\n title: 'Season 2 Episode 1'\n },\n {\n video: 'S2E2.mp4',\n title: 'Season 2 Episode 2'\n }\n];\n\ndocument.addEventListener('DOMContentLoaded', () => {\n let container = document.querySelector('#episodes');\n let api_div = document.getElementById('my-video2_html5_api')\n let title_display = document.getElementById('s2');\n let output = '';\n episodes.forEach(ep => {\n let btitle = ep.title.split(\" \").slice(-2).join(\" \");\n output += `<button \n class=\"buttons episode-btn\" \n data-video=\"${ep.video}\" \n data-title=\"${ep.title}\">\n ${btitle}\n </button>`\n })\n container.innerHTML = output;\n\n document.querySelectorAll('.episode-btn').forEach(btn => btn.addEventListener('click', e => {\n\n // for demonstration:\n return console.log(`play ${e.target.dataset.title}, video: ${e.target.dataset.video}`);\n\n // real code\n api_div.src = e.target.dataset.video;\n title_display.innerHTML = e.target.dataset.title\n }))\n\n})"
},
{
"answer_id": 74483043,
"author": "Mohamed EL-Gendy",
"author_id": 4000130,
"author_profile": "https://Stackoverflow.com/users/4000130",
"pm_score": 0,
"selected": false,
"text": "data-(name)"
},
{
"answer_id": 74483101,
"author": "damonholden",
"author_id": 17670742,
"author_profile": "https://Stackoverflow.com/users/17670742",
"pm_score": -1,
"selected": false,
"text": ".map()"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74482958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16820436/"
] |
74,483,009
|
<p>My dataset example looks like this:</p>
<pre><code>dput(t)
structure(list(date = structure(c(19091, 19091, 19092, 19092,
19093, 19093, 19094, 19094, 19095, 19095, 19096, 19096, 19097,
19097, 19098, 19098, 19099, 19099, 19100, 19100, 19101, 19101,
19102, 19102, 19103, 19103, 19104, 19104, 19105, 19105, 19106,
19106, 19107, 19107, 19109, 19109, 19110, 19110, 19111, 19111,
19112, 19112, 19113, 19113, 19114, 19114), class = "Date"), TempAmb_Avg = c(13.16,
13.16, 7.929, 7.929, 12.29, 12.29, 10.37, 10.37, 10.91, 10.91,
10.14, 10.14, 9.15, 9.15, 11.25, 11.25, 9.17, 9.17, 11.94, 11.94,
11.26, 11.26, 9.45, 9.45, 9.09, 9.09, NA, NA, 6.447, 6.447, 9.14,
9.14, 8.02, 8.02, 10.54, 10.54, 10.12, 10.12, 11.56, 11.56, 12.3,
12.3, 10.82, 10.82, 11.17, 11.17)), row.names = c(NA, 46L), class = "data.frame")
</code></pre>
<p>I'm having a problem that I can't go around. When plotting the <strong>TempAmb_Avg</strong> <em>geom_bar</em> does not display the real data, but <em>geom_line</em>, displays. I've been using this code:</p>
<pre><code>plot<- ggplot(NDVI) +
geom_bar(aes(x=date, y=TempAmb_Avg),stat="identity",colour="blue")+
geom_line(aes(x=date, y=TempAmb_Avg),stat="identity",colour="black")+
labs(x="TIME",y="TºC")+
theme_bw()
plot
</code></pre>
<p><a href="https://i.stack.imgur.com/YOXMt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YOXMt.png" alt="enter image description here" /></a></p>
<p>What do I have to do to display the real data with <em>geom_bar</em>?</p>
<p>I've found a solution but I'm lacking one step.
To avoid <strong>TempAmb_Avg</strong> data duplication when using <em>geom_bar</em> I've divided
<strong>TempAmb_Avg</strong>/2.</p>
<pre><code>plot<- ggplot(NDVI) +
geom_bar(aes(x=date, y=TempAmb_Avg/2),stat="identity",colour="blue")+
geom_line(aes(x=date, y=TempAmb_Avg),stat="identity",colour="black")+
labs(x="TIME",y="TºC")+
theme_bw()
plot
</code></pre>
<p>However not all <strong>TempAmb_Avg</strong> is duplicated.
How can I set a condition to only divide with 2 the duplicated values?</p>
|
[
{
"answer_id": 74484351,
"author": "Bruno Mioto",
"author_id": 15611828,
"author_profile": "https://Stackoverflow.com/users/15611828",
"pm_score": 1,
"selected": false,
"text": "library(dplyr)\nlibrary(ggplot2)\n\n#load your data first to NDVI object\n\nplot <- NDVI %>%\n #this will delete any duplicate row\n distinct() %>%\n ggplot(NDVI) + \n geom_bar(aes(x=date, y=TempAmb_Avg),stat=\"identity\",colour=\"blue\")+\n geom_line(aes(x=date, y=TempAmb_Avg),stat=\"identity\",colour=\"black\")+\n labs(x=\"TIME\",y=\"TºC\")+\n theme_bw()\nplot\n"
},
{
"answer_id": 74488208,
"author": "Cláudio Siva",
"author_id": 15030195,
"author_profile": "https://Stackoverflow.com/users/15030195",
"pm_score": 0,
"selected": false,
"text": "geom_bar"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15030195/"
] |
74,483,010
|
<p>I was looking for a workaround for configuring my database connection.<br>
I saw that opening 3306 port is dangerous and we should be using SSH Tunnel instead to connect to the database.</p>
<p>I configured my MySQL server using docker and successfully connected it using MySQL Workbench
<a href="https://i.stack.imgur.com/ZQ6wV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZQ6wV.png" alt="enter image description here" /></a></p>
<p>Now I have to configure and connect it to Visual Studio 2022 to be able to query to the database.</p>
<p>Visual Studio 2022 is only supported by MySQL Data thru NuGet packages which doesn't have a gui connection setup.</p>
<p><a href="https://i.stack.imgur.com/1DzD4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1DzD4.png" alt="enter image description here" /></a></p>
<p>I installed Visual Studio 2019 which is officially supported by MySQL Database and can be configured thru Data Source.</p>
<p>How can I setup MySQL Database connection to my Visual Studio if it's SSH Tunnel configured.<br>
Add Connection window only shows basic information about the connection. I'm not sure how to configure this over a SSH Tunnel.</p>
<p><a href="https://i.stack.imgur.com/R0dps.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R0dps.png" alt="enter image description here" /></a></p>
<p>Thank you in advance.</p>
|
[
{
"answer_id": 74541397,
"author": "wenbingeng-MSFT",
"author_id": 20528460,
"author_profile": "https://Stackoverflow.com/users/20528460",
"pm_score": 2,
"selected": true,
"text": "using MySql.Data.MySqlClient;\nusing Renci.SshNet;\nusing System;\nusing System.Collections.Generic;\nusing System.ComponentModel;\nusing System.Data;\nusing System.Drawing;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows.Forms;\n\n\nnamespace SSHMySql\n {\n public partial class Form1 : Form\n {\n public Form1()\n {\n InitializeComponent();\n SSHConnectMySql();\n }\n\n public void SSHConnectMySql()\n {\n string SSHHost = \"*.*.*.*\"; // SSH address\n int SSHPort = ; // SSH port\n string SSHUser = \"user\"; // SSH username\n string SSHPassword = \"pwd\"; // SSH password\n\n string sqlIPA = \"127.0.0.1\";// Map addresses In fact, it is possible to write other MySql on Linux My.cnf bind-address can be set to 0.0.0.0 or not\n string sqlHost = \"192.168.1.20\"; // The IP address of the machine installed by mysql can also be an intranet IP, for example: 192.168.1.20\n uint sqlport = ; // Database port and mapping port\n string sqlConn = \"Database=mysql;Data Source=\" + sqlIPA + \";Port=\" + sqlport + \";User Id=user;Password=pwd;CharSet=utf8\";\n string sqlSELECT = \"select * from user\";\n\n PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo(SSHHost, SSHPort, SSHUser, SSHPassword);\n connectionInfo.Timeout = TimeSpan.FromSeconds();\n using (var client = new SshClient(connectionInfo))\n {\n try\n {\n client.Connect();\n if (!client.IsConnected)\n {\n MessageBox.Show(\"SSH connect failed\");\n }\n\n var portFwdL = new ForwardedPortLocal(sqlIPA, sqlport, sqlHost, sqlport); // map to local port\n client.AddForwardedPort(portFwdL);\n portFwdL.Start();\n if (!client.IsConnected)\n {\n MessageBox.Show(\"port forwarding failed\");\n }\n\n MySqlConnection conn = new MySqlConnection(sqlConn);\n MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();\n myDataAdapter.SelectCommand = new MySqlCommand(sqlSELECT, conn);\n\n try\n {\n conn.Open();\n DataSet ds = new DataSet();\n myDataAdapter.Fill(ds);\n dataGridView1.DataSource = ds.Tables[];\n }\n catch (Exception ee)\n {\n MessageBox.Show(ee.Message);\n }\n finally\n {\n conn.Close();\n }\n\n client.Disconnect();\n }\n catch (Exception ex)\n {\n MessageBox.Show(ex.Message);\n }\n }\n }\n }\n }\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12372795/"
] |
74,483,020
|
<p>I have the following html which renders the following</p>
<pre><code><input type="checkbox" class='btn-filter' style='zoom:2; id="inactive-accounts" name="" value="1">
<label style= 'font-size:15px' for="inactive-accounts">Show Inactive Accounts</label><br>
</code></pre>
<p><a href="https://i.stack.imgur.com/a2brL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a2brL.png" alt="enter image description here" /></a></p>
<p>If the checkbox is a regular size the text lines up well with the checkbox but since I am using zoom to increase the size of the checkbox it is not aligned correctly. I tried a solution I found on stack overflow to create CSS like so:</p>
<pre><code> .checkboxes label {
display: inline-block;
padding-right: 10px;
white-space: nowrap;
}
.checkboxes input {
vertical-align: middle;
zoom:"2"
}
.checkboxes label span {
vertical-align: middle;
}
<input type="checkbox" class='btn-filter' style='zoom:2; justify-content:center' id="inactive-accounts" name="" value="1">
<label style= 'font-size:15px' for="inactive-accounts">Show Inactive Accounts</label><br>
</code></pre>
<p>but this does not fix the issue. Could it be that I should not be using zoom to increase the size of the checkbox here?</p>
|
[
{
"answer_id": 74483098,
"author": "heyitsjhu",
"author_id": 5200126,
"author_profile": "https://Stackoverflow.com/users/5200126",
"pm_score": 0,
"selected": false,
"text": "div"
},
{
"answer_id": 74483225,
"author": "Serhii Prudkyi",
"author_id": 20020672,
"author_profile": "https://Stackoverflow.com/users/20020672",
"pm_score": 2,
"selected": false,
"text": ".checkboxes {\n outline: 1px solid green;\n padding: 20px;\n font-size: 20px;\n display: flex;\n align-items: center;\n}\n.checkboxes input, .checkboxes label {\n margin: 0;\n min-height: 20px;\n display: flex;\n align-items: center;\n}\n.checkboxes label {\n white-space: nowrap;\n margin-left: 7px;\n outline: 1px solid grey;\n padding-left: 5px;\n}\n.checkboxes input {\n transform: scale(2);\n outline: 1px solid grey;\n}\n.checkboxes label span {\n vertical-align: middle;\n}"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9060036/"
] |
74,483,027
|
<p>C++ question!
I have a .txt file with this info:</p>
<pre><code>james, watson
brittany,blake
roger,tra4@pos
jonathan, pote5
amber,Trisa123!
</code></pre>
<p>where the first columnn is name and the second one is the Id of website users.</p>
<p>I need to read this file and then sotre the informations into 2 arrays:
name[]
user_Id []
could you please help me? I found the solution for saving it into a 2d vector but I prefer to save it as arrays since I need to compare the string values with another string (received by uer to check if her name/user Id is already in the system or not)</p>
<p>I found the solution for saving it into a 2d vector but not for arrays.</p>
|
[
{
"answer_id": 74487153,
"author": "A M",
"author_id": 9666018,
"author_profile": "https://Stackoverflow.com/users/9666018",
"pm_score": 2,
"selected": true,
"text": "std::vector"
},
{
"answer_id": 74487282,
"author": "YourDoge",
"author_id": 20147194,
"author_profile": "https://Stackoverflow.com/users/20147194",
"pm_score": 0,
"selected": false,
"text": "strtok()"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534558/"
] |
74,483,028
|
<p>This question is best asked using an example - if I have daily data (in this case, daily Domestic Box Office for the movie Elvis), how can I sum only the weekend values?</p>
<p>If the data looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Date</th>
<th>DBO</th>
</tr>
</thead>
<tbody>
<tr>
<td>6/24/2022</td>
<td>12755467</td>
</tr>
<tr>
<td>6/25/2022</td>
<td>9929779</td>
</tr>
<tr>
<td>6/26/2022</td>
<td>8526333</td>
</tr>
<tr>
<td>6/27/2022</td>
<td>4253038</td>
</tr>
<tr>
<td>6/28/2022</td>
<td>5267391</td>
</tr>
<tr>
<td>6/29/2022</td>
<td>4010762</td>
</tr>
<tr>
<td>6/30/2022</td>
<td>3577241</td>
</tr>
<tr>
<td>7/1/2022</td>
<td>5320812</td>
</tr>
<tr>
<td>7/2/2022</td>
<td>6841224</td>
</tr>
<tr>
<td>7/3/2022</td>
<td>6290576</td>
</tr>
<tr>
<td>7/4/2022</td>
<td>4248679</td>
</tr>
<tr>
<td>7/5/2022</td>
<td>3639110</td>
</tr>
<tr>
<td>7/6/2022</td>
<td>3002182</td>
</tr>
<tr>
<td>7/7/2022</td>
<td>2460108</td>
</tr>
<tr>
<td>7/8/2022</td>
<td>3326066</td>
</tr>
<tr>
<td>7/9/2022</td>
<td>4324040</td>
</tr>
<tr>
<td>7/10/2022</td>
<td>3530965</td>
</tr>
</tbody>
</table>
</div>
<p>I'd like to be able to get results that look like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Weekend</th>
<th>DBO Sum</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>31211579</td>
</tr>
<tr>
<td>2</td>
<td>18452612</td>
</tr>
<tr>
<td>3</td>
<td>11181071</td>
</tr>
</tbody>
</table>
</div>
<p>Also - not sure how tricky this would be but would love to include percent change v. last weekend.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Weekend</th>
<th>DBO Sum</th>
<th>% Change</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>31211579</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>18452612</td>
<td>-41%</td>
</tr>
<tr>
<td>3</td>
<td>11181071</td>
<td>-39%</td>
</tr>
</tbody>
</table>
</div>
<p>I tried this with CASE WHEN but I got the results in different columns, which was not what I was looking for.</p>
<pre><code>SELECT
,SUM(CASE
WHEN DATE BETWEEN '2022-06-24' AND '2022-06-26' THEN index
ELSE 0
END) AS Weekend1
,SUM(CASE
WHEN DATE BETWEEN '2022-07-01' AND '2022-07-03' THEN index
ELSE 0
END) AS Weekend2
,SUM(CASE
WHEN DATE BETWEEN '2022-07-08' AND '2022-07-10' THEN index
ELSE 0
END) AS Weekend3
FROM Elvis
</code></pre>
|
[
{
"answer_id": 74487153,
"author": "A M",
"author_id": 9666018,
"author_profile": "https://Stackoverflow.com/users/9666018",
"pm_score": 2,
"selected": true,
"text": "std::vector"
},
{
"answer_id": 74487282,
"author": "YourDoge",
"author_id": 20147194,
"author_profile": "https://Stackoverflow.com/users/20147194",
"pm_score": 0,
"selected": false,
"text": "strtok()"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534430/"
] |
74,483,048
|
<p>how to use Russian Language in HTML? and Is their any best way to type in Russian Keyboard, if their is no option in PC? (Except Google) Actually Google translate my paragraph, but I need to add some text too.</p>
<p>Thanks</p>
<p>I tried using google translate.</p>
|
[
{
"answer_id": 74487153,
"author": "A M",
"author_id": 9666018,
"author_profile": "https://Stackoverflow.com/users/9666018",
"pm_score": 2,
"selected": true,
"text": "std::vector"
},
{
"answer_id": 74487282,
"author": "YourDoge",
"author_id": 20147194,
"author_profile": "https://Stackoverflow.com/users/20147194",
"pm_score": 0,
"selected": false,
"text": "strtok()"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534577/"
] |
74,483,058
|
<p>I am using C# with Xamarin Forms and I don't know how to add values to a ListView without repeating them.</p>
<p>I haven't tried anything yet</p>
<p>InventoryPerRowModel.Add(new InventoryPerRow { IntRow = Convert.ToInt32(Row.Text), IntPlants = Convert.ToInt32(TotalPlants.Text), IntPlantsUnusable = Convert.ToInt32(PlantsUnusable.Text) });</p>
<p>var InventoryPorSurcoModelOrdenado = InventoryPorSurcoModel.OrderBy(x => x.IntSurco).ToList();
MyListView.ItemsSource = InventoryByPathSortedModel;</p>
|
[
{
"answer_id": 74487153,
"author": "A M",
"author_id": 9666018,
"author_profile": "https://Stackoverflow.com/users/9666018",
"pm_score": 2,
"selected": true,
"text": "std::vector"
},
{
"answer_id": 74487282,
"author": "YourDoge",
"author_id": 20147194,
"author_profile": "https://Stackoverflow.com/users/20147194",
"pm_score": 0,
"selected": false,
"text": "strtok()"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20471690/"
] |
74,483,090
|
<p>I am looking for the way to remove duplicates. I found a common way is to create a Set and then spread into a new Array.</p>
<p>How could I Set to acomplish this purpose? For instance, I have the following code:</p>
<pre><code>const tmp1=[];
const tmp2=[{
guid:"e695d848-7188-4741-9c95-44bec634940f",
name: "Spreading.pdf",
code: "G1"
}];
const tmp = [...new Set([...tmp1],[...tmp2])]; //This should remove duplicates, but gets empty array
const x = [...tmp1, ...tmp2]; // This would keep duplicates
</code></pre>
<p>The issue is that because tmp1 is an empty array, then I am getting empty result. However, if I do the following, then getting correct result:</p>
<pre><code>const tmp = [...new Set(...tmp1,[...tmp2])];
</code></pre>
<p>I think something is missing in here.</p>
<p>This is an example of duplicated entries where Set is working like a charm just keeping one record:</p>
<pre><code>const tmp1=[{
guid:"e695d848-7188-4741-9c95-44bec634940f",
name: "Spreading.pdf",
code: "G1"
}];
const tmp2=[{
guid:"e695d848-7188-4741-9c95-44bec634940f",
name: "Spreading.pdf",
code: "G1"
}];
const tmp = [...new Set([...tmp1],[...tmp2])];
</code></pre>
<p>This was the original idea, but how about if one of the lists is empty. Then, I am getting an empty array if this occurs.</p>
<p>Thank you</p>
|
[
{
"answer_id": 74487153,
"author": "A M",
"author_id": 9666018,
"author_profile": "https://Stackoverflow.com/users/9666018",
"pm_score": 2,
"selected": true,
"text": "std::vector"
},
{
"answer_id": 74487282,
"author": "YourDoge",
"author_id": 20147194,
"author_profile": "https://Stackoverflow.com/users/20147194",
"pm_score": 0,
"selected": false,
"text": "strtok()"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4538768/"
] |
74,483,104
|
<p>I have a pandas data frame with dates. I need to know if every other date pair is consecutive.</p>
<pre><code>2 1988-01-01
3 2015-01-31
4 2015-02-01
5 2015-05-31
6 2015-06-01
7 2021-11-16
11 2021-11-17
12 2022-10-05
8 2022-10-06
9 2022-10-12
10 2022-10-13
</code></pre>
<pre class="lang-py prettyprint-override"><code># How to build this example dataframe
df=pd.DataFrame({'date':pd.to_datetime(['1988-01-01','2015-01-31','2015-02-01', '2015-05-31','2015-06-01', '2021-11-16', '2021-11-17', '2022-10-05', '2022-10-06', '2022-10-12', '2022-10-13'])})
</code></pre>
<p>Each pair should be consecutive. I have tried different sorting but everything I see relates to the entire series being consecutive. I need to compare each pair of dates after the first date.</p>
<pre><code>cb_gap = cb_sorted.sort_values('dates').groupby('dates').diff() > pd.to_timedelta('1 day')
</code></pre>
<p>What I need to see is this...</p>
<pre><code>2 1988-01-01 <- Ignore the start date
3 2015-01-31 <- these dates have no gap
4 2015-02-01
5 2015-05-31 <- these dates have no gap
6 2015-06-01
7 2021-11-16 <- these have a gap!!!!
11 2021-11-18
12 2022-10-05 <- these have no gap
8 2022-10-06
9 2022-10-12
</code></pre>
|
[
{
"answer_id": 74483239,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 1,
"selected": false,
"text": "# make date into datetime\ndf['date'] = pd.to_datetime(df['date'])\n\n# create two intermediate DF skipping the first and taking alternate values\n# and concat them along x-axis\ndf2=pd.concat([df.iloc[1:].iloc[::2].reset_index()[['id','date']],\n df.iloc[2:].iloc[::2].reset_index()[['id','date']]\n ],axis=1 )\n\n# take the difference of second date from the first one\ndf2['diff']=df2.iloc[:,3]-df2.iloc[:,1]\ndf2\n\n"
},
{
"answer_id": 74488809,
"author": "chrslg",
"author_id": 20037042,
"author_profile": "https://Stackoverflow.com/users/20037042",
"pm_score": 0,
"selected": false,
"text": "pd.DataFrame({'date':df.date,'diff':df.date.shift(-1)-df.date})[1::2]\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20409660/"
] |
74,483,129
|
<p>I have a table with payment history</p>
<p>payments:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>consumer_id</th>
<th>amount</th>
<th>created_at</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>30</td>
<td>2021-05-11 13:01:36</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>-10</td>
<td>2021-05-12 14:01:36</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>-2.50</td>
<td>2021-05-13 13:01:36</td>
</tr>
<tr>
<td>4</td>
<td>1</td>
<td>-4.50</td>
<td>2021-05-14 13:01:36</td>
</tr>
<tr>
<td>5</td>
<td>1</td>
<td>20</td>
<td>2021-05-15 13:01:36</td>
</tr>
</tbody>
</table>
</div>
<p>In final result need to get consumer <strong>balance</strong> after each transaction.
So something like this</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>consumer_id</th>
<th>amount</th>
<th>created_at</th>
<th>balance</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>30</td>
<td>2021-05-11 13:01:36</td>
<td><em>30.00</em></td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>-10</td>
<td>2021-05-12 14:01:36</td>
<td><em>20.00</em></td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>-2.50</td>
<td>2021-05-13 13:01:36</td>
<td><em>17.50</em></td>
</tr>
<tr>
<td>4</td>
<td>1</td>
<td>-4.50</td>
<td>2021-05-14 13:01:36</td>
<td><em>13.00</em></td>
</tr>
<tr>
<td>5</td>
<td>1</td>
<td>20</td>
<td>2021-05-15 13:01:36</td>
<td><em>33.00</em></td>
</tr>
</tbody>
</table>
</div>
<p>I using this query</p>
<pre><code>SET @balanceTotal = 0;
select amount, created_at, consumer_id, @balanceTotal := @balanceTotal + amount as balance
from payments
where consumer_id = 1
</code></pre>
<p>This works fine until I try to add some sorting or pagination.</p>
<p>Any suggestion on how to write a query with <code>order by desc</code>, <code>limit</code>, and <code>offset</code> to count balance properly?</p>
|
[
{
"answer_id": 74483205,
"author": "GMB",
"author_id": 10676716,
"author_profile": "https://Stackoverflow.com/users/10676716",
"pm_score": 3,
"selected": true,
"text": "select p.*, \n sum(amount) over(partition by consumer_id order by created_at) balance\nfrom payments p\n"
},
{
"answer_id": 74483620,
"author": "nnichols",
"author_id": 1191247,
"author_profile": "https://Stackoverflow.com/users/1191247",
"pm_score": 1,
"selected": false,
"text": "select p.*, sum(amount) over(order by created_at) balance\nfrom payments p\nwhere consumer_id = 1\norder by created_at desc\nlimit 0, 5;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4433414/"
] |
74,483,141
|
<p>Hi I have a toggle switch and spinner on my page. I want for the spinner to stop spinning or disappear when the toggle switch is flicked off. I believe I need some kind of javascript for this but a I am a newbie. Please assist in writing javascript for this on how to execute the spinner based on the .switch value.</p>
<p>.html page</p>
<blockquote>
<pre><code> @keyframes spinner {
0% {
transform: translate3d(-50%, -50%, 0) rotate(0deg);
}
}
100% {
transform: translate3d(-50%, -50%, 0) rotate(360deg);
}
.switch {
position: relative;
display: inline-block;
width: 55px;
height: 28px;
}
.spin::before {
animation: 1.5s linear infinite spinner;
animation-play-state: inherit;
border: solid 5px #cfd0d1;
border-bottom-color: #1c87c9;
border-radius: 50%; content: "";
height: 20px; width: 20px;
position: absolute;
top: 26%; left:
35%;
transform: translate3d(-50%, -50%, 0);
will-change:
transform; }
.switch { position: relative; display: inline-block; width:
55px; height: 28px; }
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 20px;
width: 20px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
<span class="slider round"></span>
<div class="spin"></div>
</code></pre>
</blockquote>
|
[
{
"answer_id": 74483205,
"author": "GMB",
"author_id": 10676716,
"author_profile": "https://Stackoverflow.com/users/10676716",
"pm_score": 3,
"selected": true,
"text": "select p.*, \n sum(amount) over(partition by consumer_id order by created_at) balance\nfrom payments p\n"
},
{
"answer_id": 74483620,
"author": "nnichols",
"author_id": 1191247,
"author_profile": "https://Stackoverflow.com/users/1191247",
"pm_score": 1,
"selected": false,
"text": "select p.*, sum(amount) over(order by created_at) balance\nfrom payments p\nwhere consumer_id = 1\norder by created_at desc\nlimit 0, 5;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20453400/"
] |
74,483,145
|
<p>I have a string of characters like this in R</p>
<pre><code>ABCDE,"January 10, 2010",F,,,,GH,"March 9, 2009",,,
</code></pre>
<p>I would like to do something like <code>str.split()</code> to partition by all combinations of commas and quotation marks into an array of strings, but keep the commas in quotation marks that represent dates so that I get:</p>
<pre><code>ABCDE
January 10, 2010
F
GH
March 9, 2009
</code></pre>
<p>Thanks</p>
|
[
{
"answer_id": 74483274,
"author": "akrun",
"author_id": 3732271,
"author_profile": "https://Stackoverflow.com/users/3732271",
"pm_score": 3,
"selected": true,
"text": "read.table"
},
{
"answer_id": 74483276,
"author": "Andre Wildberg",
"author_id": 9462095,
"author_profile": "https://Stackoverflow.com/users/9462095",
"pm_score": 2,
"selected": false,
"text": "data.frame(list = na.omit(\n unname(unlist(read.csv(\n text = 'ABCDE,\"January 10, 2010\",F,,,,GH,\"March 9, 2009\",,,', \n check.names = F, header = F)))))\n list\n1 ABCDE\n2 January 10, 2010\n3 FALSE\n4 GH\n5 March 9, 2009\n"
},
{
"answer_id": 74483319,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 2,
"selected": false,
"text": "library(stringr)\nlibrary(dplyr)\n\nx <- \"ABCDE,\\\"January 10, 2010\\\",F,,,,GH,\\\"March 9, 2009\\\",,,\"\ny <- str_match_all(x, \"\\\"(.*?)\\\"|[^,]+\")[[1]]\noutput <- coalesce(y[,2], y[,1])\noutput\n\n[1] \"ABCDE\" \"January 10, 2010\" \"F\" \"GH\"\n[5] \"March 9, 2009\"\n"
},
{
"answer_id": 74483611,
"author": "onyambu",
"author_id": 8380272,
"author_profile": "https://Stackoverflow.com/users/8380272",
"pm_score": 1,
"selected": false,
"text": "na.omit(stack(read.csv(text = str1, header = FALSE)))[1]\n\n values\n1 ABCDE\n2 January 10, 2010\n3 FALSE\n4 GH\n5 March 9, 2009\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14122775/"
] |
74,483,173
|
<p>I would like my server to call the login endpoint of another server and cache the auth token for later use. My issue is that when the server tries to reuse the existing token it hangs indefinitely or infinite loops.</p>
<pre><code>@Component
class ApiWebClient {
private var authToken = Mono.just(AuthToken("", Instant.ofEpochSecond(0)))
fun login(): Mono<AuthToken> {
authToken = doesTokenNeedRefreshing().flatMap { needsRefreshing ->
if (needsRefreshing) {
WebClient.create().post()
.uri("https://example.com/login")
.body(
Mono.just("Credentials"),
String::class.java
).exchangeToMono { response ->
response.bodyToMono<LoginResponse>()
}.map { response ->
LOGGER.info("Successfully logged in")
AuthToken(response.token, Instant.now())
}
} else {
LOGGER.info("Reuse token")
authToken
}
}.cache()
return authToken
}
private fun doesTokenNeedRefreshing(): Mono<Boolean> {
return authToken.map {
Instant.now().minusMillis(ONE_MINUTE_IN_MILLIS).isAfter(it.lastModified)
}
}
class AuthToken(
var token: String,
var lastModified: Instant
)
companion object {
private const val ONE_MINUTE_IN_MILLIS = 60 * 1000L
@Suppress("JAVA_CLASS_ON_COMPANION")
@JvmStatic
private val LOGGER = LoggerFactory.getLogger(javaClass.enclosingClass)
}
}
</code></pre>
<p>If login gets called twice within the <code>ONE_MINUTE_IN_MILLIS</code> amount of time then it just hangs. I suspect this is because the <code>doesTokenNeedRefreshing()</code> calls a <code>.map {}</code> on <code>authToken</code> and then later down the chain <code>authToken</code> is reassigned to itself. As well, there's an attempt to recache that exact same value. I've played around with recreating <code>AuthToken</code> each time instead of returning the same instance but no luck. The server either hangs or infinite loops.</p>
<p>How can I achieve returning the same instance of the cached value so I don't have to make a web request each time?</p>
|
[
{
"answer_id": 74483274,
"author": "akrun",
"author_id": 3732271,
"author_profile": "https://Stackoverflow.com/users/3732271",
"pm_score": 3,
"selected": true,
"text": "read.table"
},
{
"answer_id": 74483276,
"author": "Andre Wildberg",
"author_id": 9462095,
"author_profile": "https://Stackoverflow.com/users/9462095",
"pm_score": 2,
"selected": false,
"text": "data.frame(list = na.omit(\n unname(unlist(read.csv(\n text = 'ABCDE,\"January 10, 2010\",F,,,,GH,\"March 9, 2009\",,,', \n check.names = F, header = F)))))\n list\n1 ABCDE\n2 January 10, 2010\n3 FALSE\n4 GH\n5 March 9, 2009\n"
},
{
"answer_id": 74483319,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 2,
"selected": false,
"text": "library(stringr)\nlibrary(dplyr)\n\nx <- \"ABCDE,\\\"January 10, 2010\\\",F,,,,GH,\\\"March 9, 2009\\\",,,\"\ny <- str_match_all(x, \"\\\"(.*?)\\\"|[^,]+\")[[1]]\noutput <- coalesce(y[,2], y[,1])\noutput\n\n[1] \"ABCDE\" \"January 10, 2010\" \"F\" \"GH\"\n[5] \"March 9, 2009\"\n"
},
{
"answer_id": 74483611,
"author": "onyambu",
"author_id": 8380272,
"author_profile": "https://Stackoverflow.com/users/8380272",
"pm_score": 1,
"selected": false,
"text": "na.omit(stack(read.csv(text = str1, header = FALSE)))[1]\n\n values\n1 ABCDE\n2 January 10, 2010\n3 FALSE\n4 GH\n5 March 9, 2009\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6106641/"
] |
74,483,231
|
<p>I come from SQL Server and some times I'm not familiar to Oracle syntax, I want to create a function that takes a date and number of dates as a parameters and create a table function.</p>
<p>My original query is:</p>
<pre><code>VAR TREND = 1;
VAR OBS_DATE = 20221109;
VAR N_DAYS = 21;
WITH CAL AS
(
SELECT
TO_DATE(:OBS_DATE, 'YYYYMMDD') + (LEVEL - 1 * :TREND) DT, ROW_NUMBER() OVER(ORDER BY NULL) - 1 IX
FROM
DUAL
WHERE
TO_CHAR(TO_DATE(:OBS_DATE, 'YYYYMMDD') + (LEVEL - 1 * :TREND) , 'D') NOT IN (1,7)
CONNECT BY LEVEL <= :N_DAYS + :N_DAYS/5*2+1
)
SELECT DT
FROM CAL
WHERE IX <= :N_DAYS;
</code></pre>
<p>But when I try to convert as a function it sends me an error and I don't know what the correct syntax is.</p>
<p>My attempt is:</p>
<pre><code>CREATE OR REPLACE FUNCTION FUN_BUS_CALENDAR(
OBS_DATE IN DATE := SYSDATE
, NDAYS IN NUMBER
, TREND IN NUMBER
)
RETURN OBS_DATE DATE;
BEGIN
WITH CAL AS(
SELECT
TO_DATE(:OBS_DATE, 'YYYYMMDD') + (LEVEL - 1 * :TREND) OBS_DATE, ROW_NUMBER() OVER(ORDER BY NULL) - 1 IX
FROM DUAL
WHERE TO_CHAR(TO_DATE(:OBS_DATE, 'YYYYMMDD') + (LEVEL - 1 * :TREND) , 'D') NOT IN (1,7)
CONNECT BY LEVEL <= :N_DAYS + :N_DAYS/5.*2.+1.
)
SELECT OBS_DATE FROM CAL WHERE IX <= :N_DAYS
RETURN OBS_DATE
END
/
</code></pre>
|
[
{
"answer_id": 74483410,
"author": "MT0",
"author_id": 1509264,
"author_profile": "https://Stackoverflow.com/users/1509264",
"pm_score": 1,
"selected": false,
"text": "CREATE FUNCTION BARRRAF.FUN_BUS_CALENDAR(\n OBS_DATE IN DATE := SYSDATE,\n NDAYS IN NUMBER,\n TREND IN NUMBER\n) RETURN SYS.ODCIDATELIST PIPELINED\nIS\nBEGIN\n FOR i IN 1 .. ndays LOOP\n PIPE ROW( obs_date + i - trend );\n END LOOP;\nEND;\n/\n"
},
{
"answer_id": 74487521,
"author": "Pugzly",
"author_id": 16771377,
"author_profile": "https://Stackoverflow.com/users/16771377",
"pm_score": 0,
"selected": false,
"text": "\nCREATE OR REPLACE FUNCTION generate_dates(i_from_dat IN TIMESTAMP, i_to_dat IN TIMESTAMP, i_interval IN NUMBER, i_interval_type IN VARCHAR2)\nRETURN VARCHAR2\nSQL_MACRO\nIS\nBEGIN\n RETURN q'~SELECT LEAST(i_from_dat,i_to_dat) + NUMTODSINTERVAL( (LEVEL-1)*i_interval, i_interval_type ) AS dt\n FROM DUAL\n CONNECT BY LEAST(i_from_dat,i_to_dat) + NUMTODSINTERVAL( (LEVEL-1)*i_interval, i_interval_type) < GREATEST(i_from_dat, i_to_dat)~';\nEND ;\n\nSELECT * FROM generate_dates(\nTIMESTAMP '2022-11-03 09:47:31',\nTIMESTAMP '2022-11-03 12:37:11',\n 30, 'MINUTE') ;\n\nDT\n03-NOV-22 09.47.31.000000 AM\n03-NOV-22 10.17.31.000000 AM\n03-NOV-22 10.47.31.000000 AM\n03-NOV-22 11.17.31.000000 AM\n03-NOV-22 11.47.31.000000 AM\n03-NOV-22 12.17.31.000000 PM\n\nSELECT * FROM generate_dates(\nTIMESTAMP '2022-11-03 00:00:00',\nTIMESTAMP '2022-11-08 00:00:00',\n 1, 'DAY') ;\n\nDT\n03-NOV-22 12.00.00.000000 AM\n04-NOV-22 12.00.00.000000 AM\n05-NOV-22 12.00.00.000000 AM\n06-NOV-22 12.00.00.000000 AM\n07-NOV-22 12.00.00.000000 AM\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946796/"
] |
74,483,236
|
<blockquote>
<p>I need to code a method that checks if:</p>
<p>A = all numbers are equal.
B = no numbers are equal.
C = at least two numbers are equal.</p>
<p>Im just beginning to learn all this in uni but I cant seem to figure out what i am doing wrong in this method which needs to return the given conditions e.g("A", "B", "C").</p>
</blockquote>
<pre><code>public static int checkNumbers(int x, int y, int z)
{
int A,B,C;
A = 'A';
B = 'B';
C = 'C';
if((x == y) && (y == z))
{
return A;
}
else if ((x == y) || (x == z) || (y == z))
{
return C;
}
else
{
return B;
}
}
</code></pre>
|
[
{
"answer_id": 74483410,
"author": "MT0",
"author_id": 1509264,
"author_profile": "https://Stackoverflow.com/users/1509264",
"pm_score": 1,
"selected": false,
"text": "CREATE FUNCTION BARRRAF.FUN_BUS_CALENDAR(\n OBS_DATE IN DATE := SYSDATE,\n NDAYS IN NUMBER,\n TREND IN NUMBER\n) RETURN SYS.ODCIDATELIST PIPELINED\nIS\nBEGIN\n FOR i IN 1 .. ndays LOOP\n PIPE ROW( obs_date + i - trend );\n END LOOP;\nEND;\n/\n"
},
{
"answer_id": 74487521,
"author": "Pugzly",
"author_id": 16771377,
"author_profile": "https://Stackoverflow.com/users/16771377",
"pm_score": 0,
"selected": false,
"text": "\nCREATE OR REPLACE FUNCTION generate_dates(i_from_dat IN TIMESTAMP, i_to_dat IN TIMESTAMP, i_interval IN NUMBER, i_interval_type IN VARCHAR2)\nRETURN VARCHAR2\nSQL_MACRO\nIS\nBEGIN\n RETURN q'~SELECT LEAST(i_from_dat,i_to_dat) + NUMTODSINTERVAL( (LEVEL-1)*i_interval, i_interval_type ) AS dt\n FROM DUAL\n CONNECT BY LEAST(i_from_dat,i_to_dat) + NUMTODSINTERVAL( (LEVEL-1)*i_interval, i_interval_type) < GREATEST(i_from_dat, i_to_dat)~';\nEND ;\n\nSELECT * FROM generate_dates(\nTIMESTAMP '2022-11-03 09:47:31',\nTIMESTAMP '2022-11-03 12:37:11',\n 30, 'MINUTE') ;\n\nDT\n03-NOV-22 09.47.31.000000 AM\n03-NOV-22 10.17.31.000000 AM\n03-NOV-22 10.47.31.000000 AM\n03-NOV-22 11.17.31.000000 AM\n03-NOV-22 11.47.31.000000 AM\n03-NOV-22 12.17.31.000000 PM\n\nSELECT * FROM generate_dates(\nTIMESTAMP '2022-11-03 00:00:00',\nTIMESTAMP '2022-11-08 00:00:00',\n 1, 'DAY') ;\n\nDT\n03-NOV-22 12.00.00.000000 AM\n04-NOV-22 12.00.00.000000 AM\n05-NOV-22 12.00.00.000000 AM\n06-NOV-22 12.00.00.000000 AM\n07-NOV-22 12.00.00.000000 AM\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534699/"
] |
74,483,241
|
<p>When the phone number is entered, I want it to appear in the input in the format (123) - 456 - 78 - 90. how can I do it?</p>
<pre><code><template>
<div v-for="about in abouts">
<input type="text" v-model="about.phone">
<input type="text" v-model="about.mail">
</div>
</template>
<script>
export default {
data(){
return{
abouts:[{phone:'',mail:''},{phone:'',mail:''}]
}
}
}
</script>
</code></pre>
|
[
{
"answer_id": 74483410,
"author": "MT0",
"author_id": 1509264,
"author_profile": "https://Stackoverflow.com/users/1509264",
"pm_score": 1,
"selected": false,
"text": "CREATE FUNCTION BARRRAF.FUN_BUS_CALENDAR(\n OBS_DATE IN DATE := SYSDATE,\n NDAYS IN NUMBER,\n TREND IN NUMBER\n) RETURN SYS.ODCIDATELIST PIPELINED\nIS\nBEGIN\n FOR i IN 1 .. ndays LOOP\n PIPE ROW( obs_date + i - trend );\n END LOOP;\nEND;\n/\n"
},
{
"answer_id": 74487521,
"author": "Pugzly",
"author_id": 16771377,
"author_profile": "https://Stackoverflow.com/users/16771377",
"pm_score": 0,
"selected": false,
"text": "\nCREATE OR REPLACE FUNCTION generate_dates(i_from_dat IN TIMESTAMP, i_to_dat IN TIMESTAMP, i_interval IN NUMBER, i_interval_type IN VARCHAR2)\nRETURN VARCHAR2\nSQL_MACRO\nIS\nBEGIN\n RETURN q'~SELECT LEAST(i_from_dat,i_to_dat) + NUMTODSINTERVAL( (LEVEL-1)*i_interval, i_interval_type ) AS dt\n FROM DUAL\n CONNECT BY LEAST(i_from_dat,i_to_dat) + NUMTODSINTERVAL( (LEVEL-1)*i_interval, i_interval_type) < GREATEST(i_from_dat, i_to_dat)~';\nEND ;\n\nSELECT * FROM generate_dates(\nTIMESTAMP '2022-11-03 09:47:31',\nTIMESTAMP '2022-11-03 12:37:11',\n 30, 'MINUTE') ;\n\nDT\n03-NOV-22 09.47.31.000000 AM\n03-NOV-22 10.17.31.000000 AM\n03-NOV-22 10.47.31.000000 AM\n03-NOV-22 11.17.31.000000 AM\n03-NOV-22 11.47.31.000000 AM\n03-NOV-22 12.17.31.000000 PM\n\nSELECT * FROM generate_dates(\nTIMESTAMP '2022-11-03 00:00:00',\nTIMESTAMP '2022-11-08 00:00:00',\n 1, 'DAY') ;\n\nDT\n03-NOV-22 12.00.00.000000 AM\n04-NOV-22 12.00.00.000000 AM\n05-NOV-22 12.00.00.000000 AM\n06-NOV-22 12.00.00.000000 AM\n07-NOV-22 12.00.00.000000 AM\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19301566/"
] |
74,483,250
|
<p>I currently have an array where the user inputs the number of rows and columns, then the system outputs it and sums all elements.
I know how to sum all elements in the array, but don't understand how to specifically sum elements only in ODD columns.
Since the column indexes start with 0, it would have to start with the second column, skip one and sum all elements in the one after that and so on.</p>
<p>This code outputs the array and sums all elements. I think I have to add another loop before the "sum" ones, but don't know how. Thanks in advance.</p>
<pre><code>import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int row, col, sum;
row = sc.nextInt();
col = sc.nextInt();
sum = 0;
int [][] a = new int [row] [col];
for (int i=0; i<a.length; i++) {
for (int j=0; j<a[i].length; j++) {
a[i][j] = i+j+1;
}
}
for (int[] rows : a) {
for (int item : rows) {
System.out.print(item + " ");
}
System.out.println();
}
for (int[] arr : a) {
for(int i: arr) {
sum+=i;
}
}
System.out.print("sum=" + sum);
sc.close();
}
}
</code></pre>
|
[
{
"answer_id": 74483752,
"author": "Iddo Sadeh",
"author_id": 3620846,
"author_profile": "https://Stackoverflow.com/users/3620846",
"pm_score": 0,
"selected": false,
"text": "int counter =0;\nfor (int[] arr : a) {\n if (counter %2 == 0){\n counter +=1;\n continue;\n }\n else{\n for(int i: arr) {\n counter+=1;\n sum+=i; \n }\n }\n}\n"
},
{
"answer_id": 74483793,
"author": "human bean",
"author_id": 17186475,
"author_profile": "https://Stackoverflow.com/users/17186475",
"pm_score": 1,
"selected": false,
"text": "int sum = 0; \nfor (int i = 1; i < arr.length; i += 2)\n for (int j = 0; j < arr[i].length; j++)\n sum += arr[i][j];\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534706/"
] |
74,483,288
|
<p>I need a special Widget.</p>
<p>Hey, I need the name pros.</p>
<p>Is there a widget that can be moved freely. Like how you can just move on with maps?</p>
<p>So basically scrollable in all directions.</p>
|
[
{
"answer_id": 74484383,
"author": "Soliev",
"author_id": 19945688,
"author_profile": "https://Stackoverflow.com/users/19945688",
"pm_score": 1,
"selected": false,
"text": "import 'package:flutter/material.dart';\n\nvoid main() => runApp(const MyApp());\n\nclass MyApp extends StatelessWidget {\n const MyApp({super.key});\n\n static const String _title = 'Flutter Code Sample';\n\n @override\n Widget build(BuildContext context) {\n return const MaterialApp(\n title: _title,\n home: HomePage(),\n );\n }\n}\n\nclass HomePage extends StatefulWidget {\n const HomePage({super.key});\n\n @override\n State<HomePage> createState() => _HomePageState();\n}\n\nclass _HomePageState extends State<HomePage> {\n late Offset _offset;\n\n @override\n void initState() {\n _offset = const Offset(0, 0);\n super.initState();\n }\n\n @override\n Widget build(BuildContext context) {\n return Scaffold(\n appBar: AppBar(title: Text(_offset.toString())),\n body: SizedBox.expand(\n child: InteractiveViewer(\n onInteractionUpdate: (details) => setState(() {\n _offset = details.focalPoint;\n }),\n boundaryMargin: const EdgeInsets.all(1000.0),\n minScale: 0.1,\n maxScale: 3,\n child: Center(\n child: TextButton(\n child: const Text('Drag me'),\n onPressed: () {\n },\n ),\n ),\n ),\n ),\n );\n }\n}\n\n"
},
{
"answer_id": 74484425,
"author": "MrShakila",
"author_id": 19292778,
"author_profile": "https://Stackoverflow.com/users/19292778",
"pm_score": 0,
"selected": false,
"text": "Draggable(\n data: 'Flutter',\n child: FlutterLogo(\n size: 100.0,\n ),\n feedback: FlutterLogo(\n size: 100.0,\n ),\n childWhenDragging: Container(),\n )\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534756/"
] |
74,483,315
|
<p>I am trying to read a .txt file with a certain format and fill it into a matrix in Java.</p>
<p>The text file has following format:</p>
<pre><code>123
456
</code></pre>
<p>I have the following code, that creates the matrix based on the .txt file with the right dimension(2 rows, 3 columns in this case).</p>
<pre><code>public static int [][] readMatrix(String url)
throws FileNotFoundException {
int m = 1;
String URL = '.\src\User\url.txt';
File file = new File((url));
Scanner sc = new Scanner(file);
String line = sc.nextLine();
int n = line.length();
while (sc.hasNextLine()) {
m+= 1;
sc.nextLine();
}
int [][] matrix = new int[m][n];
return matrix;
}
</code></pre>
<p>In the next step, I want to fill out the matrix with the content from the .txt file, I tried using a Scanner but I couldn't figure out the syntax to iterate properly.</p>
<p>Any suggestions?</p>
<p>Thanks in advance!</p>
|
[
{
"answer_id": 74484264,
"author": "Jacob Malland",
"author_id": 17160379,
"author_profile": "https://Stackoverflow.com/users/17160379",
"pm_score": 0,
"selected": false,
"text": "ArrayList<String>"
},
{
"answer_id": 74484265,
"author": "Vini",
"author_id": 98044,
"author_profile": "https://Stackoverflow.com/users/98044",
"pm_score": 1,
"selected": false,
"text": "rows"
},
{
"answer_id": 74485448,
"author": "DevilsHnd",
"author_id": 4725875,
"author_profile": "https://Stackoverflow.com/users/4725875",
"pm_score": 0,
"selected": false,
"text": "342354645686786\n423423689909754\n677554345952536\n238884546869621\n345665678683481\n342354645686786\n423423689909754\n677554345952536\n238884546869621\n345665678683481\n342354645686786\n423423689909754\n677554345952536\n238884546869621\n423423689909754\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10491430/"
] |
74,483,321
|
<p>I wanted to adapt this code show that, for example if you hovered over a specific , then the relating would also show. useState seems to be the only way to make this work in React as I tried a different example with eventlistner which crashed the page.</p>
<pre><code>const Showstuff = () => {
const [isHovering, setIsHovering] = useState(false);
const handleMouseOver = () => {
setIsHovering(true);
};
const handleMouseOut = () => {
setIsHovering(false);
};
return(
<div>
<div onMouseOver={handleMouseOver} onMouseOut={handleMouseOut}>
Hover over div #1 here
</div><br /><br />
<div>
Hover over div #2 here
</div>
{isHovering && (
<div>
<h2>Text here visible when hovering div 1</h2>
</div>
)}
</div>
)
};
export default Showstuff;
</code></pre>
<p>I made multiple useStates for each items as a work around, but this means there's 3x const lines for each item I want to add, and I have 6 elements to hover. Can this be combined into a shorter code? I also tried:</p>
<pre><code>const el = document.getElementById('container');
const hiddenDiv = document.getElementById('hidden-div');
el.addEventListener('mouseover', function handleMouseOver() {
hiddenDiv.style.visibility = 'visible';
});
el.addEventListener('mouseout', function handleMouseOut() {
hiddenDiv.style.visibility = 'hidden';
});
</code></pre>
<p>from a guide on bobbyhadz website but this would require the same idea of making multiple lines of the same code with different names. This works immediately after saving the page in vscode but then shortly afterwards crashes the page, and does not work - I assume it is not React compatible.</p>
|
[
{
"answer_id": 74483476,
"author": "Enyak Stew",
"author_id": 13398497,
"author_profile": "https://Stackoverflow.com/users/13398497",
"pm_score": 2,
"selected": true,
"text": "function App() {\n const [isHovered, setIsHovered] = useState(null)\n const handleMouseOver = (e) => {\n switch (e.target.id) {\n case \"1\":\n setIsHovered(1)\n break\n case \"2\":\n setIsHovered(2)\n break\n }\n }\n\n return (\n <div className=\"App\">\n <div id=\"1\" onMouseOver={handleMouseOver} onMouseOut={() => setIsHovered(null)}>\n DIV 1\n </div>\n <div id=\"2\" onMouseOver={handleMouseOver} onMouseOut={() => setIsHovered(null)}>\n DIV 2\n </div>\n {isHovered && <h2>{isHovered === 1 ? \"Div 1 is hovered\" : \"Div 2 is hovered\"}</h2>}\n </div>\n )\n}\n"
},
{
"answer_id": 74483537,
"author": "cjl750",
"author_id": 6656062,
"author_profile": "https://Stackoverflow.com/users/6656062",
"pm_score": 1,
"selected": false,
"text": "isHovering"
},
{
"answer_id": 74483628,
"author": "Chris Hamilton",
"author_id": 12914833,
"author_profile": "https://Stackoverflow.com/users/12914833",
"pm_score": 0,
"selected": false,
"text": "export default function App() {\n const [isHovering, setIsHovering] = useState(new Array(4).fill(false));\n\n function handleMouseEnter(i) {\n setIsHovering((prev) => {\n const next = [...prev];\n next[i] = true;\n return next;\n });\n }\n\n function handleMouseLeave(i) {\n setIsHovering((prev) => {\n const next = [...prev];\n next[i] = false;\n return next;\n });\n }\n\n return (\n <>\n {isHovering.map((_, i) => (\n <span\n onMouseEnter={() => handleMouseEnter(i)}\n onMouseLeave={() => handleMouseLeave(i)}\n ></span>\n ))}\n {isHovering.map((v, i) => (\n <p>\n Hovering on {i}: {v.toString()}\n </p>\n ))}\n </>\n );\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18423250/"
] |
74,483,334
|
<p>I want to make the site like the picture
(<a href="https://i.stack.imgur.com/rFj7L.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/rFj7L.jpg</a>)</p>
<p>and because Im new I cant. Can you help me?</p>
|
[
{
"answer_id": 74483476,
"author": "Enyak Stew",
"author_id": 13398497,
"author_profile": "https://Stackoverflow.com/users/13398497",
"pm_score": 2,
"selected": true,
"text": "function App() {\n const [isHovered, setIsHovered] = useState(null)\n const handleMouseOver = (e) => {\n switch (e.target.id) {\n case \"1\":\n setIsHovered(1)\n break\n case \"2\":\n setIsHovered(2)\n break\n }\n }\n\n return (\n <div className=\"App\">\n <div id=\"1\" onMouseOver={handleMouseOver} onMouseOut={() => setIsHovered(null)}>\n DIV 1\n </div>\n <div id=\"2\" onMouseOver={handleMouseOver} onMouseOut={() => setIsHovered(null)}>\n DIV 2\n </div>\n {isHovered && <h2>{isHovered === 1 ? \"Div 1 is hovered\" : \"Div 2 is hovered\"}</h2>}\n </div>\n )\n}\n"
},
{
"answer_id": 74483537,
"author": "cjl750",
"author_id": 6656062,
"author_profile": "https://Stackoverflow.com/users/6656062",
"pm_score": 1,
"selected": false,
"text": "isHovering"
},
{
"answer_id": 74483628,
"author": "Chris Hamilton",
"author_id": 12914833,
"author_profile": "https://Stackoverflow.com/users/12914833",
"pm_score": 0,
"selected": false,
"text": "export default function App() {\n const [isHovering, setIsHovering] = useState(new Array(4).fill(false));\n\n function handleMouseEnter(i) {\n setIsHovering((prev) => {\n const next = [...prev];\n next[i] = true;\n return next;\n });\n }\n\n function handleMouseLeave(i) {\n setIsHovering((prev) => {\n const next = [...prev];\n next[i] = false;\n return next;\n });\n }\n\n return (\n <>\n {isHovering.map((_, i) => (\n <span\n onMouseEnter={() => handleMouseEnter(i)}\n onMouseLeave={() => handleMouseLeave(i)}\n ></span>\n ))}\n {isHovering.map((v, i) => (\n <p>\n Hovering on {i}: {v.toString()}\n </p>\n ))}\n </>\n );\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18351706/"
] |
74,483,354
|
<p>I have been trying to load a video in my production environment with Next.js, but I can't. I have created <strong>public/assets/video</strong> route and I have an <code>.mp4</code> file saved there. There is a <strong>public/assets/images</strong> route and I have like 50 pictures there and they work perfectly. I noticed that when I run <code>npm run build</code> in my <code>.next/static/media</code> folder, the video doesn't appear there.
In my <code>tsconfig.json</code> I added the necessary path (like I did with images) , but it still doesn't work:</p>
<p><strong>tsconfig.json</strong></p>
<pre><code>"paths": {
"@images/*": [
"./public/assets/images/*"
],
**"@videos/*": [
"./public/assets/videos/*"
],**
</code></pre>
<p>There's the code to show the video that works locally.</p>
<p><strong>index.tsx</strong></p>
<pre><code> <div>
<iframe
width={windowSize.width}
height={windowSize.height}
allow="autoplay"
src="/assets/videos/videolabone_.mp4"
title="videolabone">
</iframe>
</div>
</code></pre>
<p><strong>package-lock.json</strong></p>
<pre><code>"dependencies": {
"@emailjs/browser": "^3.6.2",
"@emotion/cache": "~11.7.1",
"@emotion/react": "~11.7.1",
"@emotion/server": "~11.4.0",
"@emotion/styled": "~11.6.0",
"@mui/icons-material": "~5.2.5",
"@mui/material": "~5.2.5",
"@mui/styles": "5.2.3",
"aos": "^2.3.4",
"formik": "2.2.9",
"next": "^12.1.6",
"npm-check-updates": "^16.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "~7.2.6",
"react-toastify": "^9.0.5",
"redux-thunk": "~2.4.1",
"sass": "~1.45.1",
"sharp": "0.29.3",
"yup": "0.32.11"
},
</code></pre>
<p><strong>Note:</strong></p>
<ul>
<li>It works with the video in my project and in a docker image, both run locally.</li>
<li>I have saved the video in git large file stage.</li>
<li>I have been trying to show the video in my project, which is on DigitalOcean server, with a docker container and that's where it doesn't load.</li>
</ul>
<p><a href="https://i.stack.imgur.com/ICmWo.png" rel="nofollow noreferrer">This appears in production</a></p>
<p>I have tried to change the video format, save it in git lfs, put the video source directly on Google Drive</p>
|
[
{
"answer_id": 74483476,
"author": "Enyak Stew",
"author_id": 13398497,
"author_profile": "https://Stackoverflow.com/users/13398497",
"pm_score": 2,
"selected": true,
"text": "function App() {\n const [isHovered, setIsHovered] = useState(null)\n const handleMouseOver = (e) => {\n switch (e.target.id) {\n case \"1\":\n setIsHovered(1)\n break\n case \"2\":\n setIsHovered(2)\n break\n }\n }\n\n return (\n <div className=\"App\">\n <div id=\"1\" onMouseOver={handleMouseOver} onMouseOut={() => setIsHovered(null)}>\n DIV 1\n </div>\n <div id=\"2\" onMouseOver={handleMouseOver} onMouseOut={() => setIsHovered(null)}>\n DIV 2\n </div>\n {isHovered && <h2>{isHovered === 1 ? \"Div 1 is hovered\" : \"Div 2 is hovered\"}</h2>}\n </div>\n )\n}\n"
},
{
"answer_id": 74483537,
"author": "cjl750",
"author_id": 6656062,
"author_profile": "https://Stackoverflow.com/users/6656062",
"pm_score": 1,
"selected": false,
"text": "isHovering"
},
{
"answer_id": 74483628,
"author": "Chris Hamilton",
"author_id": 12914833,
"author_profile": "https://Stackoverflow.com/users/12914833",
"pm_score": 0,
"selected": false,
"text": "export default function App() {\n const [isHovering, setIsHovering] = useState(new Array(4).fill(false));\n\n function handleMouseEnter(i) {\n setIsHovering((prev) => {\n const next = [...prev];\n next[i] = true;\n return next;\n });\n }\n\n function handleMouseLeave(i) {\n setIsHovering((prev) => {\n const next = [...prev];\n next[i] = false;\n return next;\n });\n }\n\n return (\n <>\n {isHovering.map((_, i) => (\n <span\n onMouseEnter={() => handleMouseEnter(i)}\n onMouseLeave={() => handleMouseLeave(i)}\n ></span>\n ))}\n {isHovering.map((v, i) => (\n <p>\n Hovering on {i}: {v.toString()}\n </p>\n ))}\n </>\n );\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20094870/"
] |
74,483,362
|
<p>When you have a Stream of Objects you can filter on them pretty elegantly.</p>
<pre class="lang-java prettyprint-override"><code>swimmingAnimalStream = animalStream
.filter(Animal::canSwim);
</code></pre>
<p>When you have slightly more complex filters instead of using Method references you have to use Lambdas.</p>
<pre class="lang-java prettyprint-override"><code>greenAnimals = animalStream
.filter(animal -> animal.getColor().equals(Colors.GREEN));
</code></pre>
<p>Is there a way to map the value before filtering on it, but still have the complete object after the filter?
So the fallowing is not what I want:</p>
<pre class="lang-java prettyprint-override"><code>animalStream
.map(Animal::getColor)
.filter(Colors.GREEN::equals)
</code></pre>
<p>With this I would be left with color information only.
What I also would like to avoid is extracting the method. I am looking for a more streamlined way of doing this. Something like this for example:</p>
<pre class="lang-java prettyprint-override"><code>animalStream
.filter(Colors.GREEN::equals, Animal::getColor);
</code></pre>
<p>The method signature of this filter method would look like this.</p>
<pre class="lang-java prettyprint-override"><code><MAPPED> Stream<T> filter(Predicate<MAPPED> filter, Function<? super T, MAPPED> mappingFunction);
</code></pre>
<p>Even better would be a version where you could join multiple mapping functions. On the fly one could maybe use a varargs for the mappingFunction. But I honestly don’t know how that would be possible with Generics. But that’s a different story.</p>
<p>The solution should also be able to use whatever Predicate that one could imagine. Equals is just an Example. Another example would be to check if a field from the object is present.</p>
<pre class="lang-java prettyprint-override"><code>animalWithMotherStream = animalStream
.filter(Optional::isPresent, Animal::getMother);
</code></pre>
<p>Does anyone now a cleaner Solution, or a library that does this already?</p>
|
[
{
"answer_id": 74483476,
"author": "Enyak Stew",
"author_id": 13398497,
"author_profile": "https://Stackoverflow.com/users/13398497",
"pm_score": 2,
"selected": true,
"text": "function App() {\n const [isHovered, setIsHovered] = useState(null)\n const handleMouseOver = (e) => {\n switch (e.target.id) {\n case \"1\":\n setIsHovered(1)\n break\n case \"2\":\n setIsHovered(2)\n break\n }\n }\n\n return (\n <div className=\"App\">\n <div id=\"1\" onMouseOver={handleMouseOver} onMouseOut={() => setIsHovered(null)}>\n DIV 1\n </div>\n <div id=\"2\" onMouseOver={handleMouseOver} onMouseOut={() => setIsHovered(null)}>\n DIV 2\n </div>\n {isHovered && <h2>{isHovered === 1 ? \"Div 1 is hovered\" : \"Div 2 is hovered\"}</h2>}\n </div>\n )\n}\n"
},
{
"answer_id": 74483537,
"author": "cjl750",
"author_id": 6656062,
"author_profile": "https://Stackoverflow.com/users/6656062",
"pm_score": 1,
"selected": false,
"text": "isHovering"
},
{
"answer_id": 74483628,
"author": "Chris Hamilton",
"author_id": 12914833,
"author_profile": "https://Stackoverflow.com/users/12914833",
"pm_score": 0,
"selected": false,
"text": "export default function App() {\n const [isHovering, setIsHovering] = useState(new Array(4).fill(false));\n\n function handleMouseEnter(i) {\n setIsHovering((prev) => {\n const next = [...prev];\n next[i] = true;\n return next;\n });\n }\n\n function handleMouseLeave(i) {\n setIsHovering((prev) => {\n const next = [...prev];\n next[i] = false;\n return next;\n });\n }\n\n return (\n <>\n {isHovering.map((_, i) => (\n <span\n onMouseEnter={() => handleMouseEnter(i)}\n onMouseLeave={() => handleMouseLeave(i)}\n ></span>\n ))}\n {isHovering.map((v, i) => (\n <p>\n Hovering on {i}: {v.toString()}\n </p>\n ))}\n </>\n );\n}\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17133024/"
] |
74,483,363
|
<p>I'm working on snowflake procedure in snowsql and want to use variable as value in insert statement - something like that:</p>
<pre><code>execute immediate $$
declare
select_statement string;
begin
select_statement := '''Some text''';
INSERT INTO SOME_TABLE(MESSAGE) values (select_statement);
exception
when statement_error then
return object_construct('Error type', 'STATEMENT_ERROR',
'SQLCODE', sqlcode,
'SQLERRM', sqlerrm,
'SQLSTATE', sqlstate);
when other then
return object_construct('Error type', 'Other error',
'SQLCODE', sqlcode,
'SQLERRM', sqlerrm,
'SQLSTATE', sqlstate);
end;
$$
;
{
"Error type": "STATEMENT_ERROR",
"SQLCODE": 904,
"SQLERRM": "SQL compilation error: error line 1 at position 102\ninvalid identifier 'SELECT_STATEMENT'",
"SQLSTATE": "42000"
}
</code></pre>
<p>I was trying to use single quote as well</p>
<pre><code>select_statement := 'Some text';
</code></pre>
<p>and also without declaring it and using let</p>
<pre><code>let select_statement := 'Some text';
</code></pre>
<p>Each time getting the same error...</p>
|
[
{
"answer_id": 74483576,
"author": "Greg Pavlik",
"author_id": 12756381,
"author_profile": "https://Stackoverflow.com/users/12756381",
"pm_score": 1,
"selected": true,
"text": "create or replace table some_table(message string);\n\nexecute immediate $$\ndeclare\n rs resultset;\n select_statement string;\n ins string default 'INSERT INTO SOME_TABLE(MESSAGE) values (?)';\nbegin\n select_statement := 'Some text';\n rs := (execute immediate :ins using (select_statement));\n return table(rs);\n exception\n when statement_error then\n return object_construct('Error type', 'STATEMENT_ERROR',\n 'SQLCODE', sqlcode,\n 'SQLERRM', sqlerrm,\n 'SQLSTATE', sqlstate);\n when other then\n return object_construct('Error type', 'Other error',\n 'SQLCODE', sqlcode,\n 'SQLERRM', sqlerrm,\n 'SQLSTATE', sqlstate);\nend;\n$$\n;\n"
},
{
"answer_id": 74483691,
"author": "Himanshu Kandpal",
"author_id": 11227919,
"author_profile": "https://Stackoverflow.com/users/11227919",
"pm_score": 1,
"selected": false,
"text": "create or replace table SOME_TABLE(MESSAGE varchar2 );\nselect * from SOME_TABLE;\nexecute immediate $$\ndeclare\n select_statement string;\nbegin\n select_statement := '''Some text''';\n INSERT INTO SOME_TABLE(MESSAGE) values (:select_statement); \n exception\n when statement_error then\n return object_construct('Error type', 'STATEMENT_ERROR',\n 'SQLCODE', sqlcode,\n 'SQLERRM', sqlerrm,\n 'SQLSTATE', sqlstate);\n when other then\n return object_construct('Error type', 'Other error',\n 'SQLCODE', sqlcode,\n 'SQLERRM', sqlerrm,\n 'SQLSTATE', sqlstate); \nend;\n$$;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1287851/"
] |
74,483,368
|
<p>I have a flex container with two children of different height.</p>
<p>The left item is shorter which I'm trying to make stick to the bottom while scrolling until the full container has been scrolled so they both align. Can't seem to get this to work. No parent overflows affecting this.</p>
<p>The desired behaviour is for the viewer(left) element to align at the top, scroll until it reaches the bottom, stick there until the full container (and side rail) has scrolled</p>
<p>Sandbox <a href="https://codesandbox.io/s/suspicious-mopsa-ptokkf?file=/src/styles.scss" rel="nofollow noreferrer">Here</a></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>.wrapper {
padding: 2rem;
background: lightgrey;
}
.container {
margin-inline: max(0px, ((100% - 1440px) / 2));
display: flex;
height: 2220px;
gap: 1rem;
> * {
border: 1px solid;
}
}
.viewer {
height: 1400px;
flex-grow: 3;
position: -webkit-sticky;
position: sticky;
bottom: 0;
background: white;
}
.side-rail {
height: 2190px;
flex-grow: 1;
background: white;
}
html,
body {
margin: 0;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="wrapper">
<div class="container">
<div class="viewer">Viewer</div>
<div class="side-rail">Side rail</div>
</div>
</div></code></pre>
</div>
</div>
</p>
|
[
{
"answer_id": 74483576,
"author": "Greg Pavlik",
"author_id": 12756381,
"author_profile": "https://Stackoverflow.com/users/12756381",
"pm_score": 1,
"selected": true,
"text": "create or replace table some_table(message string);\n\nexecute immediate $$\ndeclare\n rs resultset;\n select_statement string;\n ins string default 'INSERT INTO SOME_TABLE(MESSAGE) values (?)';\nbegin\n select_statement := 'Some text';\n rs := (execute immediate :ins using (select_statement));\n return table(rs);\n exception\n when statement_error then\n return object_construct('Error type', 'STATEMENT_ERROR',\n 'SQLCODE', sqlcode,\n 'SQLERRM', sqlerrm,\n 'SQLSTATE', sqlstate);\n when other then\n return object_construct('Error type', 'Other error',\n 'SQLCODE', sqlcode,\n 'SQLERRM', sqlerrm,\n 'SQLSTATE', sqlstate);\nend;\n$$\n;\n"
},
{
"answer_id": 74483691,
"author": "Himanshu Kandpal",
"author_id": 11227919,
"author_profile": "https://Stackoverflow.com/users/11227919",
"pm_score": 1,
"selected": false,
"text": "create or replace table SOME_TABLE(MESSAGE varchar2 );\nselect * from SOME_TABLE;\nexecute immediate $$\ndeclare\n select_statement string;\nbegin\n select_statement := '''Some text''';\n INSERT INTO SOME_TABLE(MESSAGE) values (:select_statement); \n exception\n when statement_error then\n return object_construct('Error type', 'STATEMENT_ERROR',\n 'SQLCODE', sqlcode,\n 'SQLERRM', sqlerrm,\n 'SQLSTATE', sqlstate);\n when other then\n return object_construct('Error type', 'Other error',\n 'SQLCODE', sqlcode,\n 'SQLERRM', sqlerrm,\n 'SQLSTATE', sqlstate); \nend;\n$$;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4718994/"
] |
74,483,371
|
<p><a href="https://i.stack.imgur.com/uY9x1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uY9x1.png" alt="enter image description here" /></a></p>
<p>I want to split these ascii characters into 4 columns so it will look more convenient.. Uploaded a picture as an example..</p>
<pre><code>for i in range(1,121):
a = chr(i)
print(str(i)+". "+str(a))
</code></pre>
<p>I have tried the .format or split(), but they don't seem to work as intended</p>
|
[
{
"answer_id": 74483475,
"author": "fishcakes",
"author_id": 3408016,
"author_profile": "https://Stackoverflow.com/users/3408016",
"pm_score": 0,
"selected": false,
"text": "\"\\n\""
},
{
"answer_id": 74483546,
"author": "Pranav Hosangadi",
"author_id": 843953,
"author_profile": "https://Stackoverflow.com/users/843953",
"pm_score": 2,
"selected": false,
"text": "print"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17357965/"
] |
74,483,375
|
<p>i have an 4 characters array = ["0222"]
Need to split in 2 groups of 2 each</p>
<p>Need to get array = ["02","22"]
Try split, but can´t get the result i need.</p>
|
[
{
"answer_id": 74483409,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 2,
"selected": false,
"text": "\\d{1,2}"
},
{
"answer_id": 74577743,
"author": "Michael B",
"author_id": 16452228,
"author_profile": "https://Stackoverflow.com/users/16452228",
"pm_score": 1,
"selected": true,
"text": "String#[]"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20503090/"
] |
74,483,407
|
<p>I created a recursive solution to the issue but the biggest bug is that it doesn't recognize that a small palindrome sandwiched with other characters all in between two identical characters isn't necessarily a palindrome</p>
<pre><code>
public static int palindrome(String str)
{
str = str.toLowerCase();
if (str.length() == 0)
return 0;
if (str.length() == 1)
return 1;
if (str.charAt(0) == str.charAt(str.length() - 1))
{
int pal = palindrome(str.substring(1, str.length() - 1));
if (pal != 1 || str.length() <= 3)
return 2 + pal;
}
return Math.max(palindrome(str.substring(0, str.length() - 1)), palindrome(str.substring(1)));
}
</code></pre>
|
[
{
"answer_id": 74484128,
"author": "Jacob Malland",
"author_id": 17160379,
"author_profile": "https://Stackoverflow.com/users/17160379",
"pm_score": 0,
"selected": false,
"text": "public static int recursiveLength(String s) {\n if (isPalindrome(s)) {\n return(s.length());\n }\n int left = recursiveLength(s.substring(1)); // Cuts the substring from the left\n int right = recursiveLength(s.substring(0, s.length()-1)); // Cuts the substring from the right\n int max = Math.max(left, right); // Calculates which was the longest substring\n return(max);\n}\n"
},
{
"answer_id": 74484834,
"author": "Joop Eggen",
"author_id": 984823,
"author_profile": "https://Stackoverflow.com/users/984823",
"pm_score": 1,
"selected": false,
"text": "if (pal == str.length() - 2)\n return str.length();\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534836/"
] |
74,483,427
|
<p>In Chromium-based browsers version 107 I notice opening a new tab with window.open does not give focus to the new tab. Previous it did, and in Firefox it still does</p>
<pre><code>//code before
{
let url = "https://google.com";
window.open(url,"_blank");
}
</code></pre>
<p>When I run the window open in the console it does give the tab focus.
Also giving a <code>return true</code> or adding <code>event.preventDefault()</code> or <code>event.stopImmediatePropagation()</code> before doe not work.</p>
<p>However, if I move the test code to the top of the code block, it does work.</p>
<p>Is Anyone aware of a change in Chromium, or a constraint that will open the new page in the background?</p>
|
[
{
"answer_id": 74484128,
"author": "Jacob Malland",
"author_id": 17160379,
"author_profile": "https://Stackoverflow.com/users/17160379",
"pm_score": 0,
"selected": false,
"text": "public static int recursiveLength(String s) {\n if (isPalindrome(s)) {\n return(s.length());\n }\n int left = recursiveLength(s.substring(1)); // Cuts the substring from the left\n int right = recursiveLength(s.substring(0, s.length()-1)); // Cuts the substring from the right\n int max = Math.max(left, right); // Calculates which was the longest substring\n return(max);\n}\n"
},
{
"answer_id": 74484834,
"author": "Joop Eggen",
"author_id": 984823,
"author_profile": "https://Stackoverflow.com/users/984823",
"pm_score": 1,
"selected": false,
"text": "if (pal == str.length() - 2)\n return str.length();\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/562999/"
] |
74,483,431
|
<p>I was wondering how I could possibly convert this holy nest of if and && checks, into a simple for-loop?
Any solutions are appreciated, since I'm completely lost and my brain has given up.</p>
<pre class="lang-cs prettyprint-override"><code>if (localModulebytes[i + 1] == convertedByteArray[1]
&& localModulebytes[i + 2] == convertedByteArray[2]
&& localModulebytes[i + 3] == convertedByteArray[3]
&& localModulebytes[i + 4] == convertedByteArray[4]
&& localModulebytes[i + 5] == convertedByteArray[5]
&& localModulebytes[i + 6] == convertedByteArray[6]
&& localModulebytes[i + 7] == convertedByteArray[7]
&& localModulebytes[i + 8] == convertedByteArray[8]
&& localModulebytes[i + 9] == convertedByteArray[9]
)
{
// Code
similarities++;
}
</code></pre>
<p>I tried this code, which gave similaries that were way beyond the ones from my bee-nest to code:</p>
<pre class="lang-cs prettyprint-override"><code>for (var j = 1; j < 9; j++)
{
if (localModulebytes[i + j] == convertedByteArray[j])
{
similarities++;
}
}
</code></pre>
|
[
{
"answer_id": 74483474,
"author": "GreenChicken",
"author_id": 12094709,
"author_profile": "https://Stackoverflow.com/users/12094709",
"pm_score": 3,
"selected": true,
"text": "var sim = true;\nfor (var j = 1; j < 9; j++) {\n if (localModulebytes[i + j] != convertedByteArray[j]) {\n sim = false;\n break;\n }\n}\nif(sim) similarities++;\n"
},
{
"answer_id": 74483497,
"author": "Rup",
"author_id": 243245,
"author_profile": "https://Stackoverflow.com/users/243245",
"pm_score": 0,
"selected": false,
"text": "if (Enumerable.Range(1,9).All(j => localModulebytes[i + j] == convertedByteArray[j])) {\n ++similarities;\n}\n"
},
{
"answer_id": 74483509,
"author": "Milan Egon Votrubec",
"author_id": 8051819,
"author_profile": "https://Stackoverflow.com/users/8051819",
"pm_score": 0,
"selected": false,
"text": "var similar = true;\nfor ( var j = 1; j < 10; j++ )\n if ( localModulebytes[i + j] != convertedByteArray[j] )\n {\n similar = false;\n break;\n }\nif (similar) similarities++;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534862/"
] |
74,483,432
|
<h3>Problem</h3>
<p>Given the following Makefile:</p>
<pre><code>.PHONY: blah blah1 blah2
blah:
@$(MAKE) -j --no-print-directory blah1 blah2
blah1:
@echo "hello"
@caddy run
blah2:
@echo "goodbye"
@esbuild --watch
</code></pre>
<p>Running <code>make blah</code> returns the following:</p>
<pre><code>❯ make blah
hello
Caddy listening on :3000
goodbye
esbuild building...
esbuild complete in 4ms
</code></pre>
<p><em><strong>How can I prefix the name of the target before any output (<code>stdout</code> or <code>stderr</code>) from that target?</strong></em></p>
<p>I'm looking to get this:</p>
<pre><code>❯ make blah
[blah1] hello
[blah1] Caddy listening on :3000
[blah2] goodbye
[blah2] esbuild building...
[blah2] esbuild complete in 4ms
</code></pre>
<h3>Version</h3>
<p>GNU Make v4.4</p>
<h3>Other solutions I've tried</h3>
<p>I can hack this together by manually appending the output through <code>sed</code> on each line inside the target definition:</p>
<pre><code>.PHONY: blah blah1 blah2
blah:
@$(MAKE) -j --no-print-directory blah1 blah2
blah1:
@echo "hello" | sed 's|^\(.*\)$$|[blah1] \1|'
@caddy run 2>&1 | sed 's|^\(.*\)$$|[blah1] \1|'
blah2:
@echo "goodbye" | sed 's|^\(.*\)$$|[blah2] \1|'
@esbuild --watch 2>&1 | sed 's|^\(.*\)$$|[blah2] \1|'
</code></pre>
<p>... but this solution gets very tedious very fast for non-contrived Makefiles.</p>
|
[
{
"answer_id": 74483474,
"author": "GreenChicken",
"author_id": 12094709,
"author_profile": "https://Stackoverflow.com/users/12094709",
"pm_score": 3,
"selected": true,
"text": "var sim = true;\nfor (var j = 1; j < 9; j++) {\n if (localModulebytes[i + j] != convertedByteArray[j]) {\n sim = false;\n break;\n }\n}\nif(sim) similarities++;\n"
},
{
"answer_id": 74483497,
"author": "Rup",
"author_id": 243245,
"author_profile": "https://Stackoverflow.com/users/243245",
"pm_score": 0,
"selected": false,
"text": "if (Enumerable.Range(1,9).All(j => localModulebytes[i + j] == convertedByteArray[j])) {\n ++similarities;\n}\n"
},
{
"answer_id": 74483509,
"author": "Milan Egon Votrubec",
"author_id": 8051819,
"author_profile": "https://Stackoverflow.com/users/8051819",
"pm_score": 0,
"selected": false,
"text": "var similar = true;\nfor ( var j = 1; j < 10; j++ )\n if ( localModulebytes[i + j] != convertedByteArray[j] )\n {\n similar = false;\n break;\n }\nif (similar) similarities++;\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32154/"
] |
74,483,446
|
<p>I'm in my first semester in coding and completely stuck on this one.</p>
<p>I want to get all forms of a word (ex: HeLLo, hEllO, heLlo, ...) to change to lowercase and don't know how to get there without writing a condition for every single variation in my file. I have many words I have to convert to either lowercase or uppercase so I realized that there must be a better way of doing but can't figure out which.</p>
<p>Is there a way to get all of these variations at once and convert them to lowercase?</p>
<p>Input = " HeLlo this is my program called HELLO "</p>
<p>Output = " hello this is my program called hello "</p>
<p>I've only tried:</p>
<p>word.replace("HELLO", "hello");</p>
<p>word.replace("Hello", "hello");
and so on..</p>
|
[
{
"answer_id": 74483456,
"author": "CharlieBONS",
"author_id": 20529340,
"author_profile": "https://Stackoverflow.com/users/20529340",
"pm_score": 2,
"selected": false,
"text": "word.toLowerCase()\n"
},
{
"answer_id": 74483587,
"author": "CharlieBONS",
"author_id": 20529340,
"author_profile": "https://Stackoverflow.com/users/20529340",
"pm_score": 1,
"selected": false,
"text": "String text = \"Hello I am No GoodBYE\";\n String[] lowercase = {\"hello\", \"goodbye\"};\n String[] uppercase = {\"no\", \"yes\"};\n String[] split_string = text.split(\" \");\n for (int i=0;i < split_string.length;i++){\n for (String low:lowercase){\n if (split_string[i].toLowerCase().equals(low)){\n split_string[i] = split_string[i].toLowerCase();\n }\n\n }\n for (String upper:uppercase){\n if (split_string[i].toLowerCase().equals(upper)){\n split_string[i] = split_string[i].toUpperCase();\n }\n }\n }\n String final_result = \"\";\n for(String word:split_string){\n final_result = final_result + \" \" + word;\n }\n System.out.println(final_result);\n\n\n"
},
{
"answer_id": 74483648,
"author": "human bean",
"author_id": 17186475,
"author_profile": "https://Stackoverflow.com/users/17186475",
"pm_score": 4,
"selected": true,
"text": "word = word.replaceAll(\"(?i)hello\", \"hello\");\n"
},
{
"answer_id": 74483695,
"author": "mrak",
"author_id": 1494048,
"author_profile": "https://Stackoverflow.com/users/1494048",
"pm_score": 2,
"selected": false,
"text": "Pattern pattern = Pattern.compile(Pattern.quote(\"hallo\"), Pattern.CASE_INSENSITIVE);\nString test = \"Hallo FoO HallO BaR HaLLo BAz\"; \nString replaced = pattern.matcher(test).replaceAll(\"hallo\");\n// Output: hallo FoO hallo BaR hallo BAz\n"
},
{
"answer_id": 74483736,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 0,
"selected": false,
"text": "HeLlo There heLLO WorlD"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534815/"
] |
74,483,451
|
<p>I have a social media app written in Flutter. Users can see the profiles each other and block/unblock them. I'm using MySQL to keep that data. Now I want to implement chat feature using Firebase Firestore (or maybe MongoDB). When a user sends a message to another user, should I check if user blocked another user from MySQL every time, so user can't send new message. Is this a good practice in chat application, or should I store the "blocked" data at Firebase also.</p>
<p>I researched this subject deeply but didn't find any solution.</p>
|
[
{
"answer_id": 74483456,
"author": "CharlieBONS",
"author_id": 20529340,
"author_profile": "https://Stackoverflow.com/users/20529340",
"pm_score": 2,
"selected": false,
"text": "word.toLowerCase()\n"
},
{
"answer_id": 74483587,
"author": "CharlieBONS",
"author_id": 20529340,
"author_profile": "https://Stackoverflow.com/users/20529340",
"pm_score": 1,
"selected": false,
"text": "String text = \"Hello I am No GoodBYE\";\n String[] lowercase = {\"hello\", \"goodbye\"};\n String[] uppercase = {\"no\", \"yes\"};\n String[] split_string = text.split(\" \");\n for (int i=0;i < split_string.length;i++){\n for (String low:lowercase){\n if (split_string[i].toLowerCase().equals(low)){\n split_string[i] = split_string[i].toLowerCase();\n }\n\n }\n for (String upper:uppercase){\n if (split_string[i].toLowerCase().equals(upper)){\n split_string[i] = split_string[i].toUpperCase();\n }\n }\n }\n String final_result = \"\";\n for(String word:split_string){\n final_result = final_result + \" \" + word;\n }\n System.out.println(final_result);\n\n\n"
},
{
"answer_id": 74483648,
"author": "human bean",
"author_id": 17186475,
"author_profile": "https://Stackoverflow.com/users/17186475",
"pm_score": 4,
"selected": true,
"text": "word = word.replaceAll(\"(?i)hello\", \"hello\");\n"
},
{
"answer_id": 74483695,
"author": "mrak",
"author_id": 1494048,
"author_profile": "https://Stackoverflow.com/users/1494048",
"pm_score": 2,
"selected": false,
"text": "Pattern pattern = Pattern.compile(Pattern.quote(\"hallo\"), Pattern.CASE_INSENSITIVE);\nString test = \"Hallo FoO HallO BaR HaLLo BAz\"; \nString replaced = pattern.matcher(test).replaceAll(\"hallo\");\n// Output: hallo FoO hallo BaR hallo BAz\n"
},
{
"answer_id": 74483736,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 0,
"selected": false,
"text": "HeLlo There heLLO WorlD"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13545110/"
] |
74,483,455
|
<p>I wonder if it is possible to create a loop to remove strings in dataframe column. I have multiple dataframes which look like the structure below.</p>
<pre><code>df = pd.DataFrame({
'xyz CODE': [1,2,3,3,4, 5,6,7,7,8],
'a': [4, 5, 3, 1, 2, 20, 10, 40, 50, 30],
'b': [20, 10, 40, 50, 30, 4, 5, 3, 1, 2],
'c': [25, 20, 5, 15, 10, 25, 20, 5, 15, 10] })
</code></pre>
<p>For each dataframe I want to remove string 'CODE' in the first column. I wrote the following</p>
<pre><code>if __name__ == '__main__':
path = os.getcwd()
csv_files = glob.glob(os.path.join(path, "*.xlsx"))
dataframes_list = []
for file in csv_files:
dataframes_list.append(pd.read_excel(file))
for i in dataframes_list:
i.columns[0] = i.columns[0].replace('CODE', '')
print(i.columns[0])
i = dosomethingtoeachdf(i)
i.to_excel(f'{i.columns[0]}' + '.xlsx')
</code></pre>
<p>I ran into an error <code>TypeError: Index does not support mutable operations</code>. I know I'm missing some basics here, appreciate any help!</p>
|
[
{
"answer_id": 74483481,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 2,
"selected": true,
"text": "DataFrame.rename"
},
{
"answer_id": 74483494,
"author": "michotross ",
"author_id": 7897042,
"author_profile": "https://Stackoverflow.com/users/7897042",
"pm_score": 0,
"selected": false,
"text": "df.columns = [column.replace(' CODE', '') if index == 0 else column for index, column in enumerate(df.columns)]\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6722067/"
] |
74,483,461
|
<p>Hi I have two dataframe like this:</p>
<p>df_1:</p>
<pre><code>id item activity
1 2 a
34 14 b
1 2 b
. . .
</code></pre>
<p>Activity has two uniqe values <code>a and b</code>.</p>
<p>df_2:</p>
<pre><code>id item activity
1 2 c
34 14 c
1 2 c
</code></pre>
<p>Here activity has all same values <code>c</code></p>
<p>Now I want final df where I have to groupby using <code>id and item</code> and get count of unique activities from <code>df_1 and df_2</code> and later join them using <code>id and item</code>.</p>
<p>df_1_grp (Groupby using <code>id and item</code> and get count of activity frequency record):</p>
<pre><code>df_1_grp = df_1.groupby("id", "item").agg(f.count(f.when(f.col('activity') == 'a', 1)).alias('a'), f.count(f.when(f.col('activity_type') == 'b', 1)).alias('b'))
</code></pre>
<pre><code>id item a b
1 2 1 1
34 14 0 1
</code></pre>
<p>df_2_grp (Groupby using <code>id and item</code> and just get the count of record as all values in activity is same):</p>
<pre><code>df_2_grp = df_2.groupBy("id", "item").count().select('id', 'item', f.col('count').alias('c'))
</code></pre>
<pre><code>id item c
1 2 2
34 14 1
</code></pre>
<p>And now join them to get final df:</p>
<pre><code>df = df_1_grp.join(df_2_grp, on = ['id', 'item'], how = 'inner')
</code></pre>
<p>Expected Output:</p>
<pre><code>id item a b c
1 2 1 1 2
34 14 0 1 1
</code></pre>
<p>Now because my dataframe is too big like probably <code>4 TB or 1 Billion records</code>. I'm running out of disc storage. Is there more optimized and effecient way of doing it.</p>
<p>Spark Config:</p>
<pre><code>spark_config["spark.executor.memory"] = "32G"
spark_config["spark.executor.memoryOverhead"] = "32G"
spark_config["spark.executor.cores"] = "32"
spark_config["spark.driver.memory"] = "8G"
spark_config["spark.dynamicAllocation.minExecutors"] = "200"
spark_config["spark.dynamicAllocation.maxExecutors"] = "300"
</code></pre>
|
[
{
"answer_id": 74483481,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 2,
"selected": true,
"text": "DataFrame.rename"
},
{
"answer_id": 74483494,
"author": "michotross ",
"author_id": 7897042,
"author_profile": "https://Stackoverflow.com/users/7897042",
"pm_score": 0,
"selected": false,
"text": "df.columns = [column.replace(' CODE', '') if index == 0 else column for index, column in enumerate(df.columns)]\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10994166/"
] |
74,483,465
|
<p>Im trying to do something for a school project and have the code ask the users for some numbers then print the smallest from the bunch.The main issue with this is that i have to put a string with the print so that the grading system gives a 100.Im not sure on how to do that with my knowledge.Here is my code-</p>
<pre><code>num1=int(input("Enter a number: "))
num2=int(input("Enter a number: "))
num3=int(input("Enter a number: "))
print(min("Smallest:", num1 , num2 , num3))
</code></pre>
<p>and the error message-</p>
<pre><code>Traceback (most recent call last):
File "<string>", line 4, in <module>
TypeError: '<' not supported between instances of 'int' and 'str'
</code></pre>
<p>I have tried making the variables strings like such-</p>
<pre><code>num1=int(input("Enter a number: "))
num2=int(input("Enter a number: "))
num3=int(input("Enter a number: "))
print(min("Smallest:", str(num1 , num2 , num3)))
</code></pre>
<p>and even just having the str() command with each variable but it doesn't like my attempt to fix it.</p>
|
[
{
"answer_id": 74483472,
"author": "Ricardo",
"author_id": 16353662,
"author_profile": "https://Stackoverflow.com/users/16353662",
"pm_score": -1,
"selected": false,
"text": "num1=int(input(\"Enter a number: \"))\nnum2=int(input(\"Enter a number: \"))\nnum3=int(input(\"Enter a number: \"))\nprint(\"Smallest: \" + str(min(num1 , num2 , num3)))\n"
},
{
"answer_id": 74483505,
"author": "Luis Cedillo Maldonado",
"author_id": 16484026,
"author_profile": "https://Stackoverflow.com/users/16484026",
"pm_score": 1,
"selected": false,
"text": "\"Smallest\""
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20441979/"
] |
74,483,499
|
<p>I am trying to write a higher-order function that takes a varying amount of arguments.
For instance something like this</p>
<pre><code>def higher(fnc, args):
print(f"Calling function {fnc}")
fnc(argv)
def one_arg(only_arg):
print(f"Here is the only arg {only}")
def two_arg(first, second):
print(f"Here is the first {first} And here is the second {second}")
higher(one_arg, "Only one argument")
higher(two_arg, "Here's one arg", "and Another one")
</code></pre>
<p>Is it possible to do this without changing the functions one_arg() or two_arg() ?</p>
<p>I've looked into using *<strong>argv</strong> but I don't think I understand it well enough or see a way to use that without changing those two functions</p>
|
[
{
"answer_id": 74483521,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "higher"
},
{
"answer_id": 74483522,
"author": "Anurag Reddy",
"author_id": 9530965,
"author_profile": "https://Stackoverflow.com/users/9530965",
"pm_score": 1,
"selected": false,
"text": "def higher(fnc, *args):\n print(f\"Calling function {fnc}\")\n fnc(*args)\n\ndef one_arg(only_arg):\n print(f\"Here is the only arg {only_arg}\")\n\ndef two_arg(first, second):\n print(f\"Here is the first {first} And here is the second {second}\")\n\nhigher(one_arg, \"Only one argument\")\nhigher(two_arg, \"Here's one arg\", \"and Another one\")\n"
}
] |
2022/11/17
|
[
"https://Stackoverflow.com/questions/74483499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12006803/"
] |
74,483,534
|
<p>how can i display a prop in filteredProducts when fetching data using axios. i have passed through a prop like below.</p>
<pre><code>export default {
data() {
return {
filteredProducts: [],
};
},
mounted() {
axios
.get('/src/stores/sneakers.json')
.then(response => { const products = response.data
this.filteredProducts = products.filter(product => product.name.includes('Nike'))
})
},
computed: {
resultCount () {
return Object.keys(this.filteredProducts).length
},
},
props: {
brand: {
type: Object,
},
},
</code></pre>
<p>I would like to replace 'Nike' with brand.name as that is being passed through. Much appreciated</p>
|
[
{
"answer_id": 74483521,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "higher"
},
{
"answer_id": 74483522,
"author": "Anurag Reddy",
"author_id": 9530965,
"author_profile": "https://Stackoverflow.com/users/9530965",
"pm_score": 1,
"selected": false,
"text": "def higher(fnc, *args):\n print(f\"Calling function {fnc}\")\n fnc(*args)\n\ndef one_arg(only_arg):\n print(f\"Here is the only arg {only_arg}\")\n\ndef two_arg(first, second):\n print(f\"Here is the first {first} And here is the second {second}\")\n\nhigher(one_arg, \"Only one argument\")\nhigher(two_arg, \"Here's one arg\", \"and Another one\")\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19892063/"
] |
74,483,555
|
<p>I have a 2D array and I am trying to fit a curve on the data. my objective function is a polynomial function:</p>
<pre><code>def objective(x, a, b, c):
return a * x + b * x**2 + c
</code></pre>
<p>I used <code>curve_fit</code> from <code>scipy.optimize</code> to find the suitable curve for the data. But, I need to know how much this model is good. what is the difference between actual data and estimated curve?
how can I find this? dose <code>curve_fit</code> use mean square error to find the curve? how can I control this difference?</p>
|
[
{
"answer_id": 74483521,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "higher"
},
{
"answer_id": 74483522,
"author": "Anurag Reddy",
"author_id": 9530965,
"author_profile": "https://Stackoverflow.com/users/9530965",
"pm_score": 1,
"selected": false,
"text": "def higher(fnc, *args):\n print(f\"Calling function {fnc}\")\n fnc(*args)\n\ndef one_arg(only_arg):\n print(f\"Here is the only arg {only_arg}\")\n\ndef two_arg(first, second):\n print(f\"Here is the first {first} And here is the second {second}\")\n\nhigher(one_arg, \"Only one argument\")\nhigher(two_arg, \"Here's one arg\", \"and Another one\")\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11013499/"
] |
74,483,572
|
<p>If i have an array like this</p>
<pre><code>a = np.array([[False, False, False, False, False, False, False, False, False, False],[False, False, False, False, False, False, False, False, False, False],[False, False, False, True, True, False, False, False, False, False],
</code></pre>
<p>I tried np.random.choice but it doesnt work for 1_D arrays :(</p>
|
[
{
"answer_id": 74483521,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "higher"
},
{
"answer_id": 74483522,
"author": "Anurag Reddy",
"author_id": 9530965,
"author_profile": "https://Stackoverflow.com/users/9530965",
"pm_score": 1,
"selected": false,
"text": "def higher(fnc, *args):\n print(f\"Calling function {fnc}\")\n fnc(*args)\n\ndef one_arg(only_arg):\n print(f\"Here is the only arg {only_arg}\")\n\ndef two_arg(first, second):\n print(f\"Here is the first {first} And here is the second {second}\")\n\nhigher(one_arg, \"Only one argument\")\nhigher(two_arg, \"Here's one arg\", \"and Another one\")\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,483,603
|
<p>Write a function that takes two lists of numbers, numerators and denominators, and returns a list of fractions produced by dividing numerators by denominators. If one list is shorter than the other, assume that the corresponding numbers are all 1s. Don't worry about zeros in the denominators (it's ok if your function breaks when dividing by zero).</p>
<p>Input: (list 1 2 3) (list 1 3 5)</p>
<p>Output: (list 1/1 2/3 3/5)</p>
|
[
{
"answer_id": 74483521,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "higher"
},
{
"answer_id": 74483522,
"author": "Anurag Reddy",
"author_id": 9530965,
"author_profile": "https://Stackoverflow.com/users/9530965",
"pm_score": 1,
"selected": false,
"text": "def higher(fnc, *args):\n print(f\"Calling function {fnc}\")\n fnc(*args)\n\ndef one_arg(only_arg):\n print(f\"Here is the only arg {only_arg}\")\n\ndef two_arg(first, second):\n print(f\"Here is the first {first} And here is the second {second}\")\n\nhigher(one_arg, \"Only one argument\")\nhigher(two_arg, \"Here's one arg\", \"and Another one\")\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20170877/"
] |
74,483,615
|
<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>@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500;700&family=Fraunces:opsz,wght@9..144,700&family=Rye&family=Seymour+One&family=Ultra&display=swap');
* {
box-sizing: border-box;
}
body {
background-color: black;
}
.parent {
display: flex;
flex-direction: column;
max-width: 600px;
font-family: "Montserrat";
border-radius: 10px;
margin: 20px;
background-color: white;
}
picture {
display: block;
}
img {
width: 100%;
height: 100%;
}
.main-content {
padding: 1rem;
}
.cologne {
text-transform: uppercase;
letter-spacing: 0.5rem;
color: #8f8f8f;
}
h1 {
font-family: "Fraunces";
overflow-wrap: break-word;
color: #343434;
}
.description {
color: #8f8f8f;
overflow-wrap: break-word;
}
.price {
display: flex;
gap: 1rem;
align-items: center;
overflow-wrap: break-word;
}
.price p:nth-child(1) {
font-size: 2rem;
font-family: "Fraunces";
color: #343434;
}
.price p:nth-child(2) {
text-decoration: line-through;
}
.cart {
width: 100%;
padding: 0.5rem 0;
font-family: inherit;
color: #343434;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><main>
<div class="parent">
<picture>
<source media="(max-width:700px)" srcset="https://images.unsplash.com/photo-1592921248991-dd940d2977e9?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2Njg3MjQzMjg&ixlib=rb-4.0.3&q=80" />
<img src="https://images.unsplash.com/photo-1514569369508-d2a48d3a423c?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2Njg3MjQ3NTM&ixlib=rb-4.0.3&q=80" alt="perfume" />
</picture>
<div class="main-content">
<span class="cologne">Lorem Ipsum</span>
<h1>Lorem Ipsum Dolor Sit Amet</h1>
<div class="description">
Donec sit amet sapien elit. Etiam et pellentesque justo, id posuere justo. Donec urna neque, lobortis hendrerit ornare vel, laoreet vitae urna.</div>
<div class="price">
<p>$149.99</p>
<p>$169.99</p>
</div>
<button class="cart" href="#">Add to Cart</button>
</div>
</div>
</main></code></pre>
</div>
</div>
</p>
<p>I created this product-preview card and I set the border-radius on the parent class, however, it is not showing at the top, I do not want this, is there a way to fix this, I suspect that the problem is with the image and that it is blocking the radius from showing in some way but I am not exactly sure.</p>
|
[
{
"answer_id": 74483521,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 0,
"selected": false,
"text": "higher"
},
{
"answer_id": 74483522,
"author": "Anurag Reddy",
"author_id": 9530965,
"author_profile": "https://Stackoverflow.com/users/9530965",
"pm_score": 1,
"selected": false,
"text": "def higher(fnc, *args):\n print(f\"Calling function {fnc}\")\n fnc(*args)\n\ndef one_arg(only_arg):\n print(f\"Here is the only arg {only_arg}\")\n\ndef two_arg(first, second):\n print(f\"Here is the first {first} And here is the second {second}\")\n\nhigher(one_arg, \"Only one argument\")\nhigher(two_arg, \"Here's one arg\", \"and Another one\")\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18835651/"
] |
74,483,618
|
<p>I just started using tmux along with slime, PyShell and IPython and I have ran into the following problem.</p>
<p>I am trying to run the following code:</p>
<pre><code>names = ['a', 'b', 'c']
nc = { name : 0 for name in names}
count = 1
for name in names:
nc[name] += count
count += 1
print(nc)
</code></pre>
<p>and when I normally run the file in terminal using <code>python3 file.py</code>, it correctly returns <code>{'a': 1, 'b': 2, 'c': 3}</code>.</p>
<p>However, when running this with slime, it is saying that there is an unexpected indent and the error message is showing that the following is being inputted:</p>
<pre><code>names = ['a', 'b', 'c']
nc = { name : 0 for name in names}
count = 1
for name in names:
nc[name] += count
count += 1
print
</code></pre>
<p>However, this is not what I am inputting. Here is a <a href="https://i.stack.imgur.com/9RsTK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9RsTK.png" alt="screen shot" /></a> to show this. Where is the problem coming from?</p>
|
[
{
"answer_id": 74483686,
"author": "cafce25",
"author_id": 442760,
"author_profile": "https://Stackoverflow.com/users/442760",
"pm_score": 0,
"selected": false,
"text": "for name in names:\n....;;;;count += 1\n........;;;;nc[name] += count\n"
},
{
"answer_id": 74484442,
"author": "Nathan Mills",
"author_id": 8890345,
"author_profile": "https://Stackoverflow.com/users/8890345",
"pm_score": 2,
"selected": true,
"text": "%autoindent"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7086465/"
] |
74,483,651
|
<p>I'm beginner of pandas so I have a question below.
There's a lot of answers about groupby rows
but I can't find the answer what I want.</p>
<p>anyway my datatable is below.</p>
<pre><code> COLUMN1 COLUMN2 COLUMN3
0 APPLE RED JOHN, JANE
1 BANANA YELLOW SMITH
1 BANANA YELLOW EMILY
2 GRAPE VIOLET JESSICA
2 GRAPE VIOLET REIRA
2 GRAPE VIOLET EMMA
2 GRAPE PURPLE JOE
2 GRAPE PURPLE LISA
3 MELON GREEN RIO
3 MELON GREEN REIRA
..
</code></pre>
<p>and I want to get this table. (edit : EXCEPT YELLOW)</p>
<pre><code> COLUMN1 COLUMN2 COLUMN3
0 APPLE RED JOHN, JANE
1 BANANA YELLOW SMITH
1 BANANA YELLOW EMILY
2 GRAPE VIOLET JESSICA, REIRA, EMMA
2 GRAPE PURPLE JOE, LISA
3 MELON GREEN RIO, REIRA
..
</code></pre>
<p>How can I get this?
Please give me a hint or answer then I'll appreciate a lot..
thank you.</p>
|
[
{
"answer_id": 74483686,
"author": "cafce25",
"author_id": 442760,
"author_profile": "https://Stackoverflow.com/users/442760",
"pm_score": 0,
"selected": false,
"text": "for name in names:\n....;;;;count += 1\n........;;;;nc[name] += count\n"
},
{
"answer_id": 74484442,
"author": "Nathan Mills",
"author_id": 8890345,
"author_profile": "https://Stackoverflow.com/users/8890345",
"pm_score": 2,
"selected": true,
"text": "%autoindent"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20505690/"
] |
74,483,652
|
<p>description: Python can loop functions in eachother. can cS loop function too?</p>
<p>Example python:</p>
<pre><code>def func():
x=input(">")
func()
</code></pre>
<p>Example c# <em><strong>expected</strong></em>:</p>
<pre><code>namespace f
{class f{
static void main(string[] args){
void stuff() {
Console.readLine()
stuff()
}
}
}}
</code></pre>
<p>i dont think its possible to loop function in the function in cs.</p>
<p>what i mean by looping function is by putting the void inside the container. here is what i mean <em><strong>python</strong></em>:</p>
<pre><code>def g():
x=input(">")
g()
</code></pre>
<p>output (typer):</p>
<pre><code>Python Latest Update
>h
>bruh
>new line
>new new line
>line
>infinite input lines
> repeating function
</code></pre>
<p>i use this because in python i added commands in the script and i do it so i wont need to retype until the python stops the input.</p>
<p>example:</p>
<pre><code>Problem (python script):
def func():
x=input(">")
if x=="help":
print("commands: help")
x=input(">")
if x=="help":
#repeat
Solution (python script):
def func():
x=input(">")
if x=="help":
print("commands: help")
func()
</code></pre>
<p>why i put the examples in python script: idk if you can do this in c# so im not going to confuse anyone</p>
<p>Can this happen in C#?</p>
|
[
{
"answer_id": 74483686,
"author": "cafce25",
"author_id": 442760,
"author_profile": "https://Stackoverflow.com/users/442760",
"pm_score": 0,
"selected": false,
"text": "for name in names:\n....;;;;count += 1\n........;;;;nc[name] += count\n"
},
{
"answer_id": 74484442,
"author": "Nathan Mills",
"author_id": 8890345,
"author_profile": "https://Stackoverflow.com/users/8890345",
"pm_score": 2,
"selected": true,
"text": "%autoindent"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20317966/"
] |
74,483,661
|
<p>At the outset, I realize what I did was bad. I relied on what is now (at least) undefined behavior, if not explicitly forbidden. It used to work, and I thought I was being clever. Now it doesn't and I'm trying to fix it.</p>
<p>I have positive power-of-2 numbers (FFT bin index, but not important). I want to effectively FFT-shift a set of bin indices by wrapping the second half of the values to the negative range. That is, given an FFT size of 512,</p>
<pre><code>0 ... 255 -> 0 ... 255
256 ... 511 -> -256 ... -1
</code></pre>
<p>What used to work was</p>
<pre class="lang-cpp prettyprint-override"><code>template <size_t N>
struct Wrapper {
int val : N;
};
auto constexpr index = 42u;
auto wrapper = Wrapper<9>{ index }; // warning: invalid narrowing conversion from "unsigned int" to "int"
auto val = wrapper.val; // signed value
</code></pre>
<p>This relied on the truncation of overflowed assignment, but was empirically tested and Just Worked(tm).</p>
<p>Now, it doesn't compile (cleanly).</p>
<p>How should I perform this conversion now?</p>
|
[
{
"answer_id": 74483704,
"author": "lorro",
"author_id": 6292621,
"author_profile": "https://Stackoverflow.com/users/6292621",
"pm_score": 3,
"selected": true,
"text": "auto wrapper = Wrapper<9>{ index & (1 << (9 - 1)) ? long(index) - 2 * (1 << (9 - 1)) : index };\n"
},
{
"answer_id": 74496020,
"author": "jwm",
"author_id": 9220132,
"author_profile": "https://Stackoverflow.com/users/9220132",
"pm_score": 0,
"selected": false,
"text": "struct Wrapper {\n int operator()(unsigned bin)\n {\n auto constexpr sign_mask = (1u << (N-1));\n\n auto val = int(bin ^ sign_mask) - sign_mask;\n return val;\n }\n};\n\nBOOST_AUTO_TEST_CASE(test_tf_fft_shift_index)\n{\n auto f = Wrapper<9>();\n auto n255 = f(255u);\n auto n256 = f(256u);\n auto n511 = f(511u);\n\n BOOST_TEST(n255 == 255);\n BOOST_TEST(n256 == -256);\n BOOST_TEST(n511 == -1);\n}\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9220132/"
] |
74,483,670
|
<p>This is my code so far (in PyCharm), I am writing a very simple number guessing game that has integers from 1-9. I am still trying to master thought & flow as well as loops, and I hit a roadblock:</p>
<pre><code>import random
Player_Name = input("What is your name?\n")
print(f"Hello {Player_Name}!\n")
random_num = random.randint(1, 10)
guess = int(input("What is the number you want to pick? Guess one, 1-9\n"))
def number_game():
if guess == random_num:
print(f"You guessed right, the number is confirmed to be {random_num}.")
else:
print(f"You guessed the wrong number. Try again.\n")
number_game()
</code></pre>
<p>I called the function and ran the code... everything appears to be working except I really can't figure out how to keep the game going in a loop until the player gets the right number out of 1-9...and end it when I need to. I tried searching all my resources and am quite stuck on this beginner practice coding. Any help is appreciated.</p>
<p>What I wrote and tried is above... googling and stackoverflow just confused me more.</p>
|
[
{
"answer_id": 74483785,
"author": "Niko",
"author_id": 7100120,
"author_profile": "https://Stackoverflow.com/users/7100120",
"pm_score": 2,
"selected": true,
"text": "import random\n\n\nPlayer_Name = input(\"What is your name?\\n\")\nprint(f\"Hello {Player_Name}!\\n\")\nrandom_num = random.randint(1, 10)\n\n\n\ndef number_game():\n guess = int(input(\"What is the number you want to pick? Guess one, 1-9\\n\"))\n if guess == random_num:\n print(f\"You guessed right, the number is confirmed to be {random_num}.\")\n return True\n else:\n print(f\"You guessed the wrong number. Try again.\\n\")\n return False\n\n\nwhile True:\n guessed_right = number_game()\n\n if guessed_right:\n quit()\n else:\n number_game()\n"
},
{
"answer_id": 74483788,
"author": "Dex",
"author_id": 14041106,
"author_profile": "https://Stackoverflow.com/users/14041106",
"pm_score": 0,
"selected": false,
"text": "while True:\n number_game()\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20505017/"
] |
74,483,702
|
<p>I am pulling memes from an API and only want to show 5 memes therefore I tried to disable the touchableOpacity after certian number of clicks. Any ideas on how I can do that?</p>
<pre><code>
</code></pre>
<pre><code>const link = 'https://meme-api.herokuapp.com/gimme'
class Meme extends React.Component {
constructor() {
super()
this.state = {
loading: false,
data: {
postLink: "sample data",
subreddit: "sample data",
title: "sample data",
url: 'https://poster.keepcalmandposters.com/8170567.jpg'
}
}
}
load = () => {
this.setState({ loading: true })
axios.get(link).then(res => {
this.setState({
data: res.data,
loading: false,
})
console.log(Object.keys(res.data))
})
}
</code></pre>
<pre><code>
</code></pre>
<p>This is where the "button" is</p>
<pre><code>
</code></pre>
<pre><code>render() {
return (
<View>
<View style={styles.container}>
<View style={styles.imageView}>
<ProgressiveImage source={{ uri: this.state.data.url }} />
</View>
<TouchableOpacity style={styles.button}
onPress={() => {this.load()}} >
<Text style={styles.btnText}>Click to open a meme!</Text>
</TouchableOpacity>
</View>
<AnimatedLoader
visible={this.state.loading}
overlayColor="rgba(255,255,255,0.75)"
source={require("../loader.json")}
animationStyle={styles.lottie}
speed={1} />
</View>
);
}
};
</code></pre>
<pre><code>
</code></pre>
<p>I tried using state/setState for disabiling the button but nothing seems to work. I am okay with just disabiling the button but I tried it with two different pressHandlers, one for this.load() and another for disabling after a click but both of them does not work at the same time.</p>
|
[
{
"answer_id": 74485190,
"author": "Felix Filipi",
"author_id": 13738475,
"author_profile": "https://Stackoverflow.com/users/13738475",
"pm_score": 2,
"selected": true,
"text": "\nclass Meme extends React.Component {\n constructor() {\n super();\n this.state = {\n count: 0\n };\n }\n\n load = () => {\n this.setState({ count++ })\n // and others logic\n }\n\n render() {\n return (\n <TouchableOpacity onPress={() => {this.load()}} disabled = {this.state.count == 5 ? true : false}>\n <Text>Click to open a meme!</Text>\n </TouchableOpacity>\n );\n }\n}\n\n"
},
{
"answer_id": 74485554,
"author": "Engr.Aftab Ufaq",
"author_id": 9570734,
"author_profile": "https://Stackoverflow.com/users/9570734",
"pm_score": 0,
"selected": false,
"text": "functional component example for this. \n\nconst Meme = () => {\n const [count, setCount] = useState(0)\n\n const loadForAPI = () => {\n setCount(count => count + 1)\n }\n\n render() {\n return (\n <TouchableOpacity onPress={() => {loadForAPI()}} disabled = {count == 5 ? true : false}>\n <Text>Click to open a meme!</Text>\n </TouchableOpacity>\n );\n }\n}\n\nexport default Meme;\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535021/"
] |
74,483,706
|
<p>How to merge two json objects if their keys are in numering string and arrange in ascending order</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 obj1 = {
'10' : "ten"
'2' : "two",
"30": "thirty
}
let obj2 = {
'4' : "four",
'5' : "five",
"1": "one"
}
// output i want :
let res = {
"1": "one",
'2' : "two",
'4' : "four",
'5' : "five",
'10' : "ten"
"30": "thirty
}</code></pre>
</div>
</div>
</p>
|
[
{
"answer_id": 74485190,
"author": "Felix Filipi",
"author_id": 13738475,
"author_profile": "https://Stackoverflow.com/users/13738475",
"pm_score": 2,
"selected": true,
"text": "\nclass Meme extends React.Component {\n constructor() {\n super();\n this.state = {\n count: 0\n };\n }\n\n load = () => {\n this.setState({ count++ })\n // and others logic\n }\n\n render() {\n return (\n <TouchableOpacity onPress={() => {this.load()}} disabled = {this.state.count == 5 ? true : false}>\n <Text>Click to open a meme!</Text>\n </TouchableOpacity>\n );\n }\n}\n\n"
},
{
"answer_id": 74485554,
"author": "Engr.Aftab Ufaq",
"author_id": 9570734,
"author_profile": "https://Stackoverflow.com/users/9570734",
"pm_score": 0,
"selected": false,
"text": "functional component example for this. \n\nconst Meme = () => {\n const [count, setCount] = useState(0)\n\n const loadForAPI = () => {\n setCount(count => count + 1)\n }\n\n render() {\n return (\n <TouchableOpacity onPress={() => {loadForAPI()}} disabled = {count == 5 ? true : false}>\n <Text>Click to open a meme!</Text>\n </TouchableOpacity>\n );\n }\n}\n\nexport default Meme;\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20493210/"
] |
74,483,726
|
<p>I am working on implementing a sieve of atkins as my first decently sized program in rust. This algorithm takes a number and returns a vector of all primes below that number. There are two different vectors I need use this function.</p>
<ol>
<li>BitVec 1 for prime 0 for not prime (flipped back and forth as part of the algorithm).</li>
<li>Vector containing all known primes.</li>
</ol>
<p>The size of the <code>BitVec</code> is known as soon as the function is called. While the final size of the vector containing all known primes is not known, there are relatively accurate upper limits for the number of primes in a range. Using these I can set the size of the vector to an upper bound then <code>shrink_to_fit</code> it before returning. The upshot of this neither array should ever need to have it's capacity increased while the algorithm is running, and if this happens something has gone horribly wrong with the algorithm.</p>
<p>Therefore, I would like my function to panic if the capacity of either the vector or the bitvec is changed during the running of the function. Is this possible and if so how would I be best off implementing it?</p>
<p>Thanks,</p>
|
[
{
"answer_id": 74485190,
"author": "Felix Filipi",
"author_id": 13738475,
"author_profile": "https://Stackoverflow.com/users/13738475",
"pm_score": 2,
"selected": true,
"text": "\nclass Meme extends React.Component {\n constructor() {\n super();\n this.state = {\n count: 0\n };\n }\n\n load = () => {\n this.setState({ count++ })\n // and others logic\n }\n\n render() {\n return (\n <TouchableOpacity onPress={() => {this.load()}} disabled = {this.state.count == 5 ? true : false}>\n <Text>Click to open a meme!</Text>\n </TouchableOpacity>\n );\n }\n}\n\n"
},
{
"answer_id": 74485554,
"author": "Engr.Aftab Ufaq",
"author_id": 9570734,
"author_profile": "https://Stackoverflow.com/users/9570734",
"pm_score": 0,
"selected": false,
"text": "functional component example for this. \n\nconst Meme = () => {\n const [count, setCount] = useState(0)\n\n const loadForAPI = () => {\n setCount(count => count + 1)\n }\n\n render() {\n return (\n <TouchableOpacity onPress={() => {loadForAPI()}} disabled = {count == 5 ? true : false}>\n <Text>Click to open a meme!</Text>\n </TouchableOpacity>\n );\n }\n}\n\nexport default Meme;\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16895246/"
] |
74,483,727
|
<p>Is it possible to work at Raspberry Pi Pico using Windows 10? My question specified is: do I have to install any Linux distro, for example Raspbian, to be able to work at it? Do I also need to use SD card to work with it?</p>
<p>Just want to receive feedback, cause I'm confused and also kinda new to embedded systems</p>
|
[
{
"answer_id": 74530766,
"author": "Mark Setchell",
"author_id": 2836621,
"author_profile": "https://Stackoverflow.com/users/2836621",
"pm_score": 0,
"selected": false,
"text": "main.py"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20337520/"
] |
74,483,789
|
<p>I came across a problem:</p>
<p>Given an array, find the <strong>max</strong> count of this array, where <em>count</em> for an element in the array is defined as the no. of elements from this array which can divide this element.</p>
<p>Example: <strong>max</strong> count from the array <code>[2,2,2,5,6,8,9,9]</code> is 4 as 6 or 8 can be divided by 2,2,2 and by themselves.</p>
<p>My approach is:</p>
<ol>
<li>Sort the array.</li>
<li>Make a set from this array (in a way such that even this set is sorted in non-descending order).</li>
<li>Take another array in which the array indices are initialized to the no. of times an element appears in the original array. Example: in above example element '2' comes three times, hence index '2-1' in this new array will be initialized to 3, index '9-1' will be initialized to 2 as '9' comes 2 times in this array.</li>
<li>Using two loops I am checking the divisibility of largest (moving largest to smallest) element in the set with smallest (moving smallest to largest) element of the set.</li>
</ol>
<p><strong>Conditions</strong></p>
<blockquote>
<p>1 <= arr[i] <= 10000</p>
</blockquote>
<blockquote>
<p>1 <= i <= 10000</p>
</blockquote>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include<limits.h>
int cmp(const void *a, const void *b)
{
return (*(int*)a - *(int*)b);
}
void arr_2_set(int *arr, int arr_size,int *set, int *len)
{
int index = 0;
int set_len = 0;
int ele = INT_MIN;
qsort(arr,arr_size,sizeof(int),cmp);
while(index < arr_size)
{
if(ele != arr[index])
{
ele = arr[index];
set[set_len] = ele;
set_len++;
}
index++;
}
*len = set_len;
}
int main(void)
{
int arr[]={2,2,2,5,6,8,9,9}; //array is already sorted in this case
int size = sizeof(arr)/sizeof(arr[0]);
int set[size];
int index = 0;
int set_len = 0;
arr_2_set(arr, size, set, &set_len); //convert array to set - "set_len" is actual length of set
int rev = set_len-1; //this will point to the largest element of set and move towards smaller element
int a[100000] = {[0 ... 99999] = 0}; //new array for keeping the count
while(index<size)
{
a[arr[index] -1]++;
index++;
}
int half;
int max=INT_MIN;
printf("set len =%d\n\n",set_len);
for(;rev>=0;rev--)
{
index = 0;
half = set[rev]/2;
while(set[index] <= half)
{
if(set[rev]%set[index] == 0)
{
a[set[rev] -1] += a[set[index]-1]; //if there are 3 twos, then 3 should be added to count of 8
//printf("index =%d rev =%d set[index] =%d set[rev] =%d count = %d\n",index,rev,set[index],set[rev],a[set[rev] -1]);
}
if(max < a[set[rev]-1])
max = a[set[rev]-1];
index++;
}
}
printf("%d",max);
return 0;
}
</code></pre>
<p>Now my question is how can I speed up this program? I was able to pass 9/10 test cases - for the 10th test case (which was hidden), it was showing <em>"Time Limit Exceeded"</em>.</p>
|
[
{
"answer_id": 74495164,
"author": "Gaurav",
"author_id": 10334659,
"author_profile": "https://Stackoverflow.com/users/10334659",
"pm_score": 3,
"selected": true,
"text": "while"
},
{
"answer_id": 74496481,
"author": "Bob__",
"author_id": 4944425,
"author_profile": "https://Stackoverflow.com/users/4944425",
"pm_score": 1,
"selected": false,
"text": "qsort"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8977557/"
] |
74,483,797
|
<p>In the following example code, a SwiftUI form holds an Observable object that holds a trivial pipeline that passes a string through to a @Published value. That object is being fed by the top line of the SwiftUI form, and the output is being displayed on the second line.</p>
<p>The value in the text field in the first row gets propagated to the output line in the second row, whenever we hit the "Send" button, unless we hit the "End" button, which cancels the subscription, as we'd expect.</p>
<pre><code>import SwiftUI
import Combine
class ResetablePipeline: ObservableObject {
@Published var output = ""
var input = PassthroughSubject<String, Never>()
init(output: String = "") {
self.output = output
self.input
.assign(to: &$output)
}
func reset()
{
// What has to go here to revive a completed pipeline?
self.input
.assign(to: &$output)
}
}
struct ResetTest: View {
@StateObject var pipeline = ResetablePipeline()
@State private var str = "Hello"
var body: some View {
Form {
HStack {
TextField(text: $str, label: { Text("String to Send")})
Button {
pipeline.input.send(str)
} label: {
Text("Send")
}.buttonStyle(.bordered)
Button {
pipeline.input.send(completion: .finished)
} label: {
Text("End")
}.buttonStyle(.bordered)
}
Text("Output: \(pipeline.output)")
Button {
pipeline.reset()
} label: {
Text("Reset")
}
}
}
}
struct ResetTest_Previews: PreviewProvider {
static var previews: some View {
ResetTest()
}
}
</code></pre>
<p>My understanding is that hitting "End" and completing/cancelling the subscription will delete all the Combine nodes that were set up in the ResetablePipeline.init function (currently only the assign operator).</p>
<p>But if we wanted to reset that connection, how would we do that (without creating a new ResetablePipeline object). What would you have to do in reset() to reconnect the plumbing in the ResetablePipeline object, so that the Send button would work again? Why does the existing code not work?</p>
|
[
{
"answer_id": 74484600,
"author": "Scott Thompson",
"author_id": 415303,
"author_profile": "https://Stackoverflow.com/users/415303",
"pm_score": 1,
"selected": false,
"text": "collect"
},
{
"answer_id": 74485062,
"author": "Curious Jorge",
"author_id": 14840926,
"author_profile": "https://Stackoverflow.com/users/14840926",
"pm_score": 1,
"selected": true,
"text": "input = PassthroughSubject<String, Never>()"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14840926/"
] |
74,483,806
|
<p>I'm trying to write a function that takes an input vector, v, and returns a vector of the same length whose elements are boolean values indicating whether or not the corresponding element of the input vector indicates the variable homelessness. The function should loop over elements of
v and uses the homeless vector to flag those elements of v that indicate the arrestee is homeless</p>
<p>I keep getting an error saying "object 'n' not found"</p>
<p>I've tried changing the ith variable to flag_homeless to no success.</p>
<pre><code>flag_homeless <- function(v)
n <- length(v)
homeless <- rep(FALSE, n)
for (i in 1:n) {
if (v[i] == "No Permanent Address") {
homeless[i] <- TRUE }
}
return(homeless)
</code></pre>
|
[
{
"answer_id": 74484600,
"author": "Scott Thompson",
"author_id": 415303,
"author_profile": "https://Stackoverflow.com/users/415303",
"pm_score": 1,
"selected": false,
"text": "collect"
},
{
"answer_id": 74485062,
"author": "Curious Jorge",
"author_id": 14840926,
"author_profile": "https://Stackoverflow.com/users/14840926",
"pm_score": 1,
"selected": true,
"text": "input = PassthroughSubject<String, Never>()"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20534657/"
] |
74,483,811
|
<p>Please take a moment to consider the following dataset:</p>
<pre><code>my_df <- data.frame(socks = c(1,1,0,1,0,0),
hat = c(0,1,1,0,0,0),
species = c('frog','pigeon','pigeon','cow','monkey','cow'),
gender = c('M','F','M','F','M','M'))
acc <- c('socks','hat')
</code></pre>
<p>I am attempting to filter this dataset to include all observations where EITHER the socks OR hat animal accessory variables are equal to 1 (Rows 1-4). I also need to use a vector to hold the names of the columns for the animal accessory variables so I can run this command within a larger function.</p>
<p>Thus far, I have tried the following:</p>
<pre><code>accessorized <- my_df %>% filter_at(vars(acc),all_vars(.==1))
accessorized <- my_df %>% filter(across(acc,~.x==1))
</code></pre>
<p>and both return a dataframe containing only those observations where BOTH hat & socks = 1 (Row 2)</p>
<p>Does anybody have suggestions for how to modify this lambda-function to check for equality to 1 across hat & socks via OR rather than AND?</p>
<p>Any help would be greatly appreciated!</p>
|
[
{
"answer_id": 74484600,
"author": "Scott Thompson",
"author_id": 415303,
"author_profile": "https://Stackoverflow.com/users/415303",
"pm_score": 1,
"selected": false,
"text": "collect"
},
{
"answer_id": 74485062,
"author": "Curious Jorge",
"author_id": 14840926,
"author_profile": "https://Stackoverflow.com/users/14840926",
"pm_score": 1,
"selected": true,
"text": "input = PassthroughSubject<String, Never>()"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5910469/"
] |
74,483,839
|
<p>So I am a little confused on how to use events in Python. I have an API for a program I use that recently changed its file loading method to be asynchronous. These files can take a while to load and in the past the file loading method would halt execution until the file was loaded. Now it immediately goes on to the next line but everything fails then because the file isn't actually loaded yet.</p>
<p>This API does provide an event that fires once the file is loaded. However, I can't wrap my head around how I would change my code to work with this new event-driven method.</p>
<p>Essentially I want to load the file, wait until it is actually loaded, and then continue on with the rest of the program. I was thinking it would be something like:</p>
<pre><code>import API
fileLoader = API.FileLoader()
fileLoader.LoadFile('path/to/file')
while not fileLoader.OnFileLoaded():
# do some sort of waiting here?
# continue on with the rest of the code
</code></pre>
<p>I have been trying to read up on decorators and callbacks and other such things but they all seem to be used mainly in GUI or web development stuff where everything is event based. This is just one step that needs to wait for an event to fire.</p>
<p>I also don't think the OnFileLoaded event really works like that. I don't see any return value from it and from what I can tell it takes an object called a FileLoaded object that contains data about where it was loaded into. My guess would be that you can try to load multiple files in different instances and just work with them as they get loaded in.</p>
<p>Is there some sort of standard pythonic way of dealing with stuff like this?</p>
<p>Update:</p>
<p>Below is what Visual Studio gives for information on the OnFileLoaded event</p>
<pre><code>public event API.FileLoader.OnFileLoadedDelegate OnFileLoaded
Member of API.FileLoader
</code></pre>
<p>And for the LoadFile method</p>
<pre><code>public void LoadFile(string filePath)
Member of API.FileLoader
</code></pre>
<p>And then I went to look what this OnFileLoadedDelegate was and I found this</p>
<pre><code>public delegate void OnFileLoadedDelegate(API2.Models.FileLoaded fileLoaded)
Member of API.FileLoader
</code></pre>
<p>And it had two methods, one called BeginInvoke</p>
<pre><code>public virtual System.IAsyncResult BeginInvoke(API2.Models.FileLoaded fileLoaded, System.AsyncCallback callback, object object)
Member of API.FileLoader.OnFileLoadedDelegate
</code></pre>
<p>and one called EndInvoke</p>
<pre><code>public virtual void EndInvoke(System.IAsyncResult result)
Member of API.FileLoader.OnFileLoadedDelegate
</code></pre>
<p>Finally I found one more method in the FileLoader class called GetAutomationCallbackService</p>
<pre><code>protected override API2.IApplicationCallbackService GetAutomationCallbackService()
Member of API.FileLoader
</code></pre>
<p>If I go to API2 I see that it also has an inteface (?) named OnFileLoaded</p>
<p>I hope that helps clear this up, I am quite confused how it all fits together.</p>
|
[
{
"answer_id": 74484600,
"author": "Scott Thompson",
"author_id": 415303,
"author_profile": "https://Stackoverflow.com/users/415303",
"pm_score": 1,
"selected": false,
"text": "collect"
},
{
"answer_id": 74485062,
"author": "Curious Jorge",
"author_id": 14840926,
"author_profile": "https://Stackoverflow.com/users/14840926",
"pm_score": 1,
"selected": true,
"text": "input = PassthroughSubject<String, Never>()"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2731076/"
] |
74,483,971
|
<p>I have the following list:</p>
<p><code>List<int> Items = new List<int> { 0, 0, 1, 1, 0 }</code></p>
<p>I want same items in the array that are next to each other to continue to add up until the next item in the array that is not the same, with the output being the following:</p>
<pre><code>0,2
1,2
0,1
</code></pre>
<p>This is the code I have:</p>
<pre><code> public static void Test()
{
StringBuilder Data = new StringBuilder();
List<int> Items = new List<int> { 0, 0, 1, 1, 0 };
int Index = 1;
if (Items[0] != Items[1])
{
Data.AppendLine(Items[0] + " 1");
}
while (Index < Items.Count)
{
int PastValue = Items[Index - 1];
int CurrentValue = Items[Index];
int CurrentLength = 1;
while (CurrentValue == PastValue && Index + CurrentLength < Items.Count)
{
CurrentValue = Items[Index + CurrentLength];
CurrentLength += 1;
}
Data.AppendLine(CurrentValue + " " + CurrentLength);
Index = Index + CurrentLength;
}
Console.WriteLine(Data.ToString());
}
</code></pre>
<p>And it produces the following which is incorrect:</p>
<pre><code>1,2
0,2
</code></pre>
<p>Is there a better way of doing this? Any help much appreciated.</p>
|
[
{
"answer_id": 74484269,
"author": "mkmkmk",
"author_id": 20154538,
"author_profile": "https://Stackoverflow.com/users/20154538",
"pm_score": 1,
"selected": true,
"text": " public static void Test()\n {\n StringBuilder Data = new StringBuilder();\n List<int> Items = new List<int> { 0, 0, 1, 1, 0 };\n int tempCount = 0;\n int tempNumber = 0;\n for ( int i = 0; i < Items.Count; i++ )\n {\n if ( Items[i].Equals(tempNumber) )\n {\n tempCount++;\n }\n else\n {\n if(tempCount>0)\n {\n Data.AppendLine( tempNumber + \",\" + tempCount );\n }\n tempNumber = Items[i];\n tempCount = 1;\n }\n }\n Data.AppendLine( tempNumber + \",\" + tempCount );\n Console.WriteLine( Data.ToString() );\n }\n"
},
{
"answer_id": 74484308,
"author": "Enigmativity",
"author_id": 259769,
"author_profile": "https://Stackoverflow.com/users/259769",
"pm_score": 2,
"selected": false,
"text": "public static IEnumerable<(V Value, int Count)> Compress<V>(this IEnumerable<V> source)\n{\n var count = 0;\n var current = default(V);\n foreach (var value in source)\n {\n if (count == 0)\n {\n current = value;\n count = 1;\n }\n else\n {\n if (current.Equals(value))\n {\n count++;\n }\n else\n {\n yield return (current, count);\n current = value;\n count = 1;\n }\n }\n }\n if (count != 0)\n {\n yield return (current, count);\n }\n}\n"
},
{
"answer_id": 74564519,
"author": "Idle_Mind",
"author_id": 2330053,
"author_profile": "https://Stackoverflow.com/users/2330053",
"pm_score": 1,
"selected": false,
"text": "public static void Main(string[] args)\n{\n List<int> Items = new List<int> { 0, 0, 1, 1, 0 };\n\n int count = 0;\n int prevInt = 0;\n List<Tuple<int, int>> results = new List<Tuple<int, int>>(); \n foreach(int i in Items)\n {\n if (count == 0 || i == prevInt)\n {\n count++;\n }\n else\n {\n results.Add(new Tuple<int, int>(prevInt, count));\n count = 1;\n }\n prevInt = i;\n }\n if (count > 0)\n {\n results.Add(new Tuple<int, int>(prevInt, count));\n }\n\n String result = String.Join(Environment.NewLine, results);\n Console.WriteLine(result);\n Console.WriteLine(\"Press Enter to Quit.\");\n Console.ReadLine();\n}\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17957703/"
] |
74,483,990
|
<p>I'm creating a static web app using React as a frontend and am running into a problem with dynamic theming. While the theme switching and saving the name of the theme into local storage works fine, it will only actually work once until a page refresh or a route change away and back to the page.</p>
<p>Ex. I can load the page with my previously chosen dark theme, but then if I were to switch back to a light theme, things work correctly, but then another switch to the dark theme causes the ui to change colors as intended but the local storage variable would stay as the light theme.</p>
<p>Code below</p>
<p>These are the html cards that showcase and change a theme</p>
<pre><code>const ThemeCards = ( props ) => {
// eslint-disable-next-line
const [theme, setTheme] = useLocalStorage("theme-type", "theme-default");
var themeToggle = (themeName) => {
setTheme(themeName);
document.getElementById("themeProvider").className = themeName;
}
return (
<div className={props.className}>
<div className={props.className + "-inner"}>
<div className={props.className + "-front"}>
<div>{props.themeName}</div>
</div>
<div className={props.className + "-back"}>
<button onClick={() => themeToggle(props.themeID)}>Toggle</button>
</div>
</div>
</div>
)
}
</code></pre>
<p>This is the useLocalStorage.js</p>
<pre><code>import { useEffect, useState } from 'react';
const useLocalStorage = (storageKey, fallbackState) => {
const [value, setValue] = useState(
JSON.parse(localStorage.getItem(storageKey)) ?? fallbackState
);
useEffect(() => {
localStorage.setItem(storageKey, JSON.stringify(value));
}, [value, storageKey]);
return [value, setValue];
}
export default useLocalStorage;
</code></pre>
<p>Implementation of themeProvider, it is simply the id of a div providing the theme name as a string as the className</p>
<pre><code>function App() {
const [theme, setTheme] = useLocalStorage("theme-type",
"theme-default");
return (
<>
<div className={theme} id="themeProvider">
<HashRouter>
<SideBar />
<NavTitle />
<Routes>
...
</Routes>
</HashRouter>
</div>
</>
);
}
export default App;
</code></pre>
<p>And versions</p>
<pre><code>"react": "^18.1.0",
"react-dom": "^18.1.0"
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
</code></pre>
<p>Refreshing the page or simply navigating to the home route and then back to the themes route will reset the cycle.</p>
<p>I've console logged both the theme and themeName hoping to debug using this if statement in the themeToggle</p>
<pre><code>if (theme === themeName) {
console.log("Theme is already set to " + themeName);
return
} else {
setTheme(themeName);
document.getElementById("themeProvider").className = themeName;
}
</code></pre>
<p>Although when the error happens, only one variable exists in the local storage yet switching to any theme yields the console log branch in the console, as if saying the local storage key represents both strings at the same time, any guidance would be appreciated as I'm rather new to persisting data in the browser!</p>
|
[
{
"answer_id": 74484533,
"author": "Daniel T",
"author_id": 10477326,
"author_profile": "https://Stackoverflow.com/users/10477326",
"pm_score": 2,
"selected": true,
"text": "ThemeToggle(props.themeID)"
},
{
"answer_id": 74484805,
"author": "Azzy",
"author_id": 2122822,
"author_profile": "https://Stackoverflow.com/users/2122822",
"pm_score": 0,
"selected": false,
"text": "const [theme, setTheme] = useLocalStorage(\"theme-type\",\n\"theme-default\");\n\nreturn (\n <>\n <div className={theme} id=\"themeProvider\">\n <HashRouter>\n <SideBar />\n <NavTitle />\n <Routes>\n ...\n <Route path={`/${appRoutes.home}`} element={<Home setTheme={setTheme} />} />\n </Routes>\n </HashRouter>\n </div>\n </>\n );\n}\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74483990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535157/"
] |
74,484,010
|
<p>I am trying to figure out how to copy the text content from my nodeList into a new navigation bar for my mobile version.</p>
<p>The original navigation bar was created in HTML. I turned my <strong>ul</strong> into a nodeList and then I created all the new elements <strong>li</strong>, <strong>a</strong>, and <strong>href</strong> and appended them to where they need to go, but I can't figure out how to copy the text content from my original list and display it into my new one. The closest I got was this example, and it makes sense why it is displaying all text in each anchor but I can't figure out how to get it right. I also left out the HTML main content because it does not pertain.</p>
<pre><code></head>
<body>
<div class="smallMenuLink"><a href="#smallNavArea">MENU</a></div>
<nav>
<ul id="primaryNavigation">
<li><a id="indexFile" href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="location.html">Location</a></li>
<li><a href="products.html">Products</a></li>
<li><a href="services.html">Services</a></li>
</ul>
<div class="keepOpen"></div>
</nav>
<nav id="smallNavArea"></nav>
<footer>
<p>Andrew Kester</p>
</footer>
</body>
<script type="text/javascript" src="js/main.js"></script>
</html>
</code></pre>
<pre><code>function duplicateMenu() {
// get all of the anchor elements from the top menu
let topList = document.querySelectorAll('ul#primaryNavigation li a') //This creates the NodeList
// create the new list items for the bottom of the page
let newList = document.createElement('ul') // -------------------------creates a new ul
topList.forEach(menuItem => { //---------------------------------------Loops through all elements in nodelist
let newListItem = document.createElement('li')
let newLink = document.createElement('a') //-----------------------creates an anchor
newLink.setAttribute('href', menuItem.getAttribute('href')) // ----this extracts the href from each anchor and Adds href to the Anchor
// 'copy' or 'modify' the textContent from upper menu to new menu
newLink.textContent = primaryNavigation.textContent
// append children to make them appear in the DOM
newListItem.append(newLink)
newList.append(newListItem)
document.querySelector('#smallNavArea').append(newList)
/* console.log(newList) */
})
}
duplicateMenu()
</code></pre>
|
[
{
"answer_id": 74484533,
"author": "Daniel T",
"author_id": 10477326,
"author_profile": "https://Stackoverflow.com/users/10477326",
"pm_score": 2,
"selected": true,
"text": "ThemeToggle(props.themeID)"
},
{
"answer_id": 74484805,
"author": "Azzy",
"author_id": 2122822,
"author_profile": "https://Stackoverflow.com/users/2122822",
"pm_score": 0,
"selected": false,
"text": "const [theme, setTheme] = useLocalStorage(\"theme-type\",\n\"theme-default\");\n\nreturn (\n <>\n <div className={theme} id=\"themeProvider\">\n <HashRouter>\n <SideBar />\n <NavTitle />\n <Routes>\n ...\n <Route path={`/${appRoutes.home}`} element={<Home setTheme={setTheme} />} />\n </Routes>\n </HashRouter>\n </div>\n </>\n );\n}\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20279098/"
] |
74,484,028
|
<p>Given a data set with the goal of graphing the data these issues arise:</p>
<ul>
<li>The header is an entry in the list,</li>
<li>Some of the entries are blank (data missing),</li>
<li>Even the numbers are in the form of strings</li>
</ul>
<pre><code>income=[]
fertility=[]
for row in csv:
income.append(row[2])
fertility.append(row[3])
print(income)
print(fertility)
</code></pre>
<p>I am trying to modify the above for loop that appends only the numerical values of the row using the float function coded below.</p>
<pre><code>def isNumeric(s):
try:
s = float(s)
return True
except:
return False
</code></pre>
<p>Below is my attempt, that is not appending the numerical values of the rows only giving me blank sets for income and fertility.</p>
<pre><code>income=[]
fertility=[]
for row in csv:
if isNumeric(row[2])=='True' and isNumeric(row[3])=='True':
float(row[2])
float(row[3])
income.append(float(row[2]))
fertility.append(float(row[3]))
print(income)
print(fertility)
</code></pre>
|
[
{
"answer_id": 74484045,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 1,
"selected": false,
"text": "float"
},
{
"answer_id": 74484168,
"author": "Mark",
"author_id": 2203038,
"author_profile": "https://Stackoverflow.com/users/2203038",
"pm_score": 0,
"selected": false,
"text": "income=[]\nfertility=[]\nfor row in csv:\n if isNumeric(row[2]) and isNumeric(row[3]):\n income.append(float(row[2]))\n fertility.append(float(row[3]))\n\nprint(income)\nprint(fertility)\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535154/"
] |
74,484,050
|
<p>So I have this data from api that then gives me a _JsonMap response which I then convert to LinkedMap<dyanmic, dynamic> by doing:</p>
<pre><code>final data = Map.from(response.data);
</code></pre>
<p>Now I have this LinkedMap<dyanmic, dynamic> data which looks like this.</p>
<pre><code>{
Product1: {
name: 'name',
description: 'description',
Promos: {
Price1: {
amount: 999,
metadata: {
dateStart: 2022-11-23
dateEnd: 2022-11-25
promoName: test,
}
}
Price2: {
amount: 999,
metadata: {
dateStart: 2022-11-23
dateEnd: 2022-11-25
promoName: test,
}
}
Price3: {
amount: 999,
metadata: {
dateStart: 2022-11-23
dateEnd: 2022-11-25
promoName: test,
}
}
}
}
Product2: {
name: 'name',
description: 'description',
Promos: {
Price1: {
amount: 999,
metadata: {
dateStart: 2022-11-23
dateEnd: 2022-11-25
promoName: test,
}
}
Price2: {
amount: 999,
metadata: {
dateStart: 2022-11-23
dateEnd: 2022-11-25
promoName: test,
}
}
Price3: {
amount: 999,
metadata: {
dateStart: 2022-11-23
dateEnd: 2022-11-25
promoName: test,
}
}
}
}
}
</code></pre>
<p>Now what i'm trying to do is Map the Producst - get to their Promos - get the all Prices - then get to their metadata and display dateStart, dateEnd, promoName to my listview.builder. any ideas?</p>
<p>response.data</p>
<pre><code> {
"Product1":{
"name":"name",
"description":"test",
"Promos":{
"Price1":{
"amount":"999",
"metadata":{
"dateStart":"2022-11-23",
"dateEnd":"2022-11-25",
"promoName":"test"
}
},
"Price2":{
"amount":"999",
"metadata":{
"dateStart":"2022-11-23",
"dateEnd":"2022-11-25",
"promoName":"test"
}
},
"Price3":{
"amount":"999",
"metadata":{
"dateStart":"2022-11-23",
"dateEnd":"2022-11-25",
"promoName":"test"
}
}
}
},
"Product2":{
"name":"name",
"description":"test",
"Promos":{
"Price1":{
"amount":"999",
"metadata":{
"dateStart":"2022-11-23",
"dateEnd":"2022-11-25",
"promoName":"test"
}
},
"Price2":{
"amount":"999",
"metadata":{
"dateStart":"2022-11-23",
"dateEnd":"2022-11-25",
"promoName":"test"
}
},
"Price3":{
"amount":"999",
"metadata":{
"dateStart":"2022-11-23",
"dateEnd":"2022-11-25",
"promoName":"test"
}
}
}
}
}
</code></pre>
|
[
{
"answer_id": 74484738,
"author": "Paulo",
"author_id": 15649348,
"author_profile": "https://Stackoverflow.com/users/15649348",
"pm_score": 0,
"selected": false,
"text": "[\n {\n \"name\": \"Product 1\",\n \"description\": \"test\",\n \"promos\": [\n {\n \"name\": \"Price 1\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n },\n {\n \"name\": \"Price 2\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n },\n {\n \"name\": \"Price 3\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n ]\n },\n {\n \"name\": \"Product 2\",\n \"description\": \"test\",\n \"promos\": [\n {\n \"name\": \"Price 1\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n },\n {\n \"name\": \"Price 2\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n },\n {\n \"name\": \"Price 3\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n ]\n }\n]\n"
},
{
"answer_id": 74484780,
"author": "THEODORE",
"author_id": 9185856,
"author_profile": "https://Stackoverflow.com/users/9185856",
"pm_score": -1,
"selected": false,
"text": "import 'package:flutter/material.dart';\nimport 'package:grouped_list/grouped_list.dart';\n\nfinal data = {\n \"Product1\": {\n \"name\": \"theodore\",\n \"description\": \"test\",\n \"Promos\": {\n \"Price1\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n },\n \"Price2\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n },\n \"Price3\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n }\n }\n },\n \"Product2\": {\n \"name\": \"cynthia\",\n \"description\": \"test\",\n \"Promos\": {\n \"Price1\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n },\n \"Price2\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n },\n \"Price3\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n }\n }\n }\n};\n\nvoid main() {\n runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return const MaterialApp(\n debugShowCheckedModeBanner: false,\n home: Scaffold(\n body: Center(\n child: MyWidget(),\n ),\n ),\n );\n }\n}\n\nclass MyWidget extends StatelessWidget {\n const MyWidget({Key? key}) : super(key: key);\n\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n debugShowCheckedModeBanner: false,\n title: 'Flutter Demo',\n theme: ThemeData(\n primarySwatch: Colors.blue,\n ),\n home: Scaffold(\n appBar: AppBar(\n title: const Text('Grouped List View Example'),\n ),\n body: GroupedListView<dynamic, String>(\n elements: data.entries.toList(),\n groupBy: (element) => element.value[\"name\"],\n groupComparator: (value1, value2) => value2.compareTo(value1),\n itemComparator: (item1, item2) =>\n item1['name'].compareTo(item2['name']),\n order: GroupedListOrder.DESC,\n useStickyGroupSeparators: true,\n groupSeparatorBuilder: (String value) => Padding(\n padding: const EdgeInsets.all(8.0),\n child: Text(\n value,\n textAlign: TextAlign.center,\n style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),\n ),\n ),\n itemBuilder: (c, element) {\n return Column(\n children: (element.value[\"Promos\"].entries.toList()\n as List<MapEntry>)\n .map((promo) => Card(\n elevation: 8.0,\n margin: const EdgeInsets.symmetric(\n horizontal: 10.0, vertical: 6.0),\n child: SizedBox(\n child: ListTile(\n contentPadding: const EdgeInsets.symmetric(\n horizontal: 20.0, vertical: 10.0),\n leading: const Icon(Icons.card_giftcard),\n title: Text(promo.key +\n \"-\" +\n \" \" +\n promo.value[\"metadata\"][\"promoName\"]),\n subtitle: Text(promo.value[\"metadata\"][\"dateEnd\"]),\n trailing: Text(promo.value[\"amount\"]),\n ),\n ),\n ))\n .toList(),\n );\n },\n ),\n ),\n );\n }\n}\n"
},
{
"answer_id": 74485214,
"author": "Ashkan Sarlak",
"author_id": 2511775,
"author_profile": "https://Stackoverflow.com/users/2511775",
"pm_score": 0,
"selected": false,
"text": "toJson"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3352042/"
] |
74,484,066
|
<p>I have two dataframes with a column called "US Postal State Code" and I am trying to merge them together on that column into a new dataframe. The problem is that the column has an object dtype in the first dataframe and a int64 dtype in the second dataframe.</p>
<p>I tried to change the column with the object dtype to int64 using</p>
<pre><code> Enterprise3['US Postal State Code']=Enterprise3['US Postal State Code'].astype(int)
</code></pre>
<p>however I got an error that states</p>
<pre><code>ValueError: invalid literal for int() with base 10: 'AL'
</code></pre>
<p>Is there another way to change the dtypes so that they match and can be merged?</p>
|
[
{
"answer_id": 74484738,
"author": "Paulo",
"author_id": 15649348,
"author_profile": "https://Stackoverflow.com/users/15649348",
"pm_score": 0,
"selected": false,
"text": "[\n {\n \"name\": \"Product 1\",\n \"description\": \"test\",\n \"promos\": [\n {\n \"name\": \"Price 1\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n },\n {\n \"name\": \"Price 2\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n },\n {\n \"name\": \"Price 3\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n ]\n },\n {\n \"name\": \"Product 2\",\n \"description\": \"test\",\n \"promos\": [\n {\n \"name\": \"Price 1\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n },\n {\n \"name\": \"Price 2\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n },\n {\n \"name\": \"Price 3\",\n \"amount\": \"999\",\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n ]\n }\n]\n"
},
{
"answer_id": 74484780,
"author": "THEODORE",
"author_id": 9185856,
"author_profile": "https://Stackoverflow.com/users/9185856",
"pm_score": -1,
"selected": false,
"text": "import 'package:flutter/material.dart';\nimport 'package:grouped_list/grouped_list.dart';\n\nfinal data = {\n \"Product1\": {\n \"name\": \"theodore\",\n \"description\": \"test\",\n \"Promos\": {\n \"Price1\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n },\n \"Price2\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n },\n \"Price3\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n }\n }\n },\n \"Product2\": {\n \"name\": \"cynthia\",\n \"description\": \"test\",\n \"Promos\": {\n \"Price1\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n },\n \"Price2\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n },\n \"Price3\": {\n \"amount\": \"999\",\n \"metadata\": {\n \"dateStart\": \"2022-11-23\",\n \"dateEnd\": \"2022-11-25\",\n \"promoName\": \"test\"\n }\n }\n }\n }\n};\n\nvoid main() {\n runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return const MaterialApp(\n debugShowCheckedModeBanner: false,\n home: Scaffold(\n body: Center(\n child: MyWidget(),\n ),\n ),\n );\n }\n}\n\nclass MyWidget extends StatelessWidget {\n const MyWidget({Key? key}) : super(key: key);\n\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n debugShowCheckedModeBanner: false,\n title: 'Flutter Demo',\n theme: ThemeData(\n primarySwatch: Colors.blue,\n ),\n home: Scaffold(\n appBar: AppBar(\n title: const Text('Grouped List View Example'),\n ),\n body: GroupedListView<dynamic, String>(\n elements: data.entries.toList(),\n groupBy: (element) => element.value[\"name\"],\n groupComparator: (value1, value2) => value2.compareTo(value1),\n itemComparator: (item1, item2) =>\n item1['name'].compareTo(item2['name']),\n order: GroupedListOrder.DESC,\n useStickyGroupSeparators: true,\n groupSeparatorBuilder: (String value) => Padding(\n padding: const EdgeInsets.all(8.0),\n child: Text(\n value,\n textAlign: TextAlign.center,\n style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),\n ),\n ),\n itemBuilder: (c, element) {\n return Column(\n children: (element.value[\"Promos\"].entries.toList()\n as List<MapEntry>)\n .map((promo) => Card(\n elevation: 8.0,\n margin: const EdgeInsets.symmetric(\n horizontal: 10.0, vertical: 6.0),\n child: SizedBox(\n child: ListTile(\n contentPadding: const EdgeInsets.symmetric(\n horizontal: 20.0, vertical: 10.0),\n leading: const Icon(Icons.card_giftcard),\n title: Text(promo.key +\n \"-\" +\n \" \" +\n promo.value[\"metadata\"][\"promoName\"]),\n subtitle: Text(promo.value[\"metadata\"][\"dateEnd\"]),\n trailing: Text(promo.value[\"amount\"]),\n ),\n ),\n ))\n .toList(),\n );\n },\n ),\n ),\n );\n }\n}\n"
},
{
"answer_id": 74485214,
"author": "Ashkan Sarlak",
"author_id": 2511775,
"author_profile": "https://Stackoverflow.com/users/2511775",
"pm_score": 0,
"selected": false,
"text": "toJson"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535301/"
] |
74,484,068
|
<p>I am struggling to handle dates and times within Javascript environment. We are using two input fields to obtain a date and time for an event. The event needs to display and calculate all dates within it's local timezone. E.g. if event is in Melbourne Australia, then I see the local time in Melbourne.</p>
<p>We are using <a href="https://flatpickr.js.org/" rel="nofollow noreferrer">flatpickr</a> for date entry and time entry (2 separate fields).</p>
<p>Date returns: <code>2022-11-18T00:00:00.000Z</code> (i.e. we only care about the date portion. time is always 00:00:00. This is stored in Mongo as <code>"date" : ISODate("2022-11-18T00:00:00.000+0000")</code>)</p>
<p>Time returns: <code>09:00 AM</code></p>
<p>I would like to store this into our MongoDB as <code>2022-11-18T09:00:00.000</code>.</p>
<p>Therefore whenever this is read or used in a calculation it always uses the time local to the event.</p>
<p>I have tried moment and date-fns: however I cannot find consistency between servers and browsers. Everything I have tried on SO always converts UTC.</p>
<p>Any help is greatly appreciated.</p>
|
[
{
"answer_id": 74487245,
"author": "Wernfried Domscheit",
"author_id": 3027266,
"author_profile": "https://Stackoverflow.com/users/3027266",
"pm_score": 0,
"selected": false,
"text": "Date"
},
{
"answer_id": 74505223,
"author": "RobG",
"author_id": 257182,
"author_profile": "https://Stackoverflow.com/users/257182",
"pm_score": 2,
"selected": true,
"text": "new Intl.DateTimeFormat().resolvedOptions().timeZone\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1374406/"
] |
74,484,072
|
<p>Many SO answers use <code>await Task.Delay(1)</code> to solve various async rendering issues in Blazor (wasm). I've even found a number of places in my own code where doing that "makes it work".</p>
<p>However it's always stated as matter of fact, without a thorough explanation, and I can't find this technique in the docs either.</p>
<p>Some questions:</p>
<ul>
<li>Why use <code>await Task.Delay(1)</code> - when would I use this technique, what is the use case?</li>
<li>The docs do not discuss this (that I could find); is it because it's a hack, or is it a legitimate way to deal with the use case?</li>
<li>Any difference between <code>Task.Delay(1)</code> and <code>Task.Yield()</code>?</li>
</ul>
|
[
{
"answer_id": 74486022,
"author": "Henk",
"author_id": 60761,
"author_profile": "https://Stackoverflow.com/users/60761",
"pm_score": 2,
"selected": true,
"text": "Task StateHasChangedAsync()"
},
{
"answer_id": 74489072,
"author": "enet",
"author_id": 6152891,
"author_profile": "https://Stackoverflow.com/users/6152891",
"pm_score": 1,
"selected": false,
"text": "Henk Holterman"
},
{
"answer_id": 74492426,
"author": "Stephen Cleary",
"author_id": 263693,
"author_profile": "https://Stackoverflow.com/users/263693",
"pm_score": 2,
"selected": false,
"text": "Task.Yield"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9971404/"
] |
74,484,077
|
<p>I have a dataframe "A" which is multi indexed shown below</p>
<pre><code>
LL SK Di Co
Bracket yr_wk
1 121 2 2 4 3
122 3 6 5 4
123 3 2 6 2
124 2 5 5 3
125 3 5 6 3
2 121 4 7 1 6
122 1 5 1 7
123 3 9 6 4
124 5 1 5 6
125 8 7 7 2
</code></pre>
<p>Another dataframe "B" which is single index</p>
<pre><code> Factor
yr_wk
121 0.98
122 1.045
123 0.92
124 0.99
125 0.95
</code></pre>
<p>I am trying to multiple the factor column of dataframe B with columns of A, grouped by the yr_wk column. Below is the resultant dataframe which I am trying to calculate</p>
<pre><code>
LL SK Di Co
Bracket yr_wk
1 121 2*0.98 2*0.98 4*0.98 3*0.98
122 3*1.045 6*1.045 5*1.045 4*1.045
123 3*0.92 2*0.92 6*0.92 2*0.92
124 2*0.99 5*0.99 5*0.99 3*0.99
125 3*0.95 5*0.95 6*0.95 3*0.95
2 121 4*0.98 7*0.98 1*0.98 6*0.98
122 1*1.045 5*1.045 1*1.045 7*1.045
123 3*0.92 9*0.92 6*0.92 4*0.92
124 5*0.99 1*0.99 5*0.99 6*0.99
125 8*0.95 7*0.95 7*0.95 2*0.95
</code></pre>
<p>Below is what I tried but it is not working because I am messing up the index</p>
<pre><code>C= A.multiply(B)
</code></pre>
|
[
{
"answer_id": 74486022,
"author": "Henk",
"author_id": 60761,
"author_profile": "https://Stackoverflow.com/users/60761",
"pm_score": 2,
"selected": true,
"text": "Task StateHasChangedAsync()"
},
{
"answer_id": 74489072,
"author": "enet",
"author_id": 6152891,
"author_profile": "https://Stackoverflow.com/users/6152891",
"pm_score": 1,
"selected": false,
"text": "Henk Holterman"
},
{
"answer_id": 74492426,
"author": "Stephen Cleary",
"author_id": 263693,
"author_profile": "https://Stackoverflow.com/users/263693",
"pm_score": 2,
"selected": false,
"text": "Task.Yield"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20470119/"
] |
74,484,089
|
<p>I have two strings, and I need to know if one is contained in the other, completely ignoring the order of the characters of both of them.</p>
<p>Example:</p>
<pre><code> string container = "WWGAAFWW";
string element = "WA";
Debug.Log(container.Contains(element));
</code></pre>
<p>This gives false, but I need it to be true, because W and A are contained in the container string.
I know there is a method to sort lists, but even then, container would become AAFGWWWW and comparing them would still give false.
Both string could be longer than this example (but not by much, i think).
After having checked that, if the second string is contained (the way I intend) I would also need to remove it from the first one, so in the example, I want the end result to be WGAFWWF.
I can't think of a simple way to do this, and I couldn't find any example on how to. Any idea?</p>
|
[
{
"answer_id": 74486022,
"author": "Henk",
"author_id": 60761,
"author_profile": "https://Stackoverflow.com/users/60761",
"pm_score": 2,
"selected": true,
"text": "Task StateHasChangedAsync()"
},
{
"answer_id": 74489072,
"author": "enet",
"author_id": 6152891,
"author_profile": "https://Stackoverflow.com/users/6152891",
"pm_score": 1,
"selected": false,
"text": "Henk Holterman"
},
{
"answer_id": 74492426,
"author": "Stephen Cleary",
"author_id": 263693,
"author_profile": "https://Stackoverflow.com/users/263693",
"pm_score": 2,
"selected": false,
"text": "Task.Yield"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535327/"
] |
74,484,091
|
<p>Here is a JSON array.</p>
<pre><code>var cars = {
"cars": {
"john": [],
"alex": [
"ford"
],
"hilton": [],
"martin": [
"ford",
"ferrari"
],
"david": [
"Lamborghini"
],
...
}
}
</code></pre>
<p>And I want to get array from this. How should I implement it in Typescript?
I tried several things, but none of them worked.
There is also a JSON array with only names as shown below, but I don't know how to use it.</p>
<pre><code>var names = {
"names": [
"john",
"alex",
"hilton",
"martin",
"david",
...
]
}
</code></pre>
<p>I tried like bellow, but it doesn't work.</p>
<pre><code>
let aryCars: string[][] = [];
names.map((name: string) => {
cars[name].map((car: string) => {
aryCars[name].push(car);
});
});
</code></pre>
<p>But following error occur.</p>
<p><code>Element implicitly has an 'any' type because index expression is not of type 'number'.</code></p>
<p>Please let me know if you know how.
Thanks.</p>
|
[
{
"answer_id": 74486022,
"author": "Henk",
"author_id": 60761,
"author_profile": "https://Stackoverflow.com/users/60761",
"pm_score": 2,
"selected": true,
"text": "Task StateHasChangedAsync()"
},
{
"answer_id": 74489072,
"author": "enet",
"author_id": 6152891,
"author_profile": "https://Stackoverflow.com/users/6152891",
"pm_score": 1,
"selected": false,
"text": "Henk Holterman"
},
{
"answer_id": 74492426,
"author": "Stephen Cleary",
"author_id": 263693,
"author_profile": "https://Stackoverflow.com/users/263693",
"pm_score": 2,
"selected": false,
"text": "Task.Yield"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18136719/"
] |
74,484,095
|
<p>I'm looking for a way to shorten my formula. I'm new to excel and have no idea how I could shorten the formula, I've made several attempts but always get errors. I'm sure for someone more experienced it will be a trivial question.</p>
<p>I hope someone can help me, I appreciate any response.</p>
<pre><code>=SUM(IF((ISNUMBER(SEARCH("Bench",$P$9:$U$11)))+(ISNUMBER(SEARCH("Press",$P$9:$U$11)));V9:V11*$W$9:$W$11,0))+SUM(IF((ISNUMBER(SEARCH("Bench",$P$19:$U$21)))+(ISNUMBER(SEARCH("Press ";$P$19:$U$21)));V19:V21*$W$19:$W$21;0))+SUM(IF((ISNUMBER(SEARCH("Bench",$P$29:$U$31)))+(ISNUMBER(SEARCH("Press",$P$29:$U$31)));V29:V31*$W$29:$W$31,0))+SUM(IF( (ISNUMBER(SEARCH("Bench",$P$39:$U$41)))+(ISNUMBER(SEARCH("Press",$P$39:$U$41)));V39:V41*$W$39:$ W$41;0))
</code></pre>
|
[
{
"answer_id": 74485970,
"author": "Max R",
"author_id": 19662289,
"author_profile": "https://Stackoverflow.com/users/19662289",
"pm_score": 2,
"selected": false,
"text": "=SUM( IF( \n (ISNUMBER( SEARCH( \"Bench\" , $P$9:$U$11 ) ) ) +\n (ISNUMBER( SEARCH( \"Press\" , $P$9:$U$11 ) ) ) ;\n V9:V11 * $W$9:$W$11 , \n 0 ) )\n\n+SUM( IF(\n (ISNUMBER( SEARCH( \"Bench\" , $P$19:$U$21 ) ) ) +\n (ISNUMBER( SEARCH( \"Press\" ; $P$19:$U$21 ) ) ) ;\n V19:V21 * $W$19:$W$21 ;\n 0 ) )\n\n+SUM( IF(\n (ISNUMBER( SEARCH( \"Bench\" , $P$29:$U$31 ) ) ) +\n (ISNUMBER( SEARCH( \"Press\" , $P$29:$U$31 ) ) ) ;\n V29:V31 * $W$29:$W$31 ,\n 0 ) )\n\n+SUM( IF(\n (ISNUMBER( SEARCH( \"Bench\" , $P$39:$U$41 ) ) ) +\n (ISNUMBER( SEARCH( \"Press\" , $P$39:$U$41 ) ) ) ;\n V39:V41 * $W$39:$W$41;\n 0 ) )\n"
},
{
"answer_id": 74492079,
"author": "Scott Craner",
"author_id": 4851590,
"author_profile": "https://Stackoverflow.com/users/4851590",
"pm_score": 3,
"selected": true,
"text": "=SUMPRODUCT(\n (ISNUMBER(MATCH(MODE(ROW($P$9:$U$41),10);{9;0;1};0)))*\n ((ISNUMBER(SEARCH(\"Bench\";$P$9:$U$41)))+\n (ISNUMBER(SEARCH(\"Press\";$P$9:$U$41))));\n $V$9:$V$41;\n $W$9:$W$41)\n"
},
{
"answer_id": 74492314,
"author": "P.b",
"author_id": 12634230,
"author_profile": "https://Stackoverflow.com/users/12634230",
"pm_score": 2,
"selected": false,
"text": "LET"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19017948/"
] |
74,484,112
|
<p>I'm really new to ruby and tbh even programming. I'm trying to use the following code in order to perform the same operation for multiple flavors as follows using a switch case -</p>
<pre><code>def Icecream
...
...
Value = case flavors
when 'STRAWBERRY'
(shop.straw * 1000).round(5)
when 'CHOCOLATE'
(shop.choc * 1000).round(5)
when 'VANILLA'
(shop.van * 1000).round(5)
when 'MANGO'
(shop.man * 1000).round(5)
end
...
...
end
</code></pre>
<p>How can I create a helper method to reduce the code duplication? This maybe a silly question but would be really helpful for learning. Thanks in advance!</p>
<p>So, shop.straw gets me a double value which I'm multiplying with 1000 and rounding.</p>
|
[
{
"answer_id": 74484149,
"author": "moyeradon",
"author_id": 4400698,
"author_profile": "https://Stackoverflow.com/users/4400698",
"pm_score": 2,
"selected": false,
"text": "def calculation(flavor)\n (flavor * 1000).round(5)\nend\n"
},
{
"answer_id": 74484677,
"author": "SMAG",
"author_id": 7573223,
"author_profile": "https://Stackoverflow.com/users/7573223",
"pm_score": 2,
"selected": false,
"text": "value = calculation(shop.flavor_value(flavor))\n"
},
{
"answer_id": 74485102,
"author": "spickermann",
"author_id": 2483313,
"author_profile": "https://Stackoverflow.com/users/2483313",
"pm_score": 2,
"selected": false,
"text": "FLAVORS = { \n 'STRAWBERRY' => :straw, 'CHOCOLATE' => :choc, 'VANILLA' => :van, 'MANGO' => :man \n}.freeze\n\ndef do_math(flavor)\n (flavor * 1000).round(5)\nend\n"
},
{
"answer_id": 74497087,
"author": "ggorlen",
"author_id": 6243352,
"author_profile": "https://Stackoverflow.com/users/6243352",
"pm_score": 0,
"selected": false,
"text": "public_send"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400359/"
] |
74,484,150
|
<p>I have a nested dictionary that looks like this:</p>
<pre><code>test_dict = {'header1_1': {'header2_1': {'header3_1': {'header4_1': ['322.5', 330.0, -0.28],
'header4_2': ['322.5', 332.5, -0.26]},
'header3_2': {'header4_1': ['285.0', 277.5, -0.09],
'header4_2': ['287.5', 277.5, -0.12]}},
'header2_2': {'header3_1': {'header4_1': ['345.0', 357.5, -0.14],
'header4_2': ['345.0', 362.5, -0.14]},
'header3_2': {'header4_1': ['257.5', 245.0, -0.1],
'header4_2': ['257.5', 240.0, -0.08]}}}}
</code></pre>
<p>There are 4 levels of headers, and each level can have multiple values, e.g., header1_1, header1_2. And once you specify a combination of these headers, you have a list containing 3 values.</p>
<p>I want to get this into a dataframe, so I create a reformed dictionary:</p>
<pre><code>reformed_dict = {}
for outerKey, innerDict in test_dict.items():
for innerKey, innerDict2 in innerDict.items():
for innerKey2, innerDict3 in innerDict2.items():
for innerKey3, values in innerDict3.items():
reformed_dict[(outerKey,
innerKey, innerKey2, innerKey3)] = values
reformed_dict
</code></pre>
<p>And the reformed dictionary looks like:<br />
{('header1_1', 'header2_1', 'header3_1', 'header4_1'): ['322.5', 330.0, -0.28],<br />
('header1_1', 'header2_1', 'header3_1', 'header4_2'): ['322.5', 332.5, -0.26],<br />
('header1_1', 'header2_1', 'header3_2', 'header4_1'): ['285.0', 277.5, -0.09],<br />
('header1_1', 'header2_1', 'header3_2', 'header4_2'): ['287.5', 277.5, -0.12],<br />
('header1_1', 'header2_2', 'header3_1', 'header4_1'): ['345.0', 357.5, -0.14],<br />
('header1_1', 'header2_2', 'header3_1', 'header4_2'): ['345.0', 362.5, -0.14],<br />
('header1_1', 'header2_2', 'header3_2', 'header4_1'): ['257.5', 245.0, -0.1],<br />
('header1_1', 'header2_2', 'header3_2', 'header4_2'): ['257.5', 240.0, -0.08]}</p>
<p>Throw that into a dataframe:</p>
<pre><code>df = pandas.DataFrame(reformed_dict)
</code></pre>
<p>And it looks like:<br />
header1_1<br />
header2_1 header2_2<br />
header3_1 header3_2 header3_1 header3_2<br />
header4_1 header4_2 header4_1 header4_2 header4_1 header4_2 header4_1 header4_2<br />
0 322.5 322.5 285.0 287.5 345.0 345.0 257.5 257.5<br />
1 330.0 332.5 277.5 277.5 357.5 362.5 245.0 240.0<br />
2 -0.28 -0.26 -0.09 -0.12 -0.14 -0.14 -0.1 -0.08</p>
<p>What I'd like to do is have all the column headers be row headers, and have 3 columns for each combination of headers and I'd name the columns Val1, Val2, Val3.</p>
<p>So I use df.stack() to push the column headers into the rows:</p>
<pre><code>df_1 = df.stack(level=0)
df_2 = df_1.stack(level=0)
df_3 = df_2.stack(level=0)
df_4 = df_3.stack(level=0)
print(df_4)
</code></pre>
<p>The result is:<br />
header1_1 header2_1 header3_1 header4_1 322.5<br />
header4_2 322.5<br />
header3_2 header4_1 285.0<br />
header4_2 287.5<br />
header2_2 header3_1 header4_1 345.0<br />
header4_2 345.0<br />
header3_2 header4_1 257.5<br />
header4_2 257.5<br />
1 header1_1 header2_1 header3_1 header4_1 330.0<br />
header4_2 332.5<br />
header3_2 header4_1 277.5<br />
header4_2 277.5<br />
header2_2 header3_1 header4_1 357.5<br />
header4_2 362.5<br />
header3_2 header4_1 245.0<br />
header4_2 240.0<br />
2 header1_1 header2_1 header3_1 header4_1 -0.28<br />
header4_2 -0.26<br />
header3_2 header4_1 -0.09<br />
header4_2 -0.12<br />
header2_2 header3_1 header4_1 -0.14<br />
header4_2 -0.14<br />
header3_2 header4_1 -0.1<br />
header4_2 -0.08</p>
<p>This isn't the layout I was looking for, as I want the 3 values in each list to be on the same row, similar to how they are in the reformed dictionary.</p>
<p>How can I accomplish this?</p>
|
[
{
"answer_id": 74484790,
"author": "Claudio",
"author_id": 7711283,
"author_profile": "https://Stackoverflow.com/users/7711283",
"pm_score": 1,
"selected": false,
"text": "test_dict = \\\n{'header1_1': {'header2_1': {'header3_1': {'header4_1': ['322.5', 330.0, -0.28],\n 'header4_2': ['322.5', 332.5, -0.26]},\n 'header3_2': {'header4_1': ['285.0', 277.5, -0.09],\n 'header4_2': ['287.5', 277.5, -0.12]}},\n 'header2_2': {'header3_1': {'header4_1': ['345.0', 357.5, -0.14],\n 'header4_2': ['345.0', 362.5, -0.14]},\n 'header3_2': {'header4_1': ['257.5', 245.0, -0.10],\n 'header4_2': ['257.5', 240.0, -0.08]}}}}\n#from pprint import pprint\n#pprint(test_dict)\n\nfrom collections import defaultdict\nimport pandas as pd\ndct_N = defaultdict(list)\ntotal_rows = 0\ndef fillDataFrameDict(dct, level=0):\n global dct_N, total_rows\n for key, value in dct.items():\n if not isinstance(value, dict):\n dct_N[f'headerNo_{level+1}'].append(key)\n total_rows += 1 \n dct_N['body'].append(value)\n for key_N, value_N in dct_N.items():\n dct_N[key_N] = value_N + (total_rows-len(value_N))*[value_N[-1]]\n else: \n dct_N[f'headerNo_{level+1}'].append(key)\n fillDataFrameDict(value, level+1)\n\nfillDataFrameDict(test_dict)\ndf = pd.DataFrame(dct_N)\nprint(df) \n"
},
{
"answer_id": 74484843,
"author": "Azhar Khan",
"author_id": 2847330,
"author_profile": "https://Stackoverflow.com/users/2847330",
"pm_score": 3,
"selected": true,
"text": "keys = reformed_dict.keys()\nindex = pd.MultiIndex.from_tuples(keys, names=[\"header1\", \"header2\", \"header3\", \"header4\"])\n\nvalues = [reformed_dict[k] for k in keys]\n\ndf = pd.DataFrame(data=values, index=index)\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6467736/"
] |
74,484,169
|
<p>Working on a hacker rank challenge and feel like I really hacked it. Need to select the second lowest members of a list, and return both if there's a tie. Here's what I did:</p>
<pre><code>if __name__ == '__main__':
names = []
scores = []
names_scores = []
for _ in range(int(input())):
name = input()
score = float(input())
names.append(name)
scores.append(score)
names_scores.append([name, score])
def second_smallest(numbers):
m1 = m2 = float('inf')
for x in numbers:
if x <= m1:
m1, m2 = x, m1
elif x < m2:
m2 = x
return m2
second_smallest_number = second_smallest(set(scores))
second_lowest_name_score = filter(lambda x: x[1] == second_smallest_number, names_scores)
second_lowest_names = [item[0] for item in second_lowest_name_score]
second_lowest_names.sort()
if len(second_lowest_names) == 1:
print(second_lowest_names[0])
else:
print(second_lowest_names[0] + "\n" + second_lowest_names[1])
</code></pre>
<p>My issue with this is that even though I "passed" I'd have to write a new line of the if statement for every number of ties. I would like to know a way that this would be extensible no matter the nubmer of ties. I understanding I could <code>pandas</code> <code>rank()</code> but wondering how to do this with the standard library</p>
|
[
{
"answer_id": 74484223,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 2,
"selected": true,
"text": "itertools.groupby"
},
{
"answer_id": 74534500,
"author": "Ben G",
"author_id": 9492720,
"author_profile": "https://Stackoverflow.com/users/9492720",
"pm_score": 0,
"selected": false,
"text": "if __name__ == '__main__':\n scores = []\n names_scores = []\n for _ in range(int(input())):\n name = input()\n score = float(input())\n scores.append(score)\n names_scores.append([name, score])\n\nfrom collections import Counter\n\nscores = sorted(Counter(scores).items())\n\nsecond_lowest_score = scores[1][0]\n\nnames = sorted([name_score[0] for name_score in names_scores if name_score[1] == second_lowest_score])\n\nprint(\"\\n\".join(names))\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9492720/"
] |
74,484,190
|
<p>To get variance in each strata in a sampling process, at least 2 elements are needed for each strata. I need to "collapse" (add the records of stratum 3 to those of some other stratum) stratum 3 with some other. If by default in these cases it is requested that such strata be collapsed with the one above it (in this case the first strata would collapse with the last one if necessary), then:</p>
<p>Is there a way to do this collapse in SQL?</p>
<p>Can I bring the first table to the second?</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th><strong>Strata</strong></th>
<th><strong>Frequency</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>6</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
</tr>
<tr>
<td>4</td>
<td>10</td>
</tr>
</tbody>
</table>
</div><div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th><strong>Strata</strong></th>
<th><strong>Frequency</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>7</td>
</tr>
<tr>
<td>4</td>
<td>10</td>
</tr>
</tbody>
</table>
</div>
<p>I will appreciate your answers very much.</p>
<p>I have a suspicion that I can use "analytic functions", particularly something along the lines of "ROWS BETWEEN 1 AND PRECEDING AND 1 FOLLOWING" together with "IF" to identify rows that have fewer than 2 records, but I've run into complications.</p>
|
[
{
"answer_id": 74484223,
"author": "Samwise",
"author_id": 3799759,
"author_profile": "https://Stackoverflow.com/users/3799759",
"pm_score": 2,
"selected": true,
"text": "itertools.groupby"
},
{
"answer_id": 74534500,
"author": "Ben G",
"author_id": 9492720,
"author_profile": "https://Stackoverflow.com/users/9492720",
"pm_score": 0,
"selected": false,
"text": "if __name__ == '__main__':\n scores = []\n names_scores = []\n for _ in range(int(input())):\n name = input()\n score = float(input())\n scores.append(score)\n names_scores.append([name, score])\n\nfrom collections import Counter\n\nscores = sorted(Counter(scores).items())\n\nsecond_lowest_score = scores[1][0]\n\nnames = sorted([name_score[0] for name_score in names_scores if name_score[1] == second_lowest_score])\n\nprint(\"\\n\".join(names))\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535391/"
] |
74,484,230
|
<p>I am currently learning to use golang as a server side language. I'm learning how to handle forms, and so I wanted to see how I could prevent some malicious client from sending a very large (in the case of a form with <code>multipart/form-data</code>) file and causing the server to run out of memory. For now this is my code which I found in a question here on stackoverflow:</p>
<pre><code>part, _ := ioutil.ReadAll(io.LimitReader(r.Body, 8388608))
r.Body = ioutil.NopCloser(io.MultiReader(bytes.NewReader(part), r.Body))
</code></pre>
<p>In my code <code>r</code> is equal to <code>*http.Request</code>. So, I think that code works well, but what happens is that when I send a file regardless of its size (according to my code, the maximum size is 8M) my code still receives the entire file, so I have doubts that my code actually works. So my question is. Does my code really work wrong? Is there a concept that I am missing and that is why I think my code is malfunctioning? How can I limit the size of an http request correctly?</p>
<h2>Update</h2>
<p>I tried to run the code that was shown in the answers, I mean, this code:</p>
<pre><code>part, _ := ioutil.ReadAll(io.LimitReader(r.Body, 8388608))
r.Body = ioutil.NopCloser(bytes.NewReader(part))
</code></pre>
<p>But when I run that code, and when I send a file larger than 8M I get this message from my web browser:</p>
<blockquote>
<p>The connection was reset</p>
<p>The connection to the server was reset while the page was loading.</p>
</blockquote>
<p>How can I solve that? How can I read only 8M maximum but without getting that error?</p>
|
[
{
"answer_id": 74484347,
"author": "Deltics",
"author_id": 123487,
"author_profile": "https://Stackoverflow.com/users/123487",
"pm_score": 2,
"selected": false,
"text": "ContentLength"
},
{
"answer_id": 74484550,
"author": "Erwin Bolwidt",
"author_id": 981744,
"author_profile": "https://Stackoverflow.com/users/981744",
"pm_score": 1,
"selected": false,
"text": "r.Body = ioutil.NopCloser(io.MultiReader(bytes.NewReader(part), r.Body))\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535504/"
] |
74,484,255
|
<p>I had a problem when I wanted to retrieve data to be displayed on the client, but after I checked again it turned out that the API response was in the form of an object, not an array or list.
so how can i access that data based on the 1,2,3... numbers in the data.
I have discussed with the back end to convert it into an array but they are hesitant to change it, so like it or not I have to take the initiative myself.</p>
<pre><code>{
"status": "success",
"code": "200",
"data": {
"1": {
"id": "f732bbb0-a34a-474d-8829-23aa66470e22",
"id_dosen": "d6aedfb6-cf88-4e89-8365-0f206822a6c4",
"id_mk": "cb0bced5-a02d-4f46-bd88-6ed61daece10",
"nidn": null,
"dosen": "Yudhy",
"id_kelas_kuliah": "52deb32d-292f-44b9-af69-a90dfc5fbc81",
"kelas_kuliah": "Pendidikan agama islam III - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 2,
"jumlah_kelas": 0,
"matakuliah": "Pendidikan agama islam III ( Islamic Religious Education III ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 2,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-09 08:14:14",
"updated_at": "2022-09-09 08:14:14",
"created_by": "Fahmi Nugraha",
"updated_by": "Fahmi Nugraha"
},
"2": {
"id": "3573bcf8-bf00-445b-91bb-8362e98f3e70",
"id_dosen": "d61b7164-cd6c-4bd9-8be8-d2a576790b9c",
"id_mk": "40f02349-887d-47c2-b190-9c5d62adf738",
"nidn": null,
"dosen": "Shadam Hussaeni",
"id_kelas_kuliah": "fb969bb3-e0d9-47ac-9ede-365c78e38994",
"kelas_kuliah": "Bahasa inggris III (Conversation) - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 2,
"jumlah_kelas": 0,
"matakuliah": "Bahasa inggris III (Conversation) ( English III (Conversation) ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 2,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-14 08:05:31",
"updated_at": "2022-09-14 08:05:31",
"created_by": "Risca Nurzantika",
"updated_by": "Risca Nurzantika"
},
"3": {
"id": "a12ad665-fc91-44d7-816d-605f51bdcfd7",
"id_dosen": "e6579b08-7cb0-4ea4-84cb-2f92f8d91d6b",
"id_mk": "45868d7c-6bcd-4420-9fe7-b60f44e805ce",
"nidn": null,
"dosen": "Dr. Partono",
"id_kelas_kuliah": "5fc85fb1-3057-4d68-af29-b22a5e18eaa2",
"kelas_kuliah": "Enterprise resource planning(ERP) - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 3,
"jumlah_kelas": 0,
"matakuliah": "Enterprise resource planning(ERP) ( Enterprise resource planning(ERP) ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 3,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-09 08:06:04",
"updated_at": "2022-09-09 08:06:04",
"created_by": "Fahmi Nugraha",
"updated_by": "Fahmi Nugraha"
},
"4": {
"id": "0926b6ac-61fa-4309-bca8-f2deaec22ee6",
"id_dosen": "dbe7f609-109c-4eb8-be0f-6621461346cb",
"id_mk": "6bcfc248-b1ff-45da-867e-c4f8ce108e3f",
"nidn": null,
"dosen": "Nano Suyatna",
"id_kelas_kuliah": "8479b48f-de14-499d-9898-43d12b0b29e9",
"kelas_kuliah": "Kontrol dan audit sistem informasi - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 3,
"jumlah_kelas": 0,
"matakuliah": "Kontrol dan audit sistem informasi ( Information system control and audit ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 3,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-09 08:06:24",
"updated_at": "2022-09-09 08:06:24",
"created_by": "Fahmi Nugraha",
"updated_by": "Fahmi Nugraha"
},
"5": {
"id": "6128d722-2589-4010-a3fe-236876594ba0",
"id_dosen": "818e059f-4aeb-4c8a-be54-0aece61fb675",
"id_mk": "1f5cee4f-6543-4067-abf2-88faec0b8163",
"nidn": null,
"dosen": "Nova Indrayana Yusman",
"id_kelas_kuliah": "258c9976-2657-4dae-9239-2b2b2528c4ae",
"kelas_kuliah": "Statistik komputasi - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 2,
"jumlah_kelas": 0,
"matakuliah": "Statistik komputasi ( Computational statistics ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 2,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-09 08:06:36",
"updated_at": "2022-09-09 08:06:36",
"created_by": "Fahmi Nugraha",
"updated_by": "Fahmi Nugraha"
},
"6": {
"id": "f928be12-c79d-4519-a10d-a2870e379a57",
"id_dosen": "7329769a-0310-453b-8e4e-5befedd774af",
"id_mk": "b03740f2-a141-44c3-891d-a46750b94d01",
"nidn": null,
"dosen": "Topan Trianto",
"id_kelas_kuliah": "20279853-74b7-4e0a-8f13-8c1a3b8675fe",
"kelas_kuliah": "Pemrograman Mobile 2 - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 2,
"jumlah_kelas": 0,
"matakuliah": "Pemrograman Mobile 2 ( Mobile programming 2 ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 2,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-09 08:06:51",
"updated_at": "2022-09-09 08:06:51",
"created_by": "Fahmi Nugraha",
"updated_by": "Fahmi Nugraha"
},
"7": {
"id": "b332e62b-20b7-4041-87cf-b1b2aa9402b5",
"id_dosen": "57510709-b25b-4b44-abcd-d4c238585daa",
"id_mk": "66cb1b6d-7c92-4303-a40e-6fc33c650633",
"nidn": null,
"dosen": "Yudi Sarip Aripin",
"id_kelas_kuliah": "31e6dbc5-9096-4210-b6c0-969cd6c1616f",
"kelas_kuliah": "Rekayasa sistem informasi - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 3,
"jumlah_kelas": 0,
"matakuliah": "Rekayasa sistem informasi ( Information systems engineering ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 3,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-09 08:12:55",
"updated_at": "2022-09-09 08:12:55",
"created_by": "Fahmi Nugraha",
"updated_by": "Fahmi Nugraha"
},
"8": {
"id": "8fea865a-ffd8-4fbb-bce4-58a6c4c28032",
"id_dosen": "986fab04-4da2-4fdd-8a5c-54f704ff990c",
"id_mk": "3cdc9ff5-8ca3-4bd9-88f6-84c2f1b3d608",
"nidn": null,
"dosen": "Usup Supendi",
"id_kelas_kuliah": "f26dd9ae-0aa6-42bf-9441-ba5a9afdd024",
"kelas_kuliah": "Testing & implementasi sistem informasi - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 3,
"jumlah_kelas": 0,
"matakuliah": "Testing & implementasi sistem informasi ( Information system testing & implementation ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 3,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-09 08:12:26",
"updated_at": "2022-09-09 08:12:26",
"created_by": "Fahmi Nugraha",
"updated_by": "Fahmi Nugraha"
},
"9": {
"id": "632152dc-2e65-4b22-8f4d-57448672d4ba",
"id_dosen": "58b5e16c-1c78-4a15-8366-23163d9b0c71",
"id_mk": "94a5f157-7c2d-4c58-9f84-8b391fb3e3c6",
"nidn": null,
"dosen": "M. Furqon",
"id_kelas_kuliah": "9c924a24-e73f-4768-9035-0faa625f224c",
"kelas_kuliah": "KPAM V (Korespondesi) - Sistem Informasi - A",
"prodi": "Sistem Informasi",
"kelas": "KARYAWAN",
"semester": "5",
"kelompok_kelas": "A",
"kode": null,
"sks": 1,
"jumlah_kelas": 0,
"matakuliah": "KPAM V (Korespondesi) ( KPAM V (Correspondence) ) - A",
"smt": "2022-2023 GANJIL",
"bobot_sks": 1,
"rencana_pertemuan": 14,
"jenis_evaluasi": "KOGNITIF/PENGETAHUAN",
"created_at": "2022-09-09 08:07:37",
"updated_at": "2022-09-09 08:07:37",
"created_by": "Fahmi Nugraha",
"updated_by": "Fahmi Nugraha"
}
}
}
</code></pre>
|
[
{
"answer_id": 74484432,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https://Stackoverflow.com/users/18670641",
"pm_score": 0,
"selected": false,
"text": "data"
},
{
"answer_id": 74484487,
"author": "Soliev",
"author_id": 19945688,
"author_profile": "https://Stackoverflow.com/users/19945688",
"pm_score": 0,
"selected": false,
"text": "var response = jsonDecode(apiResponse);\n\nList<YourDartObject> list = [];\nMap<String, dynamic> paketMap = response['data']; \n\nfor (var e in paketMap.values) {\n list.add(Paket.fromJson(e));\n}\n"
},
{
"answer_id": 74484671,
"author": "Soliev",
"author_id": 19945688,
"author_profile": "https://Stackoverflow.com/users/19945688",
"pm_score": 2,
"selected": true,
"text": "Datum"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19132574/"
] |
74,484,281
|
<p>I am trying to get jquery to not include the header in the filter. For example if you type John the header disappears. I tried to use the not() but it is not working. One option is to start the <code>id="myTable"</code> at the tbody but the way I am rending the table I don't want 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-js lang-js prettyprint-override"><code>$(document).ready(function() {
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myTable tr:not('th')").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td,
th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<body>
<h2>Filterable Table</h2>
<p>Try first names, last names or emails:</p>
<input id="myInput" type="text" placeholder="Search..">
<br><br>
<table id="myTable">
<thead>
<tr> <th>Firstname</th> <th>Lastname</th> <th>Email</th>
</tr>
</thead>
<tr>
<td>John</td> <td>Doe</td> <td>john@example.com</td>
</tr>
<tr>
<td>Mary</td> <td>Moe</td> <td>mary@mail.com</td>
</tr>
<tr>
<td>July</td> <td>Dooley</td> <td>july@greatstuff.com</td>
</tr>
<tr>
<td>Anja</td> <td>Ravendale</td> <td>a_r@test.com</td>
</tr>
</table>
</body></code></pre>
</div>
</div>
</p>
|
[
{
"answer_id": 74484337,
"author": "redz0323",
"author_id": 9589439,
"author_profile": "https://Stackoverflow.com/users/9589439",
"pm_score": 2,
"selected": true,
"text": "$(\"#myTable tbody tr\").filter(function() {\n $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)\n});\n"
},
{
"answer_id": 74484528,
"author": "4b0",
"author_id": 965146,
"author_profile": "https://Stackoverflow.com/users/965146",
"pm_score": 2,
"selected": false,
"text": ":has"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5091720/"
] |
74,484,283
|
<p>I would like to refactor a recursive tree-printing function I wrote so that the root node, the first call, is not indented at all.</p>
<pre class="lang-py prettyprint-override"><code>Tree = dict[str, 'Tree']
def print_tree(tree: Tree, prefix: str=''):
if not tree:
return
markers = [('├── ', '│ '), ('└── ', ' ')]
children = list(tree.items())
for key, subtree in children:
is_last_child = (key, subtree) == children[-1]
key_prefix, subtree_prefix = markers[is_last_child]
print(prefix + key_prefix + key)
print_tree(subtree, prefix + subtree_prefix)
tree = {'.': {'alpha':{}, 'beta': {'beta.alpha':{}, 'beta.beta':{}}, 'charlie': {'charlie.alpha':{}, 'charlie.beta':{}, 'charlie.charlie':{}}, 'delta':{}}}
print_tree(tree)
</code></pre>
<p>Current output is</p>
<pre><code>└── .
├── alpha
├── beta
│ ├── beta.alpha
│ └── beta.beta
├── charlie
│ ├── charlie.alpha
│ ├── charlie.beta
│ └── charlie.charlie
└── delta
</code></pre>
<p>But I would like the output to be</p>
<pre><code>.
├── alpha
├── beta
│ ├── beta.alpha
│ └── beta.beta
├── charlie
│ ├── charlie.alpha
│ ├── charlie.beta
│ └── charlie.charlie
└── delta
</code></pre>
<p>I can't think of a way to do it elegantly, as in without special-casing the first call like this:</p>
<pre class="lang-py prettyprint-override"><code>def print_tree(tree: Tree, prefix: str='', root: bool=True):
if not tree:
return
markers = [('├── ', '│ '), ('└── ', ' ')]
if root:
markers = [('', ''), ('', '')]
children = list(tree.items())
for key, subtree in children:
is_last_child = (key, subtree) == children[-1]
key_prefix, subtree_prefix = markers[is_last_child]
print(prefix + key_prefix + key)
print_tree(subtree, prefix + subtree_prefix, root=False)
</code></pre>
<p>How can I change the way I'm recursing to accomplish this? I don't want to add an extra argument to the function or otherwise require more information about state. I like how simple my current function is, it just prefixes the first level when I don't really want it to.</p>
|
[
{
"answer_id": 74484940,
"author": "Mandera",
"author_id": 3936044,
"author_profile": "https://Stackoverflow.com/users/3936044",
"pm_score": 1,
"selected": false,
"text": "Tree = dict[str, 'Tree']\ndef print_tree(tree: Tree, prefix: str=None):\n markers = [('├── ', '│ '), ('└── ', ' '), ('', '')]\n for i, (key, subtree) in enumerate(tree.items()):\n is_last_child = i == len(tree) - 1\n marker_index = 2 if prefix is None else is_last_child\n prefix = prefix or \"\"\n key_prefix, subtree_prefix = markers[marker_index]\n print(prefix + key_prefix + key)\n print_tree(subtree, prefix + subtree_prefix)\n\ntree = {'.': {'alpha':{}, 'beta': {'beta.alpha':{}, 'beta.beta':{}}, 'charlie': {'charlie.alpha':{}, 'charlie.beta':{}, 'charlie.charlie':{}}, 'delta':{}}}\nprint_tree(tree)\n"
},
{
"answer_id": 74485228,
"author": "JL Peyret",
"author_id": 1394353,
"author_profile": "https://Stackoverflow.com/users/1394353",
"pm_score": 0,
"selected": false,
"text": "Tree = dict[str, 'Tree']\ndef print_tree(tree: Tree, prefix: str='',level=0):\n # level starts out at zero....\n if not tree:\n return\n markers = [('├── ', '│ '), ('└── ', ' ')]\n children = list(tree.items())\n for key, subtree in children:\n is_last_child = (key, subtree) == children[-1]\n key_prefix, subtree_prefix = markers[is_last_child]\n\n #only if on level 1+\n if level:\n #hack to avoid the extra blanks on the left\n print((prefix + key_prefix + key).lstrip())\n print_tree(subtree, prefix + subtree_prefix,level=level+1)\n\n\ntree = {'.': {'alpha':{}, 'beta': {'beta.alpha':{}, 'beta.beta':{}}, 'charlie': {'charlie.alpha':{}, 'charlie.beta':{}, 'charlie.charlie':{}}, 'delta':{}}}\n\n\nprint_tree(tree)\n\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3310334/"
] |
74,484,286
|
<p>How do I remove an element from a JavaScript object by ID?
For instance I have to remove 004 or 007:</p>
<pre><code>const obj = {
id: '001',
children: [
{
id: '002',
children: [
{
id: '003',
children: [],
},
{
id: '004',
children: [
{
id: '005',
children: [],
}
],
}
],
},
{
id: '006',
children: [
{
id: '007',
children: [],
}
],
},
]
}
</code></pre>
<p>i am trying to like this, find id but what should be next. It is expected to remove id from the object.</p>
<pre><code>const removeById = (obj = {}, id = '') => {
console.log('obj: ', obj)
const search = obj.children.find(o => o.id === id)
console.log('##search: ', search)
if(search) {
console.log('## parent id: ', obj.id)
...
}
if (obj.children && obj.children.length > 0) {
obj.children.forEach(el => removeById(el, id));
}
}
removeById(obj, '007')
</code></pre>
|
[
{
"answer_id": 74484940,
"author": "Mandera",
"author_id": 3936044,
"author_profile": "https://Stackoverflow.com/users/3936044",
"pm_score": 1,
"selected": false,
"text": "Tree = dict[str, 'Tree']\ndef print_tree(tree: Tree, prefix: str=None):\n markers = [('├── ', '│ '), ('└── ', ' '), ('', '')]\n for i, (key, subtree) in enumerate(tree.items()):\n is_last_child = i == len(tree) - 1\n marker_index = 2 if prefix is None else is_last_child\n prefix = prefix or \"\"\n key_prefix, subtree_prefix = markers[marker_index]\n print(prefix + key_prefix + key)\n print_tree(subtree, prefix + subtree_prefix)\n\ntree = {'.': {'alpha':{}, 'beta': {'beta.alpha':{}, 'beta.beta':{}}, 'charlie': {'charlie.alpha':{}, 'charlie.beta':{}, 'charlie.charlie':{}}, 'delta':{}}}\nprint_tree(tree)\n"
},
{
"answer_id": 74485228,
"author": "JL Peyret",
"author_id": 1394353,
"author_profile": "https://Stackoverflow.com/users/1394353",
"pm_score": 0,
"selected": false,
"text": "Tree = dict[str, 'Tree']\ndef print_tree(tree: Tree, prefix: str='',level=0):\n # level starts out at zero....\n if not tree:\n return\n markers = [('├── ', '│ '), ('└── ', ' ')]\n children = list(tree.items())\n for key, subtree in children:\n is_last_child = (key, subtree) == children[-1]\n key_prefix, subtree_prefix = markers[is_last_child]\n\n #only if on level 1+\n if level:\n #hack to avoid the extra blanks on the left\n print((prefix + key_prefix + key).lstrip())\n print_tree(subtree, prefix + subtree_prefix,level=level+1)\n\n\ntree = {'.': {'alpha':{}, 'beta': {'beta.alpha':{}, 'beta.beta':{}}, 'charlie': {'charlie.alpha':{}, 'charlie.beta':{}, 'charlie.charlie':{}}, 'delta':{}}}\n\n\nprint_tree(tree)\n\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11020843/"
] |
74,484,318
|
<p>I feel like this is a question that would have already been asked somewhere, but I can't find much on it.</p>
<p>When using a variable for the purpose of updating the UI, when/why would we use <code>@State</code> within our view as opposed to using <code>@Published</code> within a ViewModel?</p>
<p>This is in the context of me trying to grasp MVVM architecture. I understand the difference generally, just not when it comes to something that both could easily accomplish the same way.</p>
<p>Below, I have 2 examples that do the same thing, but one uses <code>@State</code> while the other uses <code>@Published</code> and a ViewModel. Is one approach better than the other (for updating the UI purposes?)</p>
<p><code>@State</code> example:</p>
<pre><code>struct MyView: View {
@State var backgroundIsRed = false
var body: some View {
ZStack {
if backgroundIsRed {
Color.red
} else {
Color.green
}
}
.onTapGesture { backgroundIsRed.toggle() }
}
}
</code></pre>
<p><code>@Published</code> example:</p>
<pre><code>class ViewModel: ObservableObject {
@Published var backgroundIsRed = false
}
struct MyView: View {
@StateObject var viewModel = ViewModel()
var body: some View {
ZStack {
if viewModel.backgroundIsRed {
Color.red
} else {
Color.green
}
}
.onTapGesture { viewModel.backgroundIsRed.toggle() }
}
}
</code></pre>
|
[
{
"answer_id": 74487642,
"author": "Jorge Poveda",
"author_id": 18557672,
"author_profile": "https://Stackoverflow.com/users/18557672",
"pm_score": 2,
"selected": false,
"text": "protocol ViewModelProtocol {\n var backgroundIsRed: Bool { get }\n var date: Date { get } // Created for example purposes\n}\n"
},
{
"answer_id": 74491981,
"author": "malhal",
"author_id": 259521,
"author_profile": "https://Stackoverflow.com/users/259521",
"pm_score": 1,
"selected": false,
"text": "View"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14063245/"
] |
74,484,322
|
<p>I want to call <code>df['item'].value_counts()</code> and, with minimal manipulation, end up with a dataframe with columns <code>item</code> and <code>count</code>.</p>
<p>I can do something like this:</p>
<pre><code>df['item'].value_counts().reset_index().rename(columns={"item":"count", "index": "item"})
</code></pre>
<p>... which is fine but I'm like 95% sure there is a cleaner way to do this by passing a variable to <code>reset_index</code> or something similar</p>
|
[
{
"answer_id": 74484344,
"author": "Ian Thompson",
"author_id": 6509519,
"author_profile": "https://Stackoverflow.com/users/6509519",
"pm_score": 1,
"selected": false,
"text": "groupby"
},
{
"answer_id": 74484354,
"author": "BENY",
"author_id": 7964527,
"author_profile": "https://Stackoverflow.com/users/7964527",
"pm_score": 2,
"selected": false,
"text": "groupby"
},
{
"answer_id": 74484397,
"author": "piedpiper",
"author_id": 8576801,
"author_profile": "https://Stackoverflow.com/users/8576801",
"pm_score": 2,
"selected": false,
"text": "df['item'].value_counts().reset_index().set_axis(['item','count'], axis=1)\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8162603/"
] |
74,484,372
|
<p>In SQL Server (2018 I think? I don't know how to tell) my variable isn't working in <code>WHERE</code> clauses for <code>NVARCHAR.</code> The comparison should return values but it returns nothing. If I just type the declared text in manually it suddenly works and returns values. There's no logical reason this should be any different, the types are both NVARCHARS. It is working for dates and numbers for me.</p>
<p>The following SQL Server code works properly and returns results:</p>
<pre><code>SELECT * FROM table WHERE Column = 'text'
</code></pre>
<p>The following code fails however by coming up empty when I use an initial declare statement:</p>
<pre><code>DECLARE @Class AS NVARCHAR = 'text'
SELECT * FROM table WHERE Column = @Class
</code></pre>
<p>I can't get the variable to work in the <code>WHERE</code> clause even though I have confirmed that column is an <code>NVARCHAR</code>. Other parameters I'm declaring work just fine it just seems to be <code>NVARCHAR</code> giving me issues.</p>
<p>Is there something I'm missing?</p>
|
[
{
"answer_id": 74484415,
"author": "Dai",
"author_id": 159145,
"author_profile": "https://Stackoverflow.com/users/159145",
"pm_score": 3,
"selected": true,
"text": "DECLARE @Class AS NVARCHAR = 'text';\n"
},
{
"answer_id": 74484441,
"author": "Gary",
"author_id": 20535668,
"author_profile": "https://Stackoverflow.com/users/20535668",
"pm_score": 0,
"selected": false,
"text": "nvarchar"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16980140/"
] |
74,484,400
|
<p><a href="https://i.stack.imgur.com/ZmarR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZmarR.png" alt="enter image description here" /></a></p>
<p>How to show square on any digit in flutter UI like above example?</p>
|
[
{
"answer_id": 74484466,
"author": "zionpi",
"author_id": 1066501,
"author_profile": "https://Stackoverflow.com/users/1066501",
"pm_score": 2,
"selected": false,
"text": "flutter_tex"
},
{
"answer_id": 74484467,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https://Stackoverflow.com/users/18670641",
"pm_score": 0,
"selected": false,
"text": "FontFeatures"
},
{
"answer_id": 74484497,
"author": "Roslan Amir",
"author_id": 3365667,
"author_profile": "https://Stackoverflow.com/users/3365667",
"pm_score": 2,
"selected": false,
"text": "\\u00b2"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10135062/"
] |
74,484,411
|
<p>I have to tables looks like following:</p>
<p><strong>Table T1</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ColumnA</th>
<th>ColumnB</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>A</td>
<td>3</td>
</tr>
<tr>
<td>B</td>
<td>1</td>
</tr>
<tr>
<td>C</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
<p><strong>Table T2</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ColumnA</th>
<th>ColumnB</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>1</td>
</tr>
<tr>
<td>A</td>
<td>4</td>
</tr>
<tr>
<td>B</td>
<td>1</td>
</tr>
<tr>
<td>D</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
<p>in SQL I will do following query to check the existence of each record</p>
<pre><code>select
COALESCE(T1.ColumnA,T2.ColumnA) as ColumnA
,T1.ColumnB as ExistT1
,T2.ColumnB as ExistT2
from T1
full join T2 on
T1.ColumnA=T2.ColumnA
and T1.ColumnB=T2.ColumnB
where
(T1.ColumnA is null or T2.ColumnA is null)
</code></pre>
<p>I have tried many way in Pandas like concate, join, merge, etc, but it seems that the two merge keys would be combined into one.
I think the problem is that I want to check is not 'data columns' but 'key columns'.
Is there any good idea to do this in Python? Thanks!</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ColumnA</th>
<th>ExistT1</th>
<th>ExistT2</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>3</td>
<td>null</td>
</tr>
<tr>
<td>A</td>
<td>null</td>
<td>4</td>
</tr>
<tr>
<td>C</td>
<td>2</td>
<td>null</td>
</tr>
<tr>
<td>D</td>
<td>null</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
|
[
{
"answer_id": 74484545,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 0,
"selected": false,
"text": "(df1.assign(ExistT1=df1['ColumnB'])\n .merge(df2.assign(ExistT2=df2['ColumnB']), how='outer'))\n"
},
{
"answer_id": 74485090,
"author": "sammywemmy",
"author_id": 7175713,
"author_profile": "https://Stackoverflow.com/users/7175713",
"pm_score": 1,
"selected": false,
"text": "pd.merge"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535646/"
] |
74,484,416
|
<p>Suppose my dictionary contains > 100 elements and one or two elements have values different than other values; most values are the same (12 in the below example). How can I remove these a few elements?</p>
<pre><code>Diction = {1:12,2:12,3:23,4:12,5:12,6:12,7:12,8:2}
</code></pre>
<p>I want a dictionary object:</p>
<pre><code>Diction = {1:12,2:12,4:12,5:12,6:12,7:12}
</code></pre>
|
[
{
"answer_id": 74484545,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 0,
"selected": false,
"text": "(df1.assign(ExistT1=df1['ColumnB'])\n .merge(df2.assign(ExistT2=df2['ColumnB']), how='outer'))\n"
},
{
"answer_id": 74485090,
"author": "sammywemmy",
"author_id": 7175713,
"author_profile": "https://Stackoverflow.com/users/7175713",
"pm_score": 1,
"selected": false,
"text": "pd.merge"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7500268/"
] |
74,484,424
|
<p>I'm querying a dreambooth model from Hugging Face using the inference API and am getting a huge data response string back which starts with: <code>����çx00çx10JFIFçx00çx01çx01çx00çx00çx01çx0</code>...</p>
<p>Content-type is: image/jpeg</p>
<p>How do I decode this and display it as an image in javascript?</p>
|
[
{
"answer_id": 74484545,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 0,
"selected": false,
"text": "(df1.assign(ExistT1=df1['ColumnB'])\n .merge(df2.assign(ExistT2=df2['ColumnB']), how='outer'))\n"
},
{
"answer_id": 74485090,
"author": "sammywemmy",
"author_id": 7175713,
"author_profile": "https://Stackoverflow.com/users/7175713",
"pm_score": 1,
"selected": false,
"text": "pd.merge"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5651481/"
] |
74,484,426
|
<p>I am trying to turn <code>rectangle.style.width = "100px";</code> into a variable using parseInt so that I can place that variable into two buttons so I can either increase the width of my rectangle or decrease it. However I cant seem to get the information into the variable no matter what I do.</p>
<p>My two functions are very similar with the only diffrence being that one subtracts and the other adds.</p>
<pre><code>//does not work as supposed to
function shrinkBtn() {
myWidth= myWidth - 10 + "px";
//works but does not have the element as a variable
function shrinkBtn() {
rectangle.style.width = parseInt(rectangle.style.width)- 10+ "px";
}
</code></pre>
<p>I would have thought that this would have been super simple but I havent had any luck with any of answers I have found from previous posts or google searches.</p>
<p>I have tried a couple diffrent things when facing this issue. I have tried</p>
<pre><code>var myWidth = rectangle.style.width;
var myWidth = parseInt(rectangle.style.width);
</code></pre>
<p>I do get a output when I place it in a console log such as console.log(myWidth) however it doesnt seem to work when I try to put it in my other functions. I was expecting to be able to store the information into the variable and then place it in my function such as</p>
<pre><code>function shrinkBtn() {
myWidth = parseInt(myWidth) -10 + "px";
}
</code></pre>
<p>or</p>
<pre><code>function shrinkBtn() {
myWidth = myWidth - 10 + "px";
}
</code></pre>
<p>EDIT: added full code</p>
<pre><code>rectangle.style.width = "100px";
// rectangle.style.width = parseInt(rectangle.style.width)+ 10+ "px";
var myWidth = parseInt(rectangle.style.width);
console.log(myWidth);
decreaseBtn.addEventListener("click", shrinkBtn);
increaseBtn.addEventListener("click", growBtn);
function shrinkBtn() {
//using the variable here does not trigger the function
myWidth = parseInt(myWidth) -10 + "px";
//using this style below does trigger the function
// rectangle.style.width = parseInt(rectangle.style.width)- 10+ "px";
}
function growBtn() {
//Original function without the variable to show comparison This works
rectangle.style.width = parseInt(rectangle.style.width)+ 10+ "px";
}
</code></pre>
|
[
{
"answer_id": 74484545,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 0,
"selected": false,
"text": "(df1.assign(ExistT1=df1['ColumnB'])\n .merge(df2.assign(ExistT2=df2['ColumnB']), how='outer'))\n"
},
{
"answer_id": 74485090,
"author": "sammywemmy",
"author_id": 7175713,
"author_profile": "https://Stackoverflow.com/users/7175713",
"pm_score": 1,
"selected": false,
"text": "pd.merge"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13029581/"
] |
74,484,450
|
<p>I am trying to change a piece of styling on the footer that is present at all pages of the website. <strong>The changes must be present only on specific pages</strong>. <strong>Therefore, I need to somehow add a condition on what Routes the style should apply to the Footer.</strong> How do I do it?</p>
<p>Here is a structure of my code:</p>
<pre><code><Router>
<Switch>
<Route path="" component={} />
<Route path="" component={} />
<Route path="" component={} />
</Switch>
<Footer />
</Router>
</code></pre>
<p>I have tried useLocation hook. It would log the initial url I was in but not when I would change the page:</p>
<pre><code>const location = useLocation()
useEffect(() => {
console.log(location.pathname)
}, [location])
</code></pre>
<p>My logic is to have a state for style that I pass in as a prop to the footer and based on what Route I am on, the state would change:</p>
<pre><code>
***
const [style, setStyle] = useState(null)
***
***
<Footer style={style} />
</code></pre>
<p>Do you have any suggestions on how I could make this work?</p>
|
[
{
"answer_id": 74484532,
"author": "John Li",
"author_id": 20436957,
"author_profile": "https://Stackoverflow.com/users/20436957",
"pm_score": 0,
"selected": false,
"text": "pathname"
},
{
"answer_id": 74484568,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 1,
"selected": false,
"text": "useRouteMatch"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535674/"
] |
74,484,477
|
<p>I'm trying to get the latest file with a specific extension from a folder via FTP.
I'm using the following code to get the most recent file. But it gets the most recent file regardless of file extension.</p>
<pre><code>// new connect
$conn = ftp_connect('ftp.website.com');
ftp_login($conn, 'username', 'password');
// get list of files on given path
$files = ftp_nlist($conn, '/data');
$mostRecent = array(
'time' =\> 0,
'file' =\> null
);
foreach ($files as $file) {
// get the last modified time for the file
$time = ftp_mdtm($conn, $file);
if ($time > $mostRecent['time']) {
// this file is the most recent so far
$mostRecent['time'] = $time;
$mostRecent['file'] = $file;
}
}
ftp_get($conn, "/home/mywebsite/public_html/wp-content/uploads/data-zipped/target.zip", $mostRecent\['file'\], FTP_BINARY);
ftp_delete($conn, $mostRecent\['file'\]);
ftp_close($conn);
</code></pre>
<p>I would like to get specific files with specific extensions.</p>
<p>The files I want to get end with the following <code>filename.add.zip</code>. The filename changes daily. So it could be <code>file22.add.zip</code> <code>moredata.add.zip</code>. But the <code>add.zip</code> remains the same.</p>
<p>Unfortunately there are also files with the extension <code>filename.del.zip</code>. So it can't just be .zip it needs to be <code>add.zip</code>.</p>
<p>So via FTP, I want to pickup the most recent file ending in <code>add.zip</code>.</p>
<p>Anyone have a solution? The code that I currently us only picks up the most recent file. Regardless of the file extension.</p>
|
[
{
"answer_id": 74484548,
"author": "Anggara",
"author_id": 12196486,
"author_profile": "https://Stackoverflow.com/users/12196486",
"pm_score": 0,
"selected": false,
"text": "*.add.zip"
},
{
"answer_id": 74486169,
"author": "Martin Prikryl",
"author_id": 850848,
"author_profile": "https://Stackoverflow.com/users/850848",
"pm_score": 1,
"selected": false,
"text": "$files = ftp_nlist($conn, '/data/*.add.zip');\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14542184/"
] |
74,484,498
|
<p>I would like to get the position of columns with the same name (that is column A).</p>
<p>DataFrame a:</p>
<pre>
A B A C
text1 text3 text5 text7
text2 text4 text6 text8
</pre>
<p>I can get position of column A but how to get the position of the second column. There are multiple dataframe with different number of columns and position of A are not the same across the dataframes. Thank you.</p>
<pre><code>for col in a.columns:
if col == 'A':
indx1 = a.columns.get_loc(col)
#if second column A
indx2 = a.columns.get_loc(col)
</code></pre>
|
[
{
"answer_id": 74484629,
"author": "Krishnan Suresh",
"author_id": 19590758,
"author_profile": "https://Stackoverflow.com/users/19590758",
"pm_score": 0,
"selected": false,
"text": "res = []\nfor index, col in enumerate(a.columns):\n if col == 'A':\n res.append(index)\n\nprint(res)\n"
},
{
"answer_id": 74484630,
"author": "cosmic_inquiry",
"author_id": 8927098,
"author_profile": "https://Stackoverflow.com/users/8927098",
"pm_score": 0,
"selected": false,
"text": "indexes = [i for i, j in zip(range(len(df.columns)), df.columns) if j in df.loc[:, df.columns.value_counts() > 1].columns]\n"
},
{
"answer_id": 74484643,
"author": "KarelZe",
"author_id": 5755604,
"author_profile": "https://Stackoverflow.com/users/5755604",
"pm_score": 3,
"selected": true,
"text": "np.where()"
},
{
"answer_id": 74484660,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 0,
"selected": false,
"text": "np.where(df.columns == 'A')[0]\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12728204/"
] |
74,484,581
|
<p>I have a monad <code>m</code> that supports the following operation:</p>
<pre class="lang-hs prettyprint-override"><code>someName :: (t1 -> m u1) -> (t2 -> m u2) -> ((t1, t2) -> m (u1, u2))
</code></pre>
<p>In something more like English: given a mapping that could be used with <code>bind</code> to turn an <code>m t1</code> into <code>m u1</code> and another mapping for another pair of types, return such a mapping for pairs of the two types.</p>
<p><strong>Does this concept have a name?</strong> Is it well-defined for all monads? Only some? None, and I have my facts wrong for the one I'm working on?</p>
<hr />
<p>This is reminiscent of the <a href="https://stackoverflow.com/a/74286598/1505451"><code>traverse</code></a> operation on <code>Traversable</code>s, except there are two mappings involved. Plus, <code>traverse</code> for 2-tuples only seems to apply the mapping to the second element:</p>
<pre class="lang-hs prettyprint-override"><code>ghci> f a = Just (a + 1)
ghci> traverse f (0, 1)
Just (0,2)
ghci> traverse f ("Hello", 1)
Just ("Hello",2)
</code></pre>
|
[
{
"answer_id": 74484692,
"author": "bradrn",
"author_id": 7345298,
"author_profile": "https://Stackoverflow.com/users/7345298",
"pm_score": 3,
"selected": false,
"text": "someName :: Applicative m => (t1 -> m u1) -> (t2 -> m u2) -> ((t1, t2) -> m (u1, u2))\nsomeName f1 f2 = \\(t1, t2) -> (,) <$> f1 t1 <*> f2 t2\n"
},
{
"answer_id": 74484831,
"author": "Daniel Wagner",
"author_id": 791604,
"author_profile": "https://Stackoverflow.com/users/791604",
"pm_score": 4,
"selected": true,
"text": "bitraverse"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1505451/"
] |
74,484,591
|
<p>i don't understand hover really well, can someone tell me how to hover this footer properly? i want the text to glow with hover but instead the hover is glowing not only the text. there's also a problem with some logo's for the facebook etc. this is the code i tried. also can someone drop a link for the logo's? i think i lost the link n that's why the logo's wont appear.</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>body {
margin: 0;
overflow-x: hidden;
}
.footer {
background: #000;
padding: 30px 0px;
font-family: 'Play', sans-serif;
text-align: center;
}
.footer .row {
width: 100%;
margin: 1% 0%;
padding: 0.6% 0%;
color: gray;
font-size: 0.8em;
}
.footer .row a {
text-decoration: none;
color: gray;
transition: 0.5s;
}
.footer .row a:hover {
color: #fff;
}
.footer .row ul {
width: 100%;
}
.footer .row ul li {
display: inline-block;
margin: 0px 30px;
}
.footer .row a i {
font-size: 2em;
margin: 0% 1%;
}
@media (max-width:720px) {
.footer {
text-align: left;
padding: 5%;
}
.footer .row ul li {
display: block;
margin: 10px 0px;
text-align: left;
}
.footer .row a i {
margin: 0% 3%;
}
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><footer>
<div class="footer">
<div class="row">
<a href="#"><i class="fa fa-facebook"></i></a>
<a href="#"><i class="fa fa-instagram"></i></a>
<a href="#"><i class="fa fa-youtube"></i></a>
<a href="#"><i class="fa fa-twitter"></i></a>
</div>
<div class="row">
<ul>
<li><a href="#">Contact us</a></li>
<li><a href="#">Our Services</a></li>
<li><a href="#">Privacy Policy</a></li>
<li><a href="#">Terms & Conditions</a></li>
<li><a href="#">Career</a></li>
</ul>
</div>
<div class="row">
Company name || lorem
</div>
</div>
</footer></code></pre>
</div>
</div>
</p>
|
[
{
"answer_id": 74484692,
"author": "bradrn",
"author_id": 7345298,
"author_profile": "https://Stackoverflow.com/users/7345298",
"pm_score": 3,
"selected": false,
"text": "someName :: Applicative m => (t1 -> m u1) -> (t2 -> m u2) -> ((t1, t2) -> m (u1, u2))\nsomeName f1 f2 = \\(t1, t2) -> (,) <$> f1 t1 <*> f2 t2\n"
},
{
"answer_id": 74484831,
"author": "Daniel Wagner",
"author_id": 791604,
"author_profile": "https://Stackoverflow.com/users/791604",
"pm_score": 4,
"selected": true,
"text": "bitraverse"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20473729/"
] |
74,484,598
|
<p>I have a <strong>Trip</strong> model in ruby which has <strong>start_at</strong> column and i need to get <strong>Trip</strong> object if <strong>start_at</strong> less than 1 hour or 3 hour (only i should get trip object when <strong>start_at</strong> is < 1hr or < 3hr not for < 2hr, < 4hr, ..... etc).</p>
<p>Note: I have <strong>Cron</strong> job which runs for every 15.minutes to get <strong>trip</strong> object as explained above.</p>
<p>Example: Assume i have a trip which start_at = 9:00 am and current time is 10:00 am i should get that trip object. Same goes for 3 hour also (start_at = 9:00 am and current time is 12:00 am)</p>
<p>^^ Except above two cases i should not get trip object, need to get only for less than 1hr or 3hr</p>
<p><strong>This is what i tried</strong></p>
<pre><code>Trip.where("start_at < ? ", 1.hour.ago)
</code></pre>
<p>But above query returning trip object even if start_at < 2 hours ago, 4 hours ago, ..... blah blah</p>
<p>I am new to Ruby any help would be appreciated.
Thanks!</p>
|
[
{
"answer_id": 74484857,
"author": "eux",
"author_id": 15097028,
"author_profile": "https://Stackoverflow.com/users/15097028",
"pm_score": -1,
"selected": false,
"text": "Trip.where(start_at: [2.hours.ago..1.hour.ago, 4.hours.ago..3.hour.ago])\n"
},
{
"answer_id": 74484903,
"author": "Lee Drum",
"author_id": 17457026,
"author_profile": "https://Stackoverflow.com/users/17457026",
"pm_score": 0,
"selected": false,
"text": "Trip.where(start_at: 2.hours.ago..1.hour.ago).or(Trip.where(start_at: 4.hours.ago..3.hour.ago))\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13071662/"
] |
74,484,631
|
<p>I have two beans in my application configuration. I would like to enable only one bean based on property, Can we make bean conditional based on property ?</p>
<p>Ex: Let say if I have this property <code>enable.userconnection: true</code>, I would like to create <code>UserCredentialsConnectionFactoryAdapter</code> bean. If I set that value to <code>false</code>. I would like to enable <code>CachingConnectionFactory</code> bean.</p>
<pre><code>@Bean
public CachingConnectionFactory connectionFactory(
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setTargetConnectionFactory(axonConnectionFactory);
connectionFactory.setReconnectOnException(true);
connectionFactory.setSessionCacheSize(jmsSessionCacheSize);
return connectionFactory;
}
@Bean
public UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter()
throws Exception {
UserCredentialsConnectionFactoryAdapter connectionFactoryAdapter =
new UserCredentialsConnectionFactoryAdapter();
connectionFactoryAdapter.setUsername(getUsername());
connectionFactoryAdapter.setPassword(getPassword());
connectionFactoryAdapter.setTargetConnectionFactory(
messagingJMSService().getConnectionFactory(getName()));
return connectionFactoryAdapter;
}
</code></pre>
<p>I tried this way, which works fine based on the profile. But, I would like to apply similar logic making use of property.</p>
<pre><code>@ConditionalOnExpression("#{!environment.getProperty('spring.profiles.active').contains('a') && !environment.getProperty('spring.profiles.active').contains('b')}")
</code></pre>
|
[
{
"answer_id": 74484857,
"author": "eux",
"author_id": 15097028,
"author_profile": "https://Stackoverflow.com/users/15097028",
"pm_score": -1,
"selected": false,
"text": "Trip.where(start_at: [2.hours.ago..1.hour.ago, 4.hours.ago..3.hour.ago])\n"
},
{
"answer_id": 74484903,
"author": "Lee Drum",
"author_id": 17457026,
"author_profile": "https://Stackoverflow.com/users/17457026",
"pm_score": 0,
"selected": false,
"text": "Trip.where(start_at: 2.hours.ago..1.hour.ago).or(Trip.where(start_at: 4.hours.ago..3.hour.ago))\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12047466/"
] |
74,484,653
|
<p>After updating to Android Gradle Plugin 7.3.1 Android Studio says that <code>package</code> is deprecated in <code>AndroidManifest.xml</code> and I need to use <code>namespace</code> param in <code>build.gradle.kts</code>. I removed the <code>package</code> attribute in all my android manifests (I'm using additional manifest files for debug and release builds) and have done this:</p>
<pre><code>build.gradle.kts
android {
...
applicationId = "org.sample.appid"
...
namespace = "org.sample.packageid"
...
}
</code></pre>
<p>After this I can not build the project because of the error:</p>
<pre><code>D:\Desktop\Sample\app\src\debug\AndroidManifest.xml:4:5
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : Attribute manifest@package value=(org.sample.packageid) from AndroidManifest.xml:4:5-35
is also present at AndroidManifest.xml:2:1-102:12 value=(org.sample.appid).
Attributes of <manifest> elements are not merged.
</code></pre>
<p>Debug manifest can not be merged with the main manifest, but why package name is mixed with applicationId while merging? Is there anything that must be additionally configured? Or there's a bug with AGP 7.3.1?</p>
|
[
{
"answer_id": 74484857,
"author": "eux",
"author_id": 15097028,
"author_profile": "https://Stackoverflow.com/users/15097028",
"pm_score": -1,
"selected": false,
"text": "Trip.where(start_at: [2.hours.ago..1.hour.ago, 4.hours.ago..3.hour.ago])\n"
},
{
"answer_id": 74484903,
"author": "Lee Drum",
"author_id": 17457026,
"author_profile": "https://Stackoverflow.com/users/17457026",
"pm_score": 0,
"selected": false,
"text": "Trip.where(start_at: 2.hours.ago..1.hour.ago).or(Trip.where(start_at: 4.hours.ago..3.hour.ago))\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3556590/"
] |
74,484,679
|
<p>I'm stuck in using R. In a simple linear regression;</p>
<pre><code>y=a+b_1*x
</code></pre>
<p>I wanna know how much increase or decrease when one standard deviation of Independent Variable increases in R.</p>
<p>Do you know the way how to do it by using sapply() syntax?</p>
|
[
{
"answer_id": 74484857,
"author": "eux",
"author_id": 15097028,
"author_profile": "https://Stackoverflow.com/users/15097028",
"pm_score": -1,
"selected": false,
"text": "Trip.where(start_at: [2.hours.ago..1.hour.ago, 4.hours.ago..3.hour.ago])\n"
},
{
"answer_id": 74484903,
"author": "Lee Drum",
"author_id": 17457026,
"author_profile": "https://Stackoverflow.com/users/17457026",
"pm_score": 0,
"selected": false,
"text": "Trip.where(start_at: 2.hours.ago..1.hour.ago).or(Trip.where(start_at: 4.hours.ago..3.hour.ago))\n"
}
] |
2022/11/18
|
[
"https://Stackoverflow.com/questions/74484679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20535928/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.