qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,369,322 | <p>When it first opened, it said:</p>
<pre><code>~ type :help nvim<Enter> if you are new!
~ type :checkhealth<Enter> to optimize Nvim
~ type :q<Enter> to exit
~ type :help<Enter> for help
</code></pre>
<p>But when I type <code>:q</code> <kbd>Enter</kbd> it just appears in the body?</p>
<p>How do you stop <code>nvim</code> without running <code>pkill nvim</code>?</p>
| [
{
"answer_id": 74369393,
"author": "dollar",
"author_id": 20166094,
"author_profile": "https://Stackoverflow.com/users/20166094",
"pm_score": 3,
"selected": true,
"text": "$(document).ready(function() {\n something();\n});\n\nfunction something() {\n var newTh = \"\";\n var th = $(`#tblTable th[data-something=\"1\"]`).last();\n var index = th.index();\n newTh = `<th data-something=\"1-1\">New Column</th>`;\n\n th.after(newTh);\n\n $(\"#tblBody\").find(\"tr\").each(function(){\n var tr = $(this);\n tr.find(\"td\").eq(index).after(`<td>new column value</td>`);\n });\n}"
},
{
"answer_id": 74369394,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 0,
"selected": false,
"text": "<td>"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6310966/"
] |
74,369,324 | <p>I am trying to integrate traefik ingress route with middleware (forward-auth) for wss (secure websocket protocol).
For https requests ingressRoute works fine with forward-auth,
but for wss its not reaching to forward-auth, it's bypassing the middleware.</p>
<p>Tried many ingressRoutes with different pathprefix so that it can route to specific middleware which will forward to helidon app for authentication.
I am trying to setup ForwardAuth for wss incoming requests in traefik Ingress, but it's forwarding/bypassing to actual server without reaching to middleware, same thing works fine for usual https calls.</p>
<p>My websocket url: wss://ip:443/ws/guest</p>
<p>How to fix wss traffic for ingressRoute?</p>
<p>IngressRoute.yaml</p>
<pre><code>apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
annotations:
kubernetes.io/ingress.class: traefik
name: traefik-tls
namespace: sample-domain1-ns
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: PathPrefix(`/ws`)
middlewares:
- name: test-auth-tls
namespace: sample-domain1-ns
services:
- kind: Service
name: sample-domain1-cluster
port: 8001
tls:
certResolver: default
</code></pre>
<p>forward-auth.yaml</p>
<pre><code>apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-auth-tls
namespace: sample-domain1-ns
spec:
headers:
customRequestHeaders:
X-Forwarded-Proto: https
forwardAuth:
address: https://sample-domain1-lb.sample-domain1-ns.svc.cluster.local:8080/auth
tls:
insecureSkipVerify: true
</code></pre>
| [
{
"answer_id": 74369393,
"author": "dollar",
"author_id": 20166094,
"author_profile": "https://Stackoverflow.com/users/20166094",
"pm_score": 3,
"selected": true,
"text": "$(document).ready(function() {\n something();\n});\n\nfunction something() {\n var newTh = \"\";\n var th = $(`#tblTable th[data-something=\"1\"]`).last();\n var index = th.index();\n newTh = `<th data-something=\"1-1\">New Column</th>`;\n\n th.after(newTh);\n\n $(\"#tblBody\").find(\"tr\").each(function(){\n var tr = $(this);\n tr.find(\"td\").eq(index).after(`<td>new column value</td>`);\n });\n}"
},
{
"answer_id": 74369394,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 0,
"selected": false,
"text": "<td>"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19684021/"
] |
74,369,368 | <p>Can anyone please help on below requirement, how to implement.</p>
<p>When I click on radio buttons with keyboard up and down arrows it is moving up and down normally .</p>
<p>But I need ,when we click on propulsion button and then if I press down arrow radio button should go to off.
And when we are on off, if we press up arrow rado button should go to propulsion.<a href="https://i.stack.imgur.com/vhkOu.jpg" rel="nofollow noreferrer">enter image description here</a></p>
| [
{
"answer_id": 74372706,
"author": "Xic",
"author_id": 19160987,
"author_profile": "https://Stackoverflow.com/users/19160987",
"pm_score": 0,
"selected": false,
"text": " Column {\n Label {\n text: qsTr(\"Radio:\")\n }\n\n RadioButton {\n id: test1\n checked: true\n text: qsTr(\"DAB\")\n KeyNavigation.down: test2\n KeyNavigation.up: test3\n }\n\n RadioButton {\n id:test2\n text: qsTr(\"FM\")\n KeyNavigation.down: test3\n KeyNavigation.up: test1\n }\n\n RadioButton {\n id:test3\n text: qsTr(\"AM\")\n KeyNavigation.down: test1\n KeyNavigation.up: test2\n }\n}\n"
},
{
"answer_id": 74401781,
"author": "Srikanth Reddy",
"author_id": 19682752,
"author_profile": "https://Stackoverflow.com/users/19682752",
"pm_score": 1,
"selected": false,
"text": "Implemented the above using below code\n\nbool MainWindow::eventFilter(QObject *obj, QEvent *event)\n{\n if(obj == ui->mGbPowerModes)\n {\n if(event->type() == QEvent::KeyPress)\n {\n QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);\n\n if(keyEvent->key() == Qt::Key_Up)\n {\n if(ui->mBtnOff->isChecked())\n {\n on_mBtnPropulsion_clicked();\n ui->mBtnPropulsion->setFocus();\n ui->mBtnPropulsion->setChecked(true);\n }\n return true;\n }\n else if(keyEvent->key() == Qt::Key_Down)\n {\n if(ui->mBtnPropulsion->isChecked())\n {\n on_mBtnOff_clicked();\n ui->mBtnOff->setFocus();\n ui->mBtnOff->setChecked(true);\n }\n return true;\n }\n }\n return false;\n }\n return MainWindow::eventFilter(obj, event);\n}\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19682752/"
] |
74,369,415 | <p>How I call other other functions from a helper file that isn't a component?
I have multiple components using the same 3 functions but the 3 functions are all dependent on a dom event/event listener and requires the "this" to be passed down to other functions.</p>
<p>Do I need to create a functional component to hold these additional functions? What is the correct to call them?</p>
<p>NewItem.js</p>
<pre><code>import React, { Component } from 'react'
import {funcA} from 'SomeHelper'
class NewItem extends Component {
constructor(props) {
super(props);
}
render() {
return(
<div>{funcA(userName, obj)}</div>
)
}
}
</code></pre>
<p>SomeHelper.js</p>
<pre><code>export const funcA(userName, obj) => {
return console.log( funcB(userName, obj), funcCalculate(obj) )
}
funcB(userName, obj) => {
return "Hello World" + userName;
}
funcCalculate(obj) {
let value = 1 + 1;
//insert some code here.
return value;
}
</code></pre>
| [
{
"answer_id": 74372706,
"author": "Xic",
"author_id": 19160987,
"author_profile": "https://Stackoverflow.com/users/19160987",
"pm_score": 0,
"selected": false,
"text": " Column {\n Label {\n text: qsTr(\"Radio:\")\n }\n\n RadioButton {\n id: test1\n checked: true\n text: qsTr(\"DAB\")\n KeyNavigation.down: test2\n KeyNavigation.up: test3\n }\n\n RadioButton {\n id:test2\n text: qsTr(\"FM\")\n KeyNavigation.down: test3\n KeyNavigation.up: test1\n }\n\n RadioButton {\n id:test3\n text: qsTr(\"AM\")\n KeyNavigation.down: test1\n KeyNavigation.up: test2\n }\n}\n"
},
{
"answer_id": 74401781,
"author": "Srikanth Reddy",
"author_id": 19682752,
"author_profile": "https://Stackoverflow.com/users/19682752",
"pm_score": 1,
"selected": false,
"text": "Implemented the above using below code\n\nbool MainWindow::eventFilter(QObject *obj, QEvent *event)\n{\n if(obj == ui->mGbPowerModes)\n {\n if(event->type() == QEvent::KeyPress)\n {\n QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);\n\n if(keyEvent->key() == Qt::Key_Up)\n {\n if(ui->mBtnOff->isChecked())\n {\n on_mBtnPropulsion_clicked();\n ui->mBtnPropulsion->setFocus();\n ui->mBtnPropulsion->setChecked(true);\n }\n return true;\n }\n else if(keyEvent->key() == Qt::Key_Down)\n {\n if(ui->mBtnPropulsion->isChecked())\n {\n on_mBtnOff_clicked();\n ui->mBtnOff->setFocus();\n ui->mBtnOff->setChecked(true);\n }\n return true;\n }\n }\n return false;\n }\n return MainWindow::eventFilter(obj, event);\n}\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11576275/"
] |
74,369,426 | <p>I have the following CSS and need to programmatically update it after clicking a button but I cannot figure out how.</p>
<p>This is the initial CSS</p>
<pre><code>.hoverable:hover {
color: red;
}
</code></pre>
<p>I need the class to have the following CSS after clicking the button.</p>
<pre><code>.hoverable:hover {
color: blue;
}
</code></pre>
| [
{
"answer_id": 74369447,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 0,
"selected": false,
"text": "document.querySelectorAll()"
},
{
"answer_id": 74369506,
"author": "kennarddh",
"author_id": 14813577,
"author_profile": "https://Stackoverflow.com/users/14813577",
"pm_score": 2,
"selected": false,
"text": "pseudo-class"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5957242/"
] |
74,369,453 | <p>So, I'm moving from Wix to Neocities. And I can't really just take the pages from Wix and paste them into Neocities, so I need to remake a few things by hand now.
I already asked google about this and got this as an answer:
<a href="https://stackoverflow.com/questions/48474/how-do-i-position-one-image-on-top-of-another-in-html">How do I position one image on top of another in HTML?</a>
Which, for only TWO images works, sort of fine, aside from the fact that it literally just breaks if I add align="center" to the div.
It also just... doesn't really allow me to put more than the first two on top?</p>
<p>Here's the full code in the page:</p>
<pre><code><title>Work in progress...</title>
<link rel="icon" type="image/x-icon" href="/pages/images/favicons/main.png">
<link rel="stylesheet" type="text/css" href="/style.css">
<!-- CSS and div to make the site logo look the same as the Wix version, modified from https://stackoverflow.com/questions/48474/how-do-i-position-one-image-on-top-of-another-in-html
I might just put this into the main style.css, not sure.-->
<style>
.logo {
position: relative;
top: 0;
left: 0;
}
.image1 {
position: relative;
top: 0;
left: 0;
}
.image2 {
position: relative;
top: 0;
left: 0;
}
.image3 {
position: absolute;
top: 0px;
left: 0px;
}
</style>
<div class="logo">
<img class="image1" src="/pages/images/general/logo/1.gif" />
<img class="image2" src="/pages/images/general/logo/2.gif" />
<img class="image3" src="/pages/images/general/logo/3.gif" />
</div>
</code></pre>
<p>Since this stupid dumb site needs me to have 10 rep to even post images, you'll just have to take these links instead. At least I don't have to break the links like on GBATemp back when I was new there. I get that it's to prevent spam, but isn't there a better way?</p>
<p>Expected result:
<a href="https://i.stack.imgur.com/suFVh.png" rel="nofollow noreferrer">https://i.stack.imgur.com/suFVh.png</a></p>
<p>Actual result:
<a href="https://i.stack.imgur.com/suXC7.png" rel="nofollow noreferrer">https://i.stack.imgur.com/suXC7.png</a>
(screenshot left slightly uncropped to show that it's starting at the top-left of the page, not the absolute-regardless-of-window-size center like I want. plus the 3rd image (filename 3.gif) is completely outside of the div!)</p>
<p>I feel like a valve developer working on TF2. This shit doesn't work!! Why? Has I ever?
In all seriousness, I'm still new to CSS and just want to know what the hell is wrong because doing it the HTML way would be WAY WAY easier for me than the "just put them all into one gif" way.</p>
<p>What I want in the end is for the div to just control the position of all 3 images inside of it, so that I can just put align="center" into the div's opening tag and have it just work.</p>
<p>Oh, and I'll put a live preview of the site at <a href="https://catboybeebop.neocities.org/pages/main_new.html" rel="nofollow noreferrer">https://catboybeebop.neocities.org/pages/main_new.html</a>, so you guys can see this all in action to better help me through this.</p>
| [
{
"answer_id": 74369447,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 0,
"selected": false,
"text": "document.querySelectorAll()"
},
{
"answer_id": 74369506,
"author": "kennarddh",
"author_id": 14813577,
"author_profile": "https://Stackoverflow.com/users/14813577",
"pm_score": 2,
"selected": false,
"text": "pseudo-class"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12007351/"
] |
74,369,454 | <p>I have a dataset <code>df</code> that looks like this:</p>
<pre><code>ID Week VarA VarB VarC VarD
s001 w1 2 5 4 7
s001 w2 4 5 2 3
s001 w3 7 2 0 1
s002 w1 4 0 9 8
s002 w2 1 5 2 5
s002 w3 7 3 6 0
s001 w1 6 5 7 9
s003 w2 2 0 1 0
s003 w3 6 9 3 4
</code></pre>
<p>For each ID, I am trying to plot its progress by Week for all Var (VarB,VarC,VarD) with VarA as the reference data.</p>
<p>I do <code>df.melt()</code> and run coding below and it works.</p>
<pre><code>ID Week Var Value
s001 w1 VarA 2
s001 w2 VarA 4
s001 w3 VarA 7
s002 w1 VarA 4
s002 w2 VarA 1
s002 w3 VarA 7
s001 w1 VarA 6
s003 w2 VarA 2
s003 w3 VarA 6
s001 w1 VarB 5
s001 w2 VarB 5
...
</code></pre>
<p>Codes:</p>
<pre><code>for id in idlist:
#get VarA into new df
newdf= df_melt[df_melt.Var == 'VarA']
#remove rows with VarA so it won't be included in facet_wrap()
tmp = df_melt[df_melt.Var != 'VarA']
plot2 = ggplot() + ggtitle(id) + labs(x='Week',y="Value") \
+ geom_point(newdf[newdf['ID'] == id], aes(x='Week',y='Value')) \
+ geom_point(tmp[tmp['ID'] == id], aes(x='Week',y='Value',color='Var')) \
+ theme(axis_text_x=element_text(rotation=45))
print(plot2)
</code></pre>
<p>However, when I add <code>facet_wrap('Var', ncol=3,scales='free')</code> I get an error below</p>
<pre><code>IndexError: arrays used as indices must be of integer (or boolean) type
</code></pre>
<p>And also I couldn't connect the line using <code>geom_line()</code>.</p>
<p>This is my expected output:
<a href="https://i.stack.imgur.com/bTM9f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bTM9f.png" alt="enter image description here" /></a></p>
<p>Is this because of the different <code>df</code> used? Is there a way to use multiple <code>geom_point()</code> for different df and <code>facet_wrap</code> in one ggplot object?</p>
| [
{
"answer_id": 74412205,
"author": "has2k1",
"author_id": 832573,
"author_profile": "https://Stackoverflow.com/users/832573",
"pm_score": 3,
"selected": true,
"text": "import pandas as pd\nfrom plotnine import *\n\ndf1 = pd.DataFrame({\n 'x': list(\"abc\"),\n 'y': [1, 2, 3],\n 'g': list(\"AAA\")\n\n})\n\ndf2 = pd.DataFrame({\n 'x': list(\"abc\"),\n 'y': [4, 5, 6],\n 'g': list(\"AAB\")\n})\n\n(ggplot(aes(\"x\", \"y\"))\n + geom_point(df1)\n + geom_point(df2)\n + facet_wrap(\"g\", scales=\"free_x\")\n)\n"
},
{
"answer_id": 74427914,
"author": "kaixas K",
"author_id": 4738819,
"author_profile": "https://Stackoverflow.com/users/4738819",
"pm_score": 0,
"selected": false,
"text": "VarA"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4738819/"
] |
74,369,472 | <p>I have a file with the following text:</p>
<pre><code><div>
<b>a:</b> <a class='a' href='/a/1'>a1</a><br>
<b>b:</b> <a class='b' href='/b/2'>b2</a><br>
<b>c:</b> <a class='c' href='/c/3/'>c3</a><br>
<b>d:</b> "ef"<br><br><div class='start'>123
<br>ghij.
<br>klmn
<br><br><b>end</b>
</div>
</div>
</code></pre>
<p>I want to do the following:</p>
<ol>
<li>Whenever a line starts with <code><b>a:</b> <a class='a'</code>, I want to copy the text between the <code>></code> symbol after <code><a class='a'</code> and <code></a></code> — it must be stored in <code>a[1]</code>;</li>
<li>Similarly, whenever a line starts with <code><b>b:</b> <a class='b'</code>, I want to copy the text between the <code>></code> symbol after <code><a class='b'</code> and <code></a></code> — it must be stored in <code>b[1]</code>;</li>
<li>Whenever a line contains <code><div class='start'></code>, I want to create the variable <code>t</code> whose value starts with the text that occurs between <code><div class='start'></code> and the end of this line, then set <code>flag</code> to <code>1</code>;</li>
<li>If the value of <code>flag</code> is already <code>1</code> and the current line does not start with <code><br><br><b>end</b></code>, I want to append the current line to the current value of the variable <code>t</code> (using the space symbol as separator);</li>
<li>If the value of <code>flag</code> is already <code>1</code> and the current line starts with <code><br><br><b>end</b></code>, I want to concatenate three current values of <code>a[1]</code>, <code>b[1]</code> and <code>t</code> (using <code>;</code> as separator) and print the result to the output file, then set <code>flag</code> to <code>0</code>, then clear the variable <code>t</code>.</li>
</ol>
<p>I used the following code (for <code>gawk 4.0.1</code>):</p>
<pre><code>gawk 'BEGIN {flag = 0; t = ""; }
{
if ($0 ~ /^<b>a:<\/b> <a class=\x27a\x27/ ) {
match($0, /^<b>a:<\/b> <a class=\x27a\x27 href=\x27\/a\/[0-9]{1,}\x27>(.*)<\/a>/, a) };
if ($0 ~ /^<b>b:<\/b> <a class=\x27b\x27/ ) {
match($0, /^<b>b:<\/b> <a class=\x27b\x27 href=\x27\/b\/[0-9]{1,}\x27>(.*)<\/a>/, b) };
if ($0 ~ /<div class=\x27start\x27>/ ) {
match($0, /^.*<div class=\x27start\x27>(.*)$/, s);
t = s[1];
flag = 1 };
if (flag == 1) {
if ($0 ~ /^<br><br><b>end<\/b>/) {
str = a[1] ";" b[1] ";" t;
print(str) > "output.txt";
flag = 0; str = ""; t = "" }
else {
t = t " " $0 }
}
}' input.txt
</code></pre>
<p>I was expecting the following output:</p>
<pre><code>a1;b2;123 <br>ghij. <br>klmn
</code></pre>
<p>But the output is:</p>
<pre><code>;;123 <b>d:</b> "ef"<br><br><div class='start'>123 <br>ghij. <br>klmn
</code></pre>
<p>Why are <code>a[1]</code> and <code>b[1]</code> empty? Why does <code><b>d:</b> "ef"<br><br><div class='start'></code> occur in the output? How to fix the code to obtain the expected output?</p>
| [
{
"answer_id": 74369662,
"author": "glenn jackman",
"author_id": 7552,
"author_profile": "https://Stackoverflow.com/users/7552",
"pm_score": 0,
"selected": false,
"text": "$ echo aaaab | perl -nE '/a*(a+b)/ && say $1'\nab\n$ echo aaaab | perl -nE '/a*?(a+b)/ && say $1'\naaaab\n"
},
{
"answer_id": 74371821,
"author": "Daweo",
"author_id": 10785975,
"author_profile": "https://Stackoverflow.com/users/10785975",
"pm_score": 0,
"selected": false,
"text": "a[1]"
},
{
"answer_id": 74402254,
"author": "Ed Morton",
"author_id": 1745001,
"author_profile": "https://Stackoverflow.com/users/1745001",
"pm_score": 3,
"selected": true,
"text": "a[1]"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1736903/"
] |
74,369,480 | <p>I'm trying to understand this code, but I can't really make any sense of it. I only understand the <code>var numbers</code> and <code>var operators</code>.</p>
<p>What does the code inside the while loop mean? Especially the<br />
<code>number[divide] / numbers[divide + 1]</code></p>
<pre class="lang-js prettyprint-override"><code>var numbers = inputString.split(/\+|\-|\×|\÷/g);
var operators = inputString.replace(/[0-9]|\./g, "").split("");
resultBtn.addEventListener("click", function (e) {
var divide = operators.indexOf("÷");
while (divide != -1) {
numbers.splice(divide, 2, numbers[divide] / numbers[divide + 1]);
operators.splice(divide, 1);
divide = operators.indexOf("÷");
}
)}
</code></pre>
| [
{
"answer_id": 74369662,
"author": "glenn jackman",
"author_id": 7552,
"author_profile": "https://Stackoverflow.com/users/7552",
"pm_score": 0,
"selected": false,
"text": "$ echo aaaab | perl -nE '/a*(a+b)/ && say $1'\nab\n$ echo aaaab | perl -nE '/a*?(a+b)/ && say $1'\naaaab\n"
},
{
"answer_id": 74371821,
"author": "Daweo",
"author_id": 10785975,
"author_profile": "https://Stackoverflow.com/users/10785975",
"pm_score": 0,
"selected": false,
"text": "a[1]"
},
{
"answer_id": 74402254,
"author": "Ed Morton",
"author_id": 1745001,
"author_profile": "https://Stackoverflow.com/users/1745001",
"pm_score": 3,
"selected": true,
"text": "a[1]"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18314283/"
] |
74,369,486 | <p>In Solidity, given a Smart Contract instance named <code>foo</code></p>
<pre class="lang-js prettyprint-override"><code>MySmartContract foo = new MySmartContract()
</code></pre>
<p>I can get this Smart Contract instance's address by using <code>address(foo)</code></p>
<pre class="lang-js prettyprint-override"><code>address fooAdress = address(foo)
</code></pre>
<p>How do I get back <code>foo</code> object, given only its address <code>fooAdress</code>?</p>
<p>I expect something like:</p>
<pre class="lang-js prettyprint-override"><code>MySmartContract originalFoo = some_function_goes_here(fooAdress)
</code></pre>
| [
{
"answer_id": 74369690,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 3,
"selected": true,
"text": "interface InterfaceA {\n function count() external view returns (uint256);\n function increment() external;\n}\n"
},
{
"answer_id": 74403561,
"author": "Jeffrey",
"author_id": 2079806,
"author_profile": "https://Stackoverflow.com/users/2079806",
"pm_score": 0,
"selected": false,
"text": "some_function_goes_here"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11806050/"
] |
74,369,529 | <p>Lately I've been deep diving more about JS modules, Webpack, the difference between ES modules and CommonJS, and I came across the dynamic import topic. I was curious on how Webpack converts the dynamic <code>import()</code> statement and when I take a look at the generated bundled JS from webpack, turns out it loads the imported module by adding a <code><script></code> tag with <code>src</code> to it, and then removing it after the script has finished loading.</p>
<p>May I know why it is implemented this way? I thought we can use the <code>import()</code> statement right away as long as the entry script tag has the <code>type="module"</code>. Why does webpack need to convert it?</p>
| [
{
"answer_id": 74369690,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 3,
"selected": true,
"text": "interface InterfaceA {\n function count() external view returns (uint256);\n function increment() external;\n}\n"
},
{
"answer_id": 74403561,
"author": "Jeffrey",
"author_id": 2079806,
"author_profile": "https://Stackoverflow.com/users/2079806",
"pm_score": 0,
"selected": false,
"text": "some_function_goes_here"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13013820/"
] |
74,369,539 | <p>I have Text field which will take a long message from the user and I set <strong>expands</strong> to True</p>
<p>the problem is the hint text is not at the beginning of the the line, How do I change its position ?</p>
<p><a href="https://i.stack.imgur.com/xPqjg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xPqjg.png" alt="enter image description here" /></a></p>
<pre><code> SizedBox(
height: 150,
child: CustomTextField(
enabledRadius: 7,
focusedRadius: 7,
expands: true,
hintText: 'message',
controller: messageController,
textInputType: TextInputType.multiline,
),
),
</code></pre>
| [
{
"answer_id": 74369690,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 3,
"selected": true,
"text": "interface InterfaceA {\n function count() external view returns (uint256);\n function increment() external;\n}\n"
},
{
"answer_id": 74403561,
"author": "Jeffrey",
"author_id": 2079806,
"author_profile": "https://Stackoverflow.com/users/2079806",
"pm_score": 0,
"selected": false,
"text": "some_function_goes_here"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17733339/"
] |
74,369,542 | <p>I'm still trying to understand how to use JQ to get what I want. I want to get the size of all snapshots in my account older than a specific date and then add them up so that I can calculate cost. I am able to do this without the date filtering with this.</p>
<pre><code>aws ec2 describe-snapshots --profile my_profile_name | jq "[.Snapshots[].VolumeSize] | add"
</code></pre>
<p>This returns a numerical value. Without JQ, I'm also able to get a list of snapshots using "query" but I don't think that will be applied when using JQ but I could be wrong.</p>
<pre><code>aws ec2 describe-snapshots --profile my_profile_name --owner-ids self --query "Snapshots[?(StartTime<='2022-09-08')].[SnapshotId]"
</code></pre>
<p>I tried various arrangements using "select" along with my first example. However, I haven't been able to get anything returned yet. I appreciate any pointers.</p>
<p>This is the "select" that doesn't quite work.</p>
<pre><code>aws ec2 describe-snapshots --profile my_profile_name | jq "[.Snapshots[]select(.StartTime < "2022-09-08")] | [.Snapshots[].VolumeSize] | add"
</code></pre>
<p>Edit 11/15/22</p>
<p>I was able to make progress and I found a site that allows you to test JQ. The example is able to select strings and numbers, but I'm having trouble with the date part. I don't understand how to interrupt the date in the format that AWS provides. I can do the add part, I removed it to simplify the example.</p>
<p>This the the working "select" for a string. I can only do greater/less than when I use numbers and remove the quotes from the JSON section.</p>
<pre><code>.Snapshots[] | select(.StartTime == "2022-11-14T23:28:39+00:00") | .VolumeSize
</code></pre>
<p><a href="https://jqplay.org/s/b1JtVNpivw7" rel="nofollow noreferrer">jq play example</a></p>
| [
{
"answer_id": 74369690,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 3,
"selected": true,
"text": "interface InterfaceA {\n function count() external view returns (uint256);\n function increment() external;\n}\n"
},
{
"answer_id": 74403561,
"author": "Jeffrey",
"author_id": 2079806,
"author_profile": "https://Stackoverflow.com/users/2079806",
"pm_score": 0,
"selected": false,
"text": "some_function_goes_here"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3756981/"
] |
74,369,545 | <p>I have created a login screen with textformfield for email id and password using flutter. Also, I have added the validation to check these fields. The code is as below;</p>
<pre><code>import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
theme: ThemeData(
brightness: Brightness.dark,
),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
var _formKey = GlobalKey<FormState>();
var isLoading = false;
void _submit() {
final isValid = _formKey.currentState.validate();
if (!isValid) {
return;
}
_formKey.currentState.save();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Form Validation"),
leading: Icon(Icons.filter_vintage),
),
//body
body: Padding(
padding: const EdgeInsets.all(16.0),
//form
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
Text(
"Form-Validation In Flutter ",
style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold),
),
//styling
SizedBox(
height: MediaQuery.of(context).size.width * 0.1,
),
TextFormField(
decoration: InputDecoration(labelText: 'E-Mail'),
keyboardType: TextInputType.emailAddress,
onFieldSubmitted: (value) {
//Validator
},
validator: (value) {
if (value.isEmpty ||
!RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+")
.hasMatch(value)) {
return 'Enter a valid email!';
}
return null;
},
),
//box styling
SizedBox(
height: MediaQuery.of(context).size.width * 0.1,
),
//text input
TextFormField(
decoration: InputDecoration(labelText: 'Password'),
keyboardType: TextInputType.emailAddress,
onFieldSubmitted: (value) {},
obscureText: true,
validator: (value) {
if (value.isEmpty) {
return 'Enter a valid password!';
}
return null;
},
),
SizedBox(
height: MediaQuery.of(context).size.width * 0.1,
),
RaisedButton(
padding: EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 15.0,
),
child: Text(
"Submit",
style: TextStyle(
fontSize: 24.0,
),
),
onPressed: () => _submit(),
)
],
),
),
),
);
}
}
</code></pre>
<p>The issue I am facing is, I want to validate the fields as soon as the user starts typing the input(dynamically) rather than clicking on the submit button to wait for the validation to happen. I did a lot of research yet could not find a solution. Thanks in advance for any help!</p>
| [
{
"answer_id": 74369690,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 3,
"selected": true,
"text": "interface InterfaceA {\n function count() external view returns (uint256);\n function increment() external;\n}\n"
},
{
"answer_id": 74403561,
"author": "Jeffrey",
"author_id": 2079806,
"author_profile": "https://Stackoverflow.com/users/2079806",
"pm_score": 0,
"selected": false,
"text": "some_function_goes_here"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14400294/"
] |
74,369,582 | <p>Can anybody explain how Apollo serves both the Sandbox's html and the graphql query handler simultaneously on the same route endpoint?</p>
<p>SPECIFICALLY, What protocol(s), method(s), and how is the body content used? Is this all done via headers? Thanks for the semi-technical deep dive.</p>
| [
{
"answer_id": 74369690,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 3,
"selected": true,
"text": "interface InterfaceA {\n function count() external view returns (uint256);\n function increment() external;\n}\n"
},
{
"answer_id": 74403561,
"author": "Jeffrey",
"author_id": 2079806,
"author_profile": "https://Stackoverflow.com/users/2079806",
"pm_score": 0,
"selected": false,
"text": "some_function_goes_here"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5400055/"
] |
74,369,654 | <p>Could anyone help me understand this, i've tried investigating into an issue all day but can't seem to see much configuration choices on sonarcloud for it. I see online that sonarqube is being used I believe under the hood as version 8 and see online that I may need to update to 9. Does this seem like my issue or am I just going down a rabbit hole?</p>
<pre><code>Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project abovo: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore: Unable to load component interface org.sonar.scanner.scan.branch.BranchConfiguration: Could not find a default branch to fall back on.
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project abovo: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute (ScannerBootstrapper.java:67)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute (SonarQubeMojo.java:108)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.filesystem.InputComponentStore
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent (ComponentContainer.java:52)
at org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance (BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance (ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter (SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments (ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run (ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe (AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance (ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance (AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance (AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance (Stored.java:91)
at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable (DefaultPicoContainer.java:1034)
at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable (DefaultPicoContainer.java:1026)
at org.picocontainer.DefaultPicoContainer.startAdapters (DefaultPicoContainer.java:1003)
at org.picocontainer.DefaultPicoContainer.start (DefaultPicoContainer.java:767)
at org.sonar.core.platform.ComponentContainer.startComponents (ComponentContainer.java:122)
at org.sonar.core.platform.ComponentContainer.execute (ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart (GlobalContainer.java:130)
at org.sonar.core.platform.ComponentContainer.startComponents (ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute (ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute (Batch.java:58)
at org.sonar.batch.bootstrapper.Batch.execute (Batch.java:52)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute (BatchIsolatedLauncher.java:46)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke (IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy71.execute (Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute (EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute (EmbeddedScanner.java:138)
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute (ScannerBootstrapper.java:65)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute (SonarQubeMojo.java:108)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.IllegalStateException: Unable to load component interface org.sonar.scanner.scan.branch.BranchConfiguration
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent (ComponentContainer.java:52)
at org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance (BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance (ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter (SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments (ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run (ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe (AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance (ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance (AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance (AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance (Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance (DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent (ComponentContainer.java:50)
at org.picocontainer.DefaultPicoContainer.getComponent (DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance (BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance (ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter (SingleMemberInjector.java:78)
at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments (ConstructorInjector.java:309)
at org.picocontainer.injectors.ConstructorInjector$1.run (ConstructorInjector.java:335)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe (AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance (ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance (AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance (AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance (Stored.java:91)
at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable (DefaultPicoContainer.java:1034)
at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable (DefaultPicoContainer.java:1026)
at org.picocontainer.DefaultPicoContainer.startAdapters (DefaultPicoContainer.java:1003)
at org.picocontainer.DefaultPicoContainer.start (DefaultPicoContainer.java:767)
at org.sonar.core.platform.ComponentContainer.startComponents (ComponentContainer.java:122)
at org.sonar.core.platform.ComponentContainer.execute (ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart (GlobalContainer.java:130)
at org.sonar.core.platform.ComponentContainer.startComponents (ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute (ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute (Batch.java:58)
at org.sonar.batch.bootstrapper.Batch.execute (Batch.java:52)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute (BatchIsolatedLauncher.java:46)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke (IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy71.execute (Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute (EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute (EmbeddedScanner.java:138)
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute (ScannerBootstrapper.java:65)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute (SonarQubeMojo.java:108)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.sonar.api.utils.MessageException: Could not find a default branch to fall back on.
Error:
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.
</code></pre>
<p>Also I managed to find this as well, that also may be of help</p>
<pre><code>[INFO] 03:00:21.073 Load project branches
[DEBUG] 03:00:21.616 GET 404 https://sonarcloud.io/api/project_branches/list?project=abovo| time=542ms
[DEBUG] 03:00:21.617 Could not process project branches - continuing without it
[INFO] 03:00:21.617 Load project branches (done) | time=544ms
[INFO] 03:00:21.620 Check ALM binding of project 'abovo'
</code></pre>
| [
{
"answer_id": 74369690,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 3,
"selected": true,
"text": "interface InterfaceA {\n function count() external view returns (uint256);\n function increment() external;\n}\n"
},
{
"answer_id": 74403561,
"author": "Jeffrey",
"author_id": 2079806,
"author_profile": "https://Stackoverflow.com/users/2079806",
"pm_score": 0,
"selected": false,
"text": "some_function_goes_here"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2416223/"
] |
74,369,682 | <p>I'm working on a morse code conversion from morse code to english. I'm stuck on one part, I need to be able to add in space when 2 spaces appear in a row on the morse code, but i'm unsure how to do this. The Rule is, Each letter appears after a space in the morse code, each space appears after 2 spaces in the morse code. Problem Is I split the array using 1 space So I'm unsure how to find out when there's 2 spaces in a row.</p>
<pre><code>public static void main(String[] args) throws IOException {
InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
BufferedReader in = new BufferedReader(reader);
String line;
String newMorse = "";
String selectedMorse;
String convertedMorse;
int x = 0;
while ((line = in.readLine()) != null) {
String[] morseChars = line.split(" ");
for (int i = 0; i < morseChars.length; i++)
selectedMorse = morseChars[i];
convertedMorse = decode(selectedMorse);
newMorse = newMorse + convertedMorse;
}
System.out.println(newMorse);
}
}
}
</code></pre>
<p>Example input:
.- ...- ..--- .-- .... .. . -.-. -..-(two spaces)....- .....</p>
<p>Expected Output:
AV2WHIECX 45</p>
<p>I labelled where the two spaces would go to make it easy to see.</p>
| [
{
"answer_id": 74369690,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 3,
"selected": true,
"text": "interface InterfaceA {\n function count() external view returns (uint256);\n function increment() external;\n}\n"
},
{
"answer_id": 74403561,
"author": "Jeffrey",
"author_id": 2079806,
"author_profile": "https://Stackoverflow.com/users/2079806",
"pm_score": 0,
"selected": false,
"text": "some_function_goes_here"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20304864/"
] |
74,369,687 | <p>I am using below code to make my text content in single line and If exceeds limits displaying three dots as suffix of text:</p>
<pre><code>Container(
color: blackColorOP11,
width: 250.w,
child: Text(
"1234567890123kjhkjhgjsadadddah",
style: TextStyle(
fontWeight: FontWeight.w600,
fontFamily: "Poppins",
fontSize: 24.sp,
color: Colors.white),
softWrap: true,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
</code></pre>
<p>So It displays output for text widget as "<strong>1234567890123kjhkj...</strong>"
which is completely correct.</p>
<p>But The issue is If there is a space between this text content, for exampple like this:
"<code>1234 567890123kjhkjhgjsadadddah</code>", It just display "<strong>1234...</strong>"</p>
<p>It should display "1234 56789123kjhk..."</p>
<p>What might be the issue? Or How can I achive output as above? : <code>1234 56789123kjhk...</code></p>
| [
{
"answer_id": 74369723,
"author": "Jaimin Modi",
"author_id": 4827817,
"author_profile": "https://Stackoverflow.com/users/4827817",
"pm_score": 0,
"selected": false,
"text": "\"text content dummy\".toString().length>18?\n\"text content dummy\".toString().substring(0,18) + '...':\n\"text content dummy\".toString(),\n"
},
{
"answer_id": 74369806,
"author": "johnson",
"author_id": 8066029,
"author_profile": "https://Stackoverflow.com/users/8066029",
"pm_score": 2,
"selected": false,
"text": " \"1234567890123kjhkjhgjsadadddah\".toString().substring(0,17) + '...'\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4827817/"
] |
74,369,706 | <p>*New to Javascript</p>
<p>The code below is a section that changes the image source to the saved one.</p>
<p><strong>Desired result:</strong> When there is no source for the image I want to display a 'default.jpg' image.</p>
<p>Perhaps, is there another way to write this logic out as a simple(r) condition?</p>
<p>Attempt</p>
<pre class="lang-js prettyprint-override"><code> set_image({
image_data_url: items.image_data_url ?? "",
image_filename: items.image_filename ?? image.src = './assets/default.jpg',
});
</code></pre>
<p>Current</p>
<pre class="lang-js prettyprint-override"><code> set_image({
image_data_url: items.image_data_url ?? "",
image_filename: items.image_filename ?? "No Image",
});
</code></pre>
| [
{
"answer_id": 74369793,
"author": "ChanHyeok-Im",
"author_id": 6329353,
"author_profile": "https://Stackoverflow.com/users/6329353",
"pm_score": 2,
"selected": true,
"text": "set_image({\n image_data_url: items.image_data_url ?? \"\",\n image_filename: items.image_filename ?? './assets/default.jpg',\n});\n"
},
{
"answer_id": 74369966,
"author": "MAYUR SANCHETI",
"author_id": 12238257,
"author_profile": "https://Stackoverflow.com/users/12238257",
"pm_score": 0,
"selected": false,
"text": "<img id=\"currentPhoto\" src=\"https://www.ccrharrow.org/Images/content/953/741209.pg\" onerror=\"this.src='https://www.unesale.com/ProductImages/Large/notfound.png'\" alt=\"\">\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20435771/"
] |
74,369,755 | <p>Hey guys trying to attempt to create my own basic hockey analytic program. While trying to get all my information I gave been stumped by this error. Tried looking a bunch of things up and nothing seemed to work for me. I am new to using pandas and numpy. Any help would be much appreciated , thank you!!</p>
<pre><code>import numpy as np
nyr_sched = nhl2021_22_sched[(nhl2021_22_sched['home_team'] == 'NYR') | (nhl2021_22_sched['away_team'] == 'NYR')]
nyr_sched
for game in nyr_sched:
nyr_GID = nyr_sched['game_id']
nyr_GID = np.array(nyr_GID)
nyr_GID.tolist()
nyr_GID
</code></pre>
<p>Which prints <code>array([2021020004, 2021020011, 2021020023, 2021020035, 2021020059,...])</code></p>
<p>But I run into a problem here.</p>
<pre><code>for i in nyr_GID:
nyr_GID[i] = nyr_GID[i][5:]
print("Game {} ID is {}".format(i, nyr_GID[i]))
</code></pre>
<p>I am looking to remove the first 5 numbers from each ID in the list so instead of <code>202102004</code> it is <code>20004</code>.
However I get an error stating I am trying to access the <code>20212004</code> index. Here is the error:</p>
<pre><code>IndexError Traceback (most recent call last)
/var/folders/v8/z9h_xhmj1t38rzq1351q_my40000gn/T/ipykernel_13046/4170336391.py in <module>
1 count = 0
2 for i in nyr_GID:
----> 3 nyr_GID[i] = nyr_GID[i][5:]
4 print("Game {} ID is {}".format(i, nyr_GID[i]))
IndexError: index 2021020004 is out of bounds for axis 0 with size 82
</code></pre>
| [
{
"answer_id": 74369793,
"author": "ChanHyeok-Im",
"author_id": 6329353,
"author_profile": "https://Stackoverflow.com/users/6329353",
"pm_score": 2,
"selected": true,
"text": "set_image({\n image_data_url: items.image_data_url ?? \"\",\n image_filename: items.image_filename ?? './assets/default.jpg',\n});\n"
},
{
"answer_id": 74369966,
"author": "MAYUR SANCHETI",
"author_id": 12238257,
"author_profile": "https://Stackoverflow.com/users/12238257",
"pm_score": 0,
"selected": false,
"text": "<img id=\"currentPhoto\" src=\"https://www.ccrharrow.org/Images/content/953/741209.pg\" onerror=\"this.src='https://www.unesale.com/ProductImages/Large/notfound.png'\" alt=\"\">\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15263010/"
] |
74,369,769 | <p>Given input lists:</p>
<pre><code>L1 = [("A","p1",20), ("B","p2",30)]
L2 = [("A","p1",100), ("c","p3",35)]
</code></pre>
<p>Expected output:</p>
<pre><code>[(A,p1,20,100), (B,p2,30,"not in L2"), ("c","p3",35,"not in L1")]
</code></pre>
<p>I have tried using two <code>for</code> loops one for <code>L1</code> and other for <code>L2</code> but it is not working for iterative elements and giving repeated output which is not needed.</p>
| [
{
"answer_id": 74370423,
"author": "Я T",
"author_id": 18790524,
"author_profile": "https://Stackoverflow.com/users/18790524",
"pm_score": 1,
"selected": false,
"text": "L1 = [(\"A\",\"p1\",20), (\"B\",\"p2\",30)]\nL2 = [(\"A\",\"p1\",100), (\"c\",\"p3\",35)]\n\n# tranform L1, L2 to dict\nD1 = dict((_[0], _) for _ in L1)\nD2 = dict((_[0], _) for _ in L2)\nout_dict = dict()\n\nfor k, v in D1.items():\n if k in D2:\n # use set to avoid duplicated value\n new_tuple = D2[k] + v\n # keep the original order\n sorted_list = sorted(set(new_tuple), key=new_tuple.index)\n out_dict[k] = tuple(sorted_list)\n else:\n out_dict[k] = v + (\"not in L2\",)\n\nfor k, v in D2.items():\n if k in D1:\n new_tuple = D1[k] + v\n sorted_list = sorted(set(new_tuple), key=new_tuple.index)\n out_dict[k] = tuple(sorted_list)\n else:\n out_dict[k] = v + (\"not in L1\",)\n\noutput = list(v for k, v in out_dict.items())\n"
},
{
"answer_id": 74370424,
"author": "ZygD",
"author_id": 2753501,
"author_profile": "https://Stackoverflow.com/users/2753501",
"pm_score": 3,
"selected": true,
"text": "\"A\",\"p1\""
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8046567/"
] |
74,369,824 | <p>I'm coding <code>await user?.reload();//here</code> to reload `UserClass ' and during reloading, want to display indicator.</p>
<p>I learned Using <code>FutureProvider-when() method</code> from river_pod or 'FutureBuilder-snapshot` to implement this indicator.</p>
<p>Is these resolve is general or wonder there is more simple way to implement indicator display like this case ?</p>
<p>thanks for your helpful comment.</p>
<pre class="lang-dart prettyprint-override"><code>void currentUserNotNull(User? user, ref) async {
try {
var user = FirebaseAuth.instance.currentUser;
await user?.reload();//here
ref.read(authLoadingProvider.notifier).update((state) => false);
} on FirebaseAuthException catch (e) {
//
}
}
</code></pre>
| [
{
"answer_id": 74370505,
"author": "SugiuraY",
"author_id": 6843543,
"author_profile": "https://Stackoverflow.com/users/6843543",
"pm_score": 0,
"selected": false,
"text": "flutter_easyloading package"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6843543/"
] |
74,369,833 | <p>I have a file input.txt with two columns, I want to split the second column by ";" and transpose the unique entries then count and list how many matches are in column 1.</p>
<p><strong>This is my tab-delimited input.txt file</strong></p>
<pre><code>Gene Biological_Process
BALF2 metabolic process
CHD4 cell organization and biogenesis;metabolic process;regulation of biological process
TCOF1 cell organization and biogenesis;regulation of biological process;transport
TOP1 cell death;cell division;cell organization and biogenesis;metabolic process;regulation of biological process;response to stimulus
BcLF1 0
BALF5 metabolic process
MTA2 cell organization and biogenesis;metabolic process;regulation of biological process
MSH6 cell organization and biogenesis;metabolic process;regulation of biological process;response to stimulus
</code></pre>
<p><strong>my expected output1</strong></p>
<pre><code>Biological_Process Gene
metabolic process BALF2 CHD4 TOP1 BALF5 MTA2 MSH6
cell organization and biogenesis CHD4 TCOF1 TOP1 MTA2 MSH6
regulation of biological process CHD4 TCOF1 TOP1 MTA2 MSH6
transport TCOF1
cell death TOP1
cell division TOP1
response to stimulus TOP1 MSH6
</code></pre>
| [
{
"answer_id": 74370299,
"author": "MrMattBusby",
"author_id": 8507777,
"author_profile": "https://Stackoverflow.com/users/8507777",
"pm_score": 1,
"selected": false,
"text": "open your file ... iterate over each line"
},
{
"answer_id": 74408129,
"author": "tomc",
"author_id": 5714068,
"author_profile": "https://Stackoverflow.com/users/5714068",
"pm_score": 3,
"selected": true,
"text": "$ cat script.awk \n#! /usr/bin/awk -f \n\nBEGIN {\n FS = \"[\\t;]\"; # sep can be a regex\n OFS = \"\\t\"\n}\n\nNR>1 && /^[A-Z]/{ # skip header & blank lines \n for(i=NF; i>1; i--)\n if($i) # skip empty bio-proc\n a[$i] = a[$i] OFS $1 \n}\nEND{\n print \"Biological_Process\",\"Gene(s)\"\n for(x in a)\n print x a[x] \n}\n\n$ ./script.awk input.dat \nBiological_Process Gene(s)\ncell death TOP1\nregulation of biological process CHD4 TCOF1 TOP1 MTA2 MSH6\ntransport TCOF1\ncell division TOP1\nmetabolic process BALF2 CHD4 TOP1 BALF5 MTA2 MSH6\nresponse to stimulus TOP1 MSH6\ncell organization and biogenesis CHD4 TCOF1 TOP1 MTA2 MSH6\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10538428/"
] |
74,369,849 | <p>im 100% new to coding and just started to follow some guides a few days ago. I am now making a digital clock for my desktop and i want to change my background to a custom image that i have.</p>
<p>Can someone explain to me where i can change it so that the background becomes my image that i have? BR</p>
<pre><code>from tkinter import Tk
from tkinter import Label
import time
from PIL import Image, ImageTk
root = Tk()
root.title("Klocka")
root.attributes("-topmost", 1)
root.attributes('-alpha', 1)
root.iconbitmap('klocka.ico (1).ico')
root.geometry('600x400+50+50')
window_width = 255
window_height = 50
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
center_x = int(screen_width/3500 - window_width / 0.97)
center_y = int(screen_height/1 - window_height / 0.62)
root.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')
def present_time():
display_time = time.strftime("%I:%M:%S")
digi_clock.config(text=display_time)
digi_clock.after(200,present_time)
digi_clock = Label(root, font=("Arial",50),bg="black",fg="red")
digi_clock.pack()
present_time()
root.mainloop()
</code></pre>
| [
{
"answer_id": 74369945,
"author": "Krishnendu Bhowmick",
"author_id": 5237559,
"author_profile": "https://Stackoverflow.com/users/5237559",
"pm_score": 0,
"selected": false,
"text": "from tkinter import Tk\nfrom tkinter import Label\nimport time\nfrom PIL import Image, ImageTk\n\nIMAGE_PATH = 'PicNameHere.png'\nWIDTH, HEIGTH = 200, 50\n\nroot = Tk()\nroot.title(\"Klocka\")\nroot.attributes(\"-topmost\", 1)\nroot.attributes('-alpha', 1)\nroot.iconbitmap('klocka.ico (1).ico')\nroot.geometry('600x400+50+50')\n\n\nwindow_width = 255\nwindow_height = 50\n\nscreen_width = root.winfo_screenwidth()\nscreen_height = root.winfo_screenheight()\n\ncenter_x = int(screen_width/3500 - window_width / 0.97)\ncenter_y = int(screen_height/1 - window_height / 0.62)\n\nroot.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')\n\nbkrgframe = BkgrFrame(root, IMAGE_PATH, WIDTH, HEIGTH)\nbkrgframe.pack()\n\ndef present_time():\n display_time = time.strftime(\"%I:%M:%S\")\n digi_clock.config(text=display_time)\n digi_clock.after(200,present_time)\n\ndigi_clock = Label(root, font=(\"Arial\",50),bg=\"black\",fg=\"red\")\ndigi_clock.pack()\n\npresent_time()\n\nroot.mainloop()\n"
},
{
"answer_id": 74393621,
"author": "Krishnendu Bhowmick",
"author_id": 5237559,
"author_profile": "https://Stackoverflow.com/users/5237559",
"pm_score": -1,
"selected": false,
"text": "from tkinter import Tk\nfrom tkinter import Label\nimport time\nfrom PIL import Image, ImageTk\n\n\n\nroot = Tk()\nroot.title(\"Klocka\")\nroot.attributes(\"-topmost\", 1)\nroot.attributes('-alpha', 1)\nroot.iconbitmap('klocka.ico (1).ico')\nroot.geometry('600x400+50+50')\n\nbg = PhotoImage(file = \"Your_img.png\")\ncanvas1 = Canvas( root, width = 400,\n height = 400)\n \ncanvas1.pack(fill = \"both\", expand = True)\ncanvas1.create_image( 0, 0, image = bg, \n anchor = \"nw\")\nwindow_width = 255\nwindow_height = 50\n\nscreen_width = root.winfo_screenwidth()\nscreen_height = root.winfo_screenheight()\n\ncenter_x = int(screen_width/3500 - window_width / 0.97)\ncenter_y = int(screen_height/1 - window_height / 0.62)\n\nroot.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')\n\n\ndef present_time():\n display_time = time.strftime(\"%I:%M:%S\")\n digi_clock.config(text=display_time)\n digi_clock.after(200,present_time)\n\ndigi_clock = Label(root, font=(\"Arial\",50),bg=\"black\",fg=\"red\")\ndigi_clock.pack()\n\npresent_time()\n\nroot.mainloop()\n"
},
{
"answer_id": 74397198,
"author": "acw1668",
"author_id": 5317403,
"author_profile": "https://Stackoverflow.com/users/5317403",
"pm_score": 0,
"selected": false,
"text": "Label"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20455770/"
] |
74,369,852 | <p>I'm trying to learn Ruby on Rails, an I'm kinda stuck with associaton.
My project is to create a simple blog with three table. User, Post, and Comment.</p>
<p>In my understanding, after associationg several table with foreign key, rails would automatcily find user_id and post_id. But everytime I try to build comments, the user_id is nil.</p>
<p>Here's my model:</p>
<pre><code>class User < ApplicationRecord
has_many :posts
has_many :comments
validates :name, presence: true, length: { minimum: 5 }, uniqueness: true
validates :password, presence: true, length: { minimum: 5 }
end
</code></pre>
<pre><code>class Post < ApplicationRecord
belongs_to :user
has_many :comments
validates :title, presence: true
validates :body, presence: true, length: {minimum: 10}
end
</code></pre>
<pre><code>class Comment < ApplicationRecord
belongs_to :post
belongs_to :user
validates :body, presence: true
validates :user_id, presence: true
validates :post_id, presence: true
end
</code></pre>
<p>Here is the screenshot when I try to create a comment:
<a href="https://i.stack.imgur.com/pxStG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pxStG.jpg" alt="enter image description here" /></a></p>
<p>As you can see, the post_id is not nil but the user_id is nil.</p>
<p>I try to input user_id manualy and it work as intended. But I can't find out how to create comment with automatic user_id and post_id.</p>
| [
{
"answer_id": 74369960,
"author": "Amol Mohite",
"author_id": 12111186,
"author_profile": "https://Stackoverflow.com/users/12111186",
"pm_score": -1,
"selected": true,
"text": "user = User.find 2\npost = user.posts.where(id: 2).first\ncomment = post.comments.build({comment_params}.merge(user_id: user.id))\n"
},
{
"answer_id": 74372267,
"author": "max",
"author_id": 544825,
"author_profile": "https://Stackoverflow.com/users/544825",
"pm_score": 0,
"selected": false,
"text": "resources :posts do\n resources :comments, \n only: [:create]\n shallow: true\nend\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18330030/"
] |
74,369,944 | <p>I have a code written in Pascal. I have a record type called <code>recordPembeli</code> and I have an <code>array[1..x] of recordPembeli</code>. The <code>x</code> in this array will be the length of the data which the user determines in the body of program <code>readln(x)</code>.</p>
<p>Here is the program:</p>
<pre><code>program iniSesiDua;
uses crt;
type
recordPembeli = record
nama : string[5];
jumlahPembelian : integer;
end;
var
x : integer
dataPembelian : array[1..x] of recordPembeli;
begin
clrscr;
write('Masukkan jumlah pembeli : ');readln(x);
readln;
end.
</code></pre>
<p>I try it and it says :</p>
<blockquote>
<p>Warning: Variable "x" does not seem to be initialized</p>
<p>Error: Can't evaluate constant expression</p>
</blockquote>
<p>Can I even determine the length of the data by user input in array of record or is it forbidden?</p>
| [
{
"answer_id": 74371884,
"author": "Tom Brunberg",
"author_id": 2292722,
"author_profile": "https://Stackoverflow.com/users/2292722",
"pm_score": 3,
"selected": true,
"text": "dynamic"
},
{
"answer_id": 74374149,
"author": "Kai Burghardt",
"author_id": 9636977,
"author_profile": "https://Stackoverflow.com/users/9636977",
"pm_score": 0,
"selected": false,
"text": "x"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74369944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17611580/"
] |
74,370,006 | <p>I've been playing with returning tuples from methods, so method signatures like this...:</p>
<pre><code>private int GetAlpha() {...} // -1 indicates an error
private bool GetAlpha(out int alphaOut) {...}
</code></pre>
<p>...turn into this:</p>
<pre><code>private (bool Success, int Alpha) GetAlpha() {...}
</code></pre>
<p><strong>PROS:</strong></p>
<ul>
<li>I like avoiding the use of out-of-band values like <code>-1</code> to signal an error to the caller</li>
<li>I've been reading recently that <code>out</code> parameters are evil and to be avoided</li>
</ul>
<p><strong>CONS:</strong></p>
<ul>
<li>I can only use the <code>var (success, a, b, ...) = Foo(...)</code> syntax ONCE in a typical method. Thereafter, I'm forced to declare nearly all variables in the returned tuple, because 'success' is already defined</li>
<li>I not only have to declare return variables, but I also have to explicitly specify their type (vs. implicitly using <code>var</code>).</li>
</ul>
<pre><code>var (success, alpha) = GetAlpha();
if (success)
{
//var (success, beta, gamma) = GetStuff(alpha); // ERROR - 'success' is already defined
//(success, beta, gamma) = GetStuff(alpha); // ERROR - 'beta' and 'gamma' are undefined
//(success, var beta, var gamma) = GetStuff(alpha); // ERROR - no such syntax, silly!
string beta;
DateTime gamma;
(success, beta, gamma) = GetStuff(alpha);
.
.
.
</code></pre>
<p>The convenience and conciseness of using the implicit declaration and typing is so nice, that it bugs me I'm typically only able to use it once in a method.</p>
<p>Am I missing anything? Is there some other pattern that avoids this?</p>
| [
{
"answer_id": 74370114,
"author": "Slack Groverglow",
"author_id": 3761097,
"author_profile": "https://Stackoverflow.com/users/3761097",
"pm_score": 0,
"selected": false,
"text": "out"
},
{
"answer_id": 74370217,
"author": "StriplingWarrior",
"author_id": 120955,
"author_profile": "https://Stackoverflow.com/users/120955",
"pm_score": 3,
"selected": true,
"text": "var (alphaSucceeded, alpha) = GetAlpha();\nif (alphaSucceeded)\n{\n var (getStuffSucceeded, beta, gamma) = GetStuff(alpha);\n"
},
{
"answer_id": 74384368,
"author": "Wyck",
"author_id": 1563833,
"author_profile": "https://Stackoverflow.com/users/1563833",
"pm_score": 1,
"selected": false,
"text": "_"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264540/"
] |
74,370,038 | <p>I have tried to combine below data according to the result shown as below in sql server.</p>
<p>Raw data:</p>
<p><a href="https://i.stack.imgur.com/QNv9W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QNv9W.png" alt="enter image description here" /></a></p>
<p>Expected result:</p>
<p><a href="https://i.stack.imgur.com/25w0L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/25w0L.png" alt="enter image description here" /></a></p>
<p>i am not sure if i should use pivot. also, when i tried to concat it only able to combine the data from the same row.
It such a great help if you can help me with this. :)</p>
| [
{
"answer_id": 74370162,
"author": "Ian Kenney",
"author_id": 2308473,
"author_profile": "https://Stackoverflow.com/users/2308473",
"pm_score": 2,
"selected": true,
"text": "SELECT\n salesid, \n loyaltyid, \n STRING_AGG(paymentitem, '+') AS paymentItem\nFROM rawdata \nGROUP BY salesId, loyaltyId\nORDER BY salesId, loyaltyId;\n"
},
{
"answer_id": 74371031,
"author": "Sunita Rawat",
"author_id": 20449018,
"author_profile": "https://Stackoverflow.com/users/20449018",
"pm_score": 0,
"selected": false,
"text": "SELECT\n salesid, \n loyaltyid, \n GROUP_CONCAT(text, '+') AS paymentItem\nFROM ABC \nGROUP BY salesId, loyaltyId\nORDER BY salesId, loyaltyId;\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9186256/"
] |
74,370,057 | <p>I am trying to change date format but its showing me wrong result (showing me 1970-01-01),How can i fix this, i want dynamic date in "Y-m-d" format,Here is my code</p>
<pre><code>$start_date2=$_POST['start_date']; //showing 10-30-2022
echo $new_date = date("Y-m-d", strtotime($start_date2)); // showing 1970-01-01
</code></pre>
| [
{
"answer_id": 74370124,
"author": "Anant - Alive to die",
"author_id": 4248328,
"author_profile": "https://Stackoverflow.com/users/4248328",
"pm_score": 2,
"selected": true,
"text": "$start_date2=$_POST['start_date'];"
},
{
"answer_id": 74370211,
"author": "Misunderstood",
"author_id": 3813605,
"author_profile": "https://Stackoverflow.com/users/3813605",
"pm_score": 0,
"selected": false,
"text": "<input type=\"date\" name=\"start_date\" />\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20259827/"
] |
74,370,072 | <p><a href="https://i.stack.imgur.com/wdSCi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wdSCi.png" alt="Here is my client details list " /></a></p>
<pre><code>#API View
@api_view(['GET'])
def clientDetail(request,pk):
details = ClientAPI.objects.get(id=pk)
serializer = ClientSerializer(details,many=False)
return Response(serializer.data)
#API List
@api_view(['GET'])
def clientDetailList(request):
list = ClientAPI.objects.all().order_by('-id')
serializer = ClientSerializer(list,many=True)
return Response(serializer.data)
</code></pre>
<p>Here is my api view code .Now how i add delete function to delete the client detail list.</p>
<p>I try to delete my client details list .Can you show me the function i add my views.py</p>
| [
{
"answer_id": 74370124,
"author": "Anant - Alive to die",
"author_id": 4248328,
"author_profile": "https://Stackoverflow.com/users/4248328",
"pm_score": 2,
"selected": true,
"text": "$start_date2=$_POST['start_date'];"
},
{
"answer_id": 74370211,
"author": "Misunderstood",
"author_id": 3813605,
"author_profile": "https://Stackoverflow.com/users/3813605",
"pm_score": 0,
"selected": false,
"text": "<input type=\"date\" name=\"start_date\" />\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12154428/"
] |
74,370,076 | <p>I have scenario A a dictionary that I would wish to transform using this method if it's possible or is there an alternative</p>
<pre><code>A = {A:1,B:2,C:3}
B = {values[1] : values[1]*2 for values in A.items()}
</code></pre>
<p>Desired outcome:</p>
<pre><code>B = {1:2,2:4,3:6}
</code></pre>
| [
{
"answer_id": 74370124,
"author": "Anant - Alive to die",
"author_id": 4248328,
"author_profile": "https://Stackoverflow.com/users/4248328",
"pm_score": 2,
"selected": true,
"text": "$start_date2=$_POST['start_date'];"
},
{
"answer_id": 74370211,
"author": "Misunderstood",
"author_id": 3813605,
"author_profile": "https://Stackoverflow.com/users/3813605",
"pm_score": 0,
"selected": false,
"text": "<input type=\"date\" name=\"start_date\" />\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11761209/"
] |
74,370,146 | <p>The following code works but I wonder if there's a way to combine the following conditions in a shorter way?</p>
<pre class="lang-py prettyprint-override"><code>xlist = ['a', 'b', 'c']
xlist[:] = [x for x in xlist if ('a' not in x) & ('b' not in x)]
</code></pre>
<p>I tried this but it didn't work</p>
<pre class="lang-py prettyprint-override"><code>xlist[:] = [x for x in xlist if ['a', 'b'] not in x]
</code></pre>
| [
{
"answer_id": 74370124,
"author": "Anant - Alive to die",
"author_id": 4248328,
"author_profile": "https://Stackoverflow.com/users/4248328",
"pm_score": 2,
"selected": true,
"text": "$start_date2=$_POST['start_date'];"
},
{
"answer_id": 74370211,
"author": "Misunderstood",
"author_id": 3813605,
"author_profile": "https://Stackoverflow.com/users/3813605",
"pm_score": 0,
"selected": false,
"text": "<input type=\"date\" name=\"start_date\" />\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1912104/"
] |
74,370,156 | <p>I have the following dataframe 'df':</p>
<pre><code>df = pd.DataFrame({'a':[0,2,3],'b':[1,3,4],'c':[4,1,2]})
</code></pre>
<p>Now I want to drop such rows such that that row has 0 value for column'a' and non zero value for column 'b'. How can I do that?</p>
<p>I tried this, <code>df = df[df['a'] == 0 and df['b'] != 0]</code>, but got error.</p>
| [
{
"answer_id": 74370236,
"author": "Abirbhav G.",
"author_id": 5901382,
"author_profile": "https://Stackoverflow.com/users/5901382",
"pm_score": 0,
"selected": false,
"text": "&"
},
{
"answer_id": 74370354,
"author": "Sunita Rawat",
"author_id": 20449018,
"author_profile": "https://Stackoverflow.com/users/20449018",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd \n\ndf = pd.DataFrame(\n {\n 'a': [0, 2, 3],\n 'b': [1, 3, 4],\n 'c': [4, 1, 2]\n }\n) \n\n# take any rows which are having 0 in any columns \ndf = df[(df['a'] == 0) | (df['b'] == 0)] \n"
},
{
"answer_id": 74370617,
"author": "Avi Turner",
"author_id": 900570,
"author_profile": "https://Stackoverflow.com/users/900570",
"pm_score": 1,
"selected": false,
"text": "&"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19484710/"
] |
74,370,181 | <p>I am complete novice who is trying to supplement online course learning, by building some rudimentary programs. I am currently trying to build a program to calculate one's golf index. In order to do this, I must first calculate the average of the lowest 8 rounds, of the golfer's last 20. Calculating the average of the last 20 rounds was easy enough. It is isolating the lowest 8 rounds from the last twenty that I cannot figure out.</p>
<p>Generalized, how does one calculate the sum of the lowest N values in an array?</p>
<p>A note for the golfers out there: for the purposes of this exercise I am imagining that the individual only plays at one course, with a par of 72. I realize that the program will not work as currently constructed if par changes.</p>
<pre><code>var scores: Array = [98, 99, 87, 86, 88, 92, 88, 87, 84, 98, 85, 84, 80, 99, 100, 101, 94, 96, 79, 99, 92, 94, 87, 99, 80]
var lastTwentyScores = scores.suffix(20)
var total = lastTwentyScores.reduce(0, +)
var avg = Double(total) / Double(lastTwentyScores.count)
var index = avg - 72
</code></pre>
<p>Right now, it is giving me the average of the last twenty - 72.</p>
<p>I know I will need to create a new variable, and change the final divisor to 8, instead of 20. I just don't know how to call the 8 lowest values from the array.</p>
| [
{
"answer_id": 74370236,
"author": "Abirbhav G.",
"author_id": 5901382,
"author_profile": "https://Stackoverflow.com/users/5901382",
"pm_score": 0,
"selected": false,
"text": "&"
},
{
"answer_id": 74370354,
"author": "Sunita Rawat",
"author_id": 20449018,
"author_profile": "https://Stackoverflow.com/users/20449018",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd \n\ndf = pd.DataFrame(\n {\n 'a': [0, 2, 3],\n 'b': [1, 3, 4],\n 'c': [4, 1, 2]\n }\n) \n\n# take any rows which are having 0 in any columns \ndf = df[(df['a'] == 0) | (df['b'] == 0)] \n"
},
{
"answer_id": 74370617,
"author": "Avi Turner",
"author_id": 900570,
"author_profile": "https://Stackoverflow.com/users/900570",
"pm_score": 1,
"selected": false,
"text": "&"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20454417/"
] |
74,370,190 | <p>I have a web app that uses the Azure Active Directory (AD) login (Microsoft login), where I have a development environment, staging, and production environment.</p>
<p>The AD login works for my development environment, but I am getting an error when I try to use the same login for my staging environment.</p>
<p>The error I am getting is</p>
<blockquote>
<p>Your sign-in was successful but did not meet the criteria to access this resource. For example, you might be signing in from a browser, app, or location your admin restricts</p>
</blockquote>
<p>I am attaching the screenshot for more details. Any help is highly appreciable.</p>
<p>Best Regards,</p>
<p>Janak Darji</p>
<p><a href="https://i.stack.imgur.com/QtRm6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QtRm6.png" alt="enter image description here" /></a></p>
<p>I have tried to enter my public IP under the network tab as an allowed IP but that didn't work.</p>
| [
{
"answer_id": 74371412,
"author": "Jason Pan",
"author_id": 7687666,
"author_profile": "https://Stackoverflow.com/users/7687666",
"pm_score": 1,
"selected": false,
"text": "Azure Active Directory"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11129493/"
] |
74,370,207 | <p>Markers in SVGs are not rendered on the GitHub website.<br />
This happens only on the website, the Android app doesn't have the same problem.</p>
<p><a href="https://github.com/kitswas/git-for-all/blob/main/Chapters/chapter2.md" rel="nofollow noreferrer">Markdown file with the problem</a></p>
<p><a href="https://github.com/kitswas/git-for-all/blob/9ea764dae859ba58cf1373ec8e70f2f0b4e1d129/Chapters/images/branches.svg" rel="nofollow noreferrer"><img src="https://raw.githubusercontent.com/kitswas/git-for-all/9ea764dae859ba58cf1373ec8e70f2f0b4e1d129/Chapters/images/branches.svg" alt="The offending SVG" /></a></p>
<p>The SVG was created using Inkscape.</p>
<p>When I noticed the problem, I changed the file to an optimised SVG (File -> Save As -> Optimised SVG) but didn't observe any changes.</p>
<p><strong>Edit:</strong> The situation is thornier than I initially assumed.<br />
Firefox doesn't display the markers at all while Chrome and Edge show them in black. The images on <em>this page</em> appear differently on different browsers.<br />
I manually edited the XML to colour the markers and ended up with this file. <a href="https://github.com/kitswas/git-for-all/blob/6faf7410ceaa620e53794687d36edc6728a54e48/Chapters/images/branches.svg" rel="nofollow noreferrer"><img src="https://raw.githubusercontent.com/kitswas/git-for-all/6faf7410ceaa620e53794687d36edc6728a54e48/Chapters/images/branches.svg" alt="New SVG" /></a>.<br />
But Inkscape doesn't show the red outlines on the markers.</p>
<p><strong>Edit:</strong> This is <em>not</em> a GitHub problem as I had initially suspected but an Inkscape(+Firefox) one. Still unsure whether Firefox is responsible.</p>
| [
{
"answer_id": 74399032,
"author": "Kitswas",
"author_id": 8659747,
"author_profile": "https://Stackoverflow.com/users/8659747",
"pm_score": 1,
"selected": true,
"text": "<marker-ref>"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8659747/"
] |
74,370,221 | <p>I am working on a project where I am trying to insert values into a MySQL table. Before starting this project I verified that I had the necessary JAR file setup and tested the SQL connection. I thought I was on the right track, but I can't seem to get past these errors popping up in the console. I have a feeling I am not inserting data correctly into MySQL through Eclipse. I was hoping someone here may know of a better process or way of completing this. My source code is posted below. The file "theraven.txt" that is being read from is in the project directory.</p>
<pre class="lang-java prettyprint-override"><code>public class DatabaseGO {
//private static Connection connection = null;
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
FileInputStream findIt = new FileInputStream("theraven.txt");
Scanner fileInput = new Scanner(findIt);
ArrayList<String> words = new ArrayList<String>();
ArrayList<Integer> count = new ArrayList<Integer>();
while (fileInput.hasNext()) {
String nextWord = fileInput.next();
if (words.contains(nextWord)) {
int index = words.indexOf(nextWord);
count.set(index, count.get(index)+ 1);
}
else {
words.add(nextWord);
count.add(1);
}
}
fileInput.close();
findIt.close();
for (int i = 0; i < words.size(); ++i) {
Collections.sort(count, Collections.reverseOrder());
//////////////////////////////
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String url = "jdbc:mysql://localhost:3306/word_occurrences";
String user = "root";
String password = "kittylitter";
String sql = "INSERT INTO word(countNumber, `countName`) VALUES(?,?)";
try (Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement pst = con.prepareStatement(sql)) {
pst.setInt(1, count.get(i));
pst.setString(2, words.get(i));
pst.executeUpdate();
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(DatabaseGO.class.getName());
lgr.log(Level.SEVERE, ex.getMessage(), ex);
}
}
}
}
</code></pre>
<p>This is the current errors I am getting:</p>
<pre class="lang-none prettyprint-override"><code>SEVERE: Unknown column 'countNumber' in 'field list'
java.sql.SQLSyntaxErrorException: Unknown column 'countNumber' in 'field list'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1009)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1320)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:994)
at database.DatabaseGO.main(DatabaseGO.java:67)
Nov 09, 2022 12:00:14 AM database.DatabaseGO main
</code></pre>
<p>In MySQL I have a table named word and three columns named <code>recordNumber</code> Int (set to auto-increment), <code>wordCount</code> Int, and <code>wordName</code> VARCHAR(45). I was hoping the program would output the count of the name next to the name.</p>
| [
{
"answer_id": 74370301,
"author": "Sujay",
"author_id": 1087388,
"author_profile": "https://Stackoverflow.com/users/1087388",
"pm_score": 0,
"selected": false,
"text": "INSERT INTO word VALUES(?,?)"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19403013/"
] |
74,370,228 | <p><a href="https://i.stack.imgur.com/R9Xtn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R9Xtn.png" alt="This is the question." /></a></p>
<p>I have the code for the 1st and the second pyramid, I just don't know how to put it together like how the question is asking. The first code below is for pyramid 1 and second is for the 2nd pyramid.</p>
<p>`</p>
<pre><code>rows = int(input("Enter number of rows: "))
k = 0
for i in range(1, rows+1):
for space in range(1, (rows-i)+1):
print(end=" ")
while k!=(2*i-1):
print("* ", end="")
k += 1
k = 0
print()
</code></pre>
<p>`</p>
<p>`</p>
<pre><code>rows = int(input("Enter number of rows: "))
k = 0
count=0
count1=0
for i in range(1, rows+1):
for space in range(1, (rows-i)+1):
print(" ", end="")
count+=1
while k!=((2*i)-1):
if count<=rows-1:
print(i+k, end=" ")
count+=1
else:
count1+=1
print(i+k-(2*count1), end=" ")
k += 1
count1 = count = k = 0
print()
</code></pre>
<p>`</p>
| [
{
"answer_id": 74370346,
"author": "Utkarsh",
"author_id": 13641277,
"author_profile": "https://Stackoverflow.com/users/13641277",
"pm_score": 2,
"selected": true,
"text": "rows = int(input(\"Enter number of rows: \"))\n\nk = 0\n\nfor i in range(1, rows+1):\n for space in range(1, (rows-i)+1):\n print(end=\" \")\n \n while k!=(2*i-1):\n print(\"* \", end=\"\")\n k += 1\n\n k = 0\n print()\n\nk = 0\ncount=0\ncount1=0\n\nfor i in range(1, rows+1):\n for space in range(1, (rows-i)+1):\n print(\" \", end=\"\")\n count+=1\n \n for k in range(i,0,-1):\n print(k, end=' ')\n for k in range(2,i+1):\n print(k, end=' ')\n count = 0\n print()\n"
},
{
"answer_id": 74370775,
"author": "Алексей Р",
"author_id": 15035314,
"author_profile": "https://Stackoverflow.com/users/15035314",
"pm_score": 0,
"selected": false,
"text": "def pyramid(n_rows, s_type='*'):\n max_width = n_rows * 2 - 1\n for i in range(0, n_rows):\n stars = i * 2 + 1\n side = (max_width - stars) // 2\n if s_type == '*':\n print(f\"{' ' * side}{'* ' * stars}\")\n else:\n side_nums = ' '.join(f'{x+1}' for x in range(0,i+1))\n print(f\"{' ' * side}{side_nums[1:][::-1]}{side_nums}\")\n\n\nrows = int(input(\"Enter number of rows: \"))\npyramid(rows)\npyramid(rows, s_type='0')\n"
},
{
"answer_id": 74371250,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 0,
"selected": false,
"text": "rows = int(input('Enter a number from 1 to 9: '))\nassert rows > 0 and rows < 10\noutput = [None] * (rows*2)\nstars = '*' * (rows * 2 - 1)\nfor i in range(rows):\n output[i] = stars[:i*2+1].rjust(rows+i)\n s = ''.join(map(str, range(1, i+2))) + ''.join(map(str, range(i, 0, -1)))\n output[i+rows] = s.rjust(rows+i)\n\nprint(*output, sep='\\n')\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20455673/"
] |
74,370,252 | <p>I am trying to scrape this <a href="http://www.nepalstock.com/main/floorsheet/index/0/" rel="nofollow noreferrer">website</a> and I tried running scrapy shell in my cli and I can get xpath response up to <code>//table[@class='table my-table']</code> this xpath but after that I cannot get any data as the response is empty array <code>[]</code> I don't feel the contents is hidden inside JavaScript I have missed some techniques or is my approach wrong with scrapy?</p>
<p>Here is my overall code for reference</p>
<pre><code>class MarketDataSpider(scrapy.Spider):
name = "nepse_floorsheet"
def start_requests(self):
url = 'http://www.nepalstock.com/main/floorsheet/index/0/'
yield Request(url, callback=self.parse)
def parse(self, response):
for tr in response.xpath("//table[@class='table my-table']"):
print(tr.xpath("//tbody//tr[position()>2and position()<23]"))
</code></pre>
| [
{
"answer_id": 74370920,
"author": "Barry the Platipus",
"author_id": 19475185,
"author_profile": "https://Stackoverflow.com/users/19475185",
"pm_score": 1,
"selected": false,
"text": "tr.xpath(\".//tbody//tr[position()>2 and position()<23]\")\n"
},
{
"answer_id": 74371623,
"author": "Fazlul",
"author_id": 12848411,
"author_profile": "https://Stackoverflow.com/users/12848411",
"pm_score": 1,
"selected": true,
"text": "class MarketDataSpider(scrapy.Spider):\n name = \"nepse_floorsheet\"\n\n def start_requests(self):\n url = 'http://www.nepalstock.com/main/floorsheet/index/1/'\n yield scrapy.Request(url, callback=self.parse)\n\n\n def parse(self, response):\n\n for tr in response.xpath(\"//table[@class='table my-table']//tr[position()>2 and position()<23]\"):\n yield {\n 'Quantity':tr.xpath('.//td[6]/text()').get(),\n 'Rate':tr.xpath('.//td[7]/text()').get()\n }\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20293303/"
] |
74,370,284 | <p>I want to discourage the usage of <code>notify</code> of <code>CustomController</code>, but not <code>AnotherCustomController</code>. Is there a matcher in rubocop that allows it to check <code>notify</code> is from specific class?</p>
<pre class="lang-rb prettyprint-override"><code>class CustomController
def notify(message)
puts 'notify is deprecated'
end
end
class AnotherCustomController
def notify(message)
puts message
end
end
</code></pre>
<p>Currently, <code>(send nil? :notify ...)</code> is matched to both of them. I want to match only from CustomController.</p>
<pre class="lang-rb prettyprint-override"><code>class MatchClass < CustomController
def run
# This should be matched by rubocop
notify('test')
end
end
class NotMatchClass < AnotherCustomController
def run
# This shouldn't be matched by rubocop
notify('this is another notify method')
end
end
</code></pre>
<p>Thank you</p>
| [
{
"answer_id": 74370920,
"author": "Barry the Platipus",
"author_id": 19475185,
"author_profile": "https://Stackoverflow.com/users/19475185",
"pm_score": 1,
"selected": false,
"text": "tr.xpath(\".//tbody//tr[position()>2 and position()<23]\")\n"
},
{
"answer_id": 74371623,
"author": "Fazlul",
"author_id": 12848411,
"author_profile": "https://Stackoverflow.com/users/12848411",
"pm_score": 1,
"selected": true,
"text": "class MarketDataSpider(scrapy.Spider):\n name = \"nepse_floorsheet\"\n\n def start_requests(self):\n url = 'http://www.nepalstock.com/main/floorsheet/index/1/'\n yield scrapy.Request(url, callback=self.parse)\n\n\n def parse(self, response):\n\n for tr in response.xpath(\"//table[@class='table my-table']//tr[position()>2 and position()<23]\"):\n yield {\n 'Quantity':tr.xpath('.//td[6]/text()').get(),\n 'Rate':tr.xpath('.//td[7]/text()').get()\n }\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2474164/"
] |
74,370,302 | <p>I have the database like this</p>
<pre><code>[
{
"ymd": "2019-01-02",
"dailyRevenue": 3464
},
{
"ymd": "2019-01-03",
"dailyRevenue": 3051
},
{
"ymd": "2019-01-04",
"dailyRevenue": 3495
},
{
"ymd": "2019-01-05",
"dailyRevenue": 4770
},
{
"ymd": "2019-01-06",
"dailyRevenue": 4907
},
{
"ymd": "2019-01-07",
"dailyRevenue": 2880
},
]
</code></pre>
<p>And this is my code</p>
<pre><code>export default function Dashboard() {
const API_URL = 'http://localhost:8000/api/';
const reLabel = ['2019-03-12', '2019-09-24'], reData = [432,345];
const [revenueHistoryLabel, setRevenueHistoryLabel] = useState([]);
const [revenueHistoryData, setRevenueHistoryData] = useState([]);
useEffect(() => {
axios.get(API_URL + 'revenues').then((res) => {
setRevenueHistoryLabel(
...revenueHistoryLabel,
res.data.map((element) => element.ymd),
);
setRevenueHistoryData(
...revenueHistoryData,
res.data.map((element) => element.dailyRevenue),
);
});
}, []);
</code></pre>
<p>I tried to:</p>
<ul>
<li>retrieve ymd, then put it to revenueHistoryLabel as an array like ['2019-03-12', '2019-09-24']</li>
<li>retrieve dailyRevenue, then put it to revenueHistoryData as an array like [432,345]</li>
</ul>
<p>But after I called setRevenueHistoryLabel() and setRevenueHistoryData(), revenueHistoryLabel and revenueHistoryData were still empty arrays.</p>
| [
{
"answer_id": 74370350,
"author": "ChanHyeok-Im",
"author_id": 6329353,
"author_profile": "https://Stackoverflow.com/users/6329353",
"pm_score": 3,
"selected": true,
"text": "setRevenueHistoryLabel([\n ...revenuHistoryLabel,\n ...res.data.map((element) => element.ymd),\n]);\n\nsetRevenueHistoryData([\n ...revenuHistoryData,\n ...res.data.map((element) => element.dailyRevenue),\n]);\n"
},
{
"answer_id": 74370361,
"author": "Shilpe Saxena",
"author_id": 13265113,
"author_profile": "https://Stackoverflow.com/users/13265113",
"pm_score": 0,
"selected": false,
"text": "axios.get(\"\")"
},
{
"answer_id": 74370740,
"author": "Khang-Truong",
"author_id": 15465426,
"author_profile": "https://Stackoverflow.com/users/15465426",
"pm_score": 0,
"selected": false,
"text": "export default function Dashboard() {\n const API_URL = 'http://localhost:8000/api/';\n const reLabel = ['2019-03-12', '2019-09-24'], reData = [432,345];\n const [revenueHistoryLabel, setRevenueHistoryLabel] = useState([]);\n const [revenueHistoryData, setRevenueHistoryData] = useState([]);\n\n useEffect(() => {\n axios.get(API_URL + 'revenues').then((res) => {\n setRevenueHistoryLabel([\n ...revenueHistoryLabel,\n ...res.data.map((element) => element.ymd),\n ]);\n setRevenueHistoryData([\n ...revenueHistoryData,\n ...res.data.map((element) => element.dailyRevenue),\n ]);\n });\n }, []);\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15465426/"
] |
74,370,345 | <pre><code>package main
import (
"fmt"
)
func FindSimilarData(input string, data ...string) string {
same := ""
for _, d := range data {
fmt.Println(d)
if (d) == input {
same += d
fmt.Println(d)
fmt.Println(same)
}
}
return ""
}
func main() {
fmt.Println(FindSimilarData("iphone", "laptop", "iphone 13", "iphone 12", "iphone 12 pro"))
}
</code></pre>
<p>i want to return the data type string which has similar data, i was trying to use strings. Contains but it only returns the boolean type. can anyone give an example for this one, thanks before</p>
| [
{
"answer_id": 74370350,
"author": "ChanHyeok-Im",
"author_id": 6329353,
"author_profile": "https://Stackoverflow.com/users/6329353",
"pm_score": 3,
"selected": true,
"text": "setRevenueHistoryLabel([\n ...revenuHistoryLabel,\n ...res.data.map((element) => element.ymd),\n]);\n\nsetRevenueHistoryData([\n ...revenuHistoryData,\n ...res.data.map((element) => element.dailyRevenue),\n]);\n"
},
{
"answer_id": 74370361,
"author": "Shilpe Saxena",
"author_id": 13265113,
"author_profile": "https://Stackoverflow.com/users/13265113",
"pm_score": 0,
"selected": false,
"text": "axios.get(\"\")"
},
{
"answer_id": 74370740,
"author": "Khang-Truong",
"author_id": 15465426,
"author_profile": "https://Stackoverflow.com/users/15465426",
"pm_score": 0,
"selected": false,
"text": "export default function Dashboard() {\n const API_URL = 'http://localhost:8000/api/';\n const reLabel = ['2019-03-12', '2019-09-24'], reData = [432,345];\n const [revenueHistoryLabel, setRevenueHistoryLabel] = useState([]);\n const [revenueHistoryData, setRevenueHistoryData] = useState([]);\n\n useEffect(() => {\n axios.get(API_URL + 'revenues').then((res) => {\n setRevenueHistoryLabel([\n ...revenueHistoryLabel,\n ...res.data.map((element) => element.ymd),\n ]);\n setRevenueHistoryData([\n ...revenueHistoryData,\n ...res.data.map((element) => element.dailyRevenue),\n ]);\n });\n }, []);\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20267588/"
] |
74,370,351 | <p>I'm trying to find if a given 2-element array (<code>$result</code>) exists on a dynamically created multidimentional array.</p>
<p>There are 2 flat arrays (<code>$a</code> and <code>$b</code>) which will be used to generate a haystack array of 2-element combinations.</p>
<pre><code>$a = [1, 2, 3];
$b = [3, 4, 5];
$result = [1,3];
</code></pre>
<p>I want to check if the <code>$result</code> array exists (with the two values in either orientation) in the haystack array.</p>
<p>The (cross joined) haystack array (<code>$selections</code>) looks like the following:</p>
<pre><code>[
[1,3],
[1,4],
[1,5],
[2,3],
[2,4],
[2,5],
[3,4],
[3,5]
]
</code></pre>
<p>Notice that <code>[3,3]</code> is excluded by my application's logic.</p>
<p>I build <code>$selections</code> this way:</p>
<pre><code>$selections = [];
foreach($a as $s){
foreach($b as $o){
if($s == $o){
continue;
}
$selections[] = [$s, $o];
}
}
</code></pre>
<p>The <code>$result</code> should be considered found by the following non-exhaustive list:</p>
<ul>
<li><code>[1, 3]</code></li>
<li><code>[3, 1]</code></li>
<li><code>[2, 5]</code></li>
<li><code>[3, 3]</code></li>
</ul>
<p>But pairs like these should not be considered found:</p>
<ul>
<li><code>[1, 2]</code></li>
<li><code>[3, 3]</code></li>
<li><code>[4, 4]</code></li>
</ul>
<p>I tried using <code>array_search</code>(<code>array_search($result, $selections)</code>), but it only wwors if the elements are in order.</p>
<p>Of course, I can write a custom function to iterate through the multidimentional array and check the intersection, but I'm checking if there's a cleaner way to do this.</p>
| [
{
"answer_id": 74370857,
"author": "Alexander Loginov",
"author_id": 10200816,
"author_profile": "https://Stackoverflow.com/users/10200816",
"pm_score": 0,
"selected": false,
"text": "<?php\n\n$a = [1,2,3];\n$b = [3,4,5];\n\n$result = [3,1];\n\nfunction isOK($a, $b, $result):bool {\n return $result[1] && in_array($result[0], $a) && in_array($result[1], $b);\n}\n\n$isOK = isOK($a, $b, $result) || isOK($a, $b, array_reverse($result));\n\nvar_dump($isOK);\n"
},
{
"answer_id": 74370963,
"author": "mickmackusa",
"author_id": 2943403,
"author_profile": "https://Stackoverflow.com/users/2943403",
"pm_score": 3,
"selected": true,
"text": "var_export(\n $result[0] !== $result[1] \n && (\n (in_array($result[0], $a) && in_array($result[1], $b))\n || (in_array($result[0], $b) && in_array($result[1], $a))\n )\n);\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16005410/"
] |
74,370,366 | <p>I'm setting up an API and running into this problem. Can you explain the issue to me and help me solve this issue? Thanks</p>
<p>From Postman:</p>
<pre><code>{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-126b1240f4b8ded273f6f4c63fc7e1f6-53d97b7f1d5afc42-00",
"errors": {
"$": [
"The JSON value could not be converted to HostSimulatorLibrary.Models.OutgoingMessageModel. Path: $ | LineNumber: 0 | BytePositionInLine: 1."
],
"message": [
"The message field is required."
]
}
}
</code></pre>
<p>My Controller:</p>
<pre><code>// POST api/Messages
[HttpPost]
public async Task<ActionResult<OutgoingMessageModel>> Post([FromBody] OutgoingMessageModel message )
{
var output = _data.SendSocketResponse(message);
return Ok(output);
}
</code></pre>
<p>My Model:</p>
<pre><code>namespace HostSimulatorLibrary.Models;
public class OutgoingMessageModel
{
public int RequestID { get; set; }
public string? ResultText { get; set; }
}
</code></pre>
<p>My Input:</p>
<pre><code>[
{
"RequestID":1073388,
"ResultTX": "TEXT"
}
]
</code></pre>
<p>Also... I tried removing the brackets around my message object and received the following:</p>
<pre><code>System.NotSupportedException: Serialization and deserialization of 'System.Action' instances are not supported. Path: $.MoveNextAction.
---> System.NotSupportedException: Serialization and deserialization of 'System.Action' instances are not supported.
</code></pre>
| [
{
"answer_id": 74370857,
"author": "Alexander Loginov",
"author_id": 10200816,
"author_profile": "https://Stackoverflow.com/users/10200816",
"pm_score": 0,
"selected": false,
"text": "<?php\n\n$a = [1,2,3];\n$b = [3,4,5];\n\n$result = [3,1];\n\nfunction isOK($a, $b, $result):bool {\n return $result[1] && in_array($result[0], $a) && in_array($result[1], $b);\n}\n\n$isOK = isOK($a, $b, $result) || isOK($a, $b, array_reverse($result));\n\nvar_dump($isOK);\n"
},
{
"answer_id": 74370963,
"author": "mickmackusa",
"author_id": 2943403,
"author_profile": "https://Stackoverflow.com/users/2943403",
"pm_score": 3,
"selected": true,
"text": "var_export(\n $result[0] !== $result[1] \n && (\n (in_array($result[0], $a) && in_array($result[1], $b))\n || (in_array($result[0], $b) && in_array($result[1], $a))\n )\n);\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12140908/"
] |
74,370,367 | <p>I have tried many solutions but all in vain, including this
<a href="https://stackoverflow.com/questions/74334162/react-native-android-build-failure-with-different-errors-without-any-changes-in">React Native Android build failure with different errors without any changes in code for past days due to publish of React Native version 0.71.0-rc.0</a>
I am having deadline ahead and my project is not building from last 4 days, any help will be appreciated.</p>
<pre class="lang-js prettyprint-override"><code>* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.activity:activity-compose:1.4.0.
AAR metadata file: /Users/dev/.gradle/caches/transforms-2/files-2.1/c35837abe789834d04f87678613d3ab9/jetified-activity-compose-1.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
</code></pre>
<p>I have tried compileSdkVersion = 31
targetSdkVersion = 31
after that I am getting</p>
<pre class="lang-js prettyprint-override"><code>Execution failed for task ':react-native-incall-manager:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
</code></pre>
<p>My build.gradle file is</p>
<pre class="lang-js prettyprint-override"><code>// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
androidXCore = "1.7.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.1")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
</code></pre>
<p>React native version is "^0.66.3"</p>
| [
{
"answer_id": 74371040,
"author": "ZFloc Technologies",
"author_id": 10657559,
"author_profile": "https://Stackoverflow.com/users/10657559",
"pm_score": 3,
"selected": true,
"text": "node_modules"
},
{
"answer_id": 74373276,
"author": "A. kanojia",
"author_id": 7109301,
"author_profile": "https://Stackoverflow.com/users/7109301",
"pm_score": 0,
"selected": false,
"text": "Ex: if you are on 0.64.3, change to 0.64.4"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13884276/"
] |
74,370,375 | <p>I am currently trying to load a .obj model into my three.js project. I feel like I have all the code correct becasuse my code compiles without any errors, but when I go to Google Chrome's console it is giving me this error. <a href="https://i.stack.imgur.com/hXMES.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hXMES.png" alt="enter image description here" /></a>.</p>
<p>mainpage.html</p>
<p><a href="https://i.stack.imgur.com/6iMYA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6iMYA.png" alt="[](https://i.stack.imgur.com/cVOeN.png)" /></a></p>
<p>mainpage.js</p>
<p><a href="https://i.stack.imgur.com/qdlwG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qdlwG.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74378268,
"author": "JulianDotExe",
"author_id": 20165430,
"author_profile": "https://Stackoverflow.com/users/20165430",
"pm_score": 3,
"selected": true,
"text": "<body>\n\n <script src = \"../node_modules/three/build/three.js\"></script> \n <script type = \"module\" src = \"../public/mainpage.js\"></script>\n\n</body>\n"
},
{
"answer_id": 74455623,
"author": "ben_stays_anonymous",
"author_id": 19883076,
"author_profile": "https://Stackoverflow.com/users/19883076",
"pm_score": 0,
"selected": false,
"text": "<script type=\"importmap\">\n {\n \"imports\": {\n \"three\": \"../build/three.module.js\",\n \"three/addons/\": \"./jsm/\"\n }\n }\n </script>\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19883076/"
] |
74,370,411 | <p>I want to add an edit button and delete image dynamically to table, but it is showing error
Page Not Found at
Request URL: <a href="http://127.0.0.1:8000/%7B%25%20url%20%27expense-edit%27%20expense.id%20%25%7D" rel="nofollow noreferrer">http://127.0.0.1:8000/%7B%25%20url%20'expense-edit'%20expense.id%20%25%7D</a></p>
<p>here is js file</p>
<pre><code>const searchField = document.querySelector("#searchField");
const tableOutput = document.querySelector(".table-output");
const appTable = document.querySelector(".app-table");
const paginationContainer = document.querySelector(".pagination-container");
tableOutput.style.display = 'none';
const noResults = document.querySelector(".no-results");
const tbody = document.querySelector(".table-body");
searchField.addEventListener('keyup', (e) => {
const searchValue = e.target.value;
if (searchValue.trim().length > 0) {
paginationContainer.style.display = "none";
tbody.innerHTML = "";
fetch("http://127.0.0.1:8000/search-expenses", {
body: JSON.stringify({ searchText: searchValue }),
method: "POST",
})
.then((res) => res.json())
.then((data) => {
console.log("data", data);
appTable.style.display = "none";
tableOutput.style.display = "block";
console.log("data.length", data.length);
if (data.length === 0) {
noResults.style.display = "block";
tableOutput.style.display = "none";
}
else {
noResults.style.display = "none";
data.forEach((item) => {
tbody.innerHTML += `
<tr>
<td>${item.amount}</td>
<td>${item.category}</td>
<td>${item.description}</td>
<td>${item.date}</td>
<td><a href="{% url 'expense-edit' expense.id %}" class="btn btn-secondary btn-sm">Edit</a><a href="{% url 'expense-delete' expense.id %}"><img src="{% static 'img/delete.png' %}" width="35" height="35"/></a></td>
</tr>`;
});
}
});
}
else {
noResults.style.display = "none";
tableOutput.style.display = "none";
appTable.style.display = "block";
paginationContainer.style.display = "block";
}
});
</code></pre>
<p>urls.py</p>
<pre><code>
from django.urls import path
from . import views
from django.views.decorators.csrf import csrf_exempt
urlpatterns = [
path('', views.home, name="home"),
path('expenses', views.index, name='expenses'),
path('add-expenses', views.add_expenses, name='add-expenses'),
path('edit-expense/<int:id>', views.expense_edit, name='expense-edit'),
path('expense-delete/<int:id>', views.delete_expense, name='expense-delete'),
path('search-expenses', csrf_exempt(views.search_expenses), name='search_expenses'),
path('expense_category_summary', views.expense_category_summary, name="expense_category_summary"),
path('stats', views.stats_view, name="stats"),
path('export_csv', views.export_csv, name="export-csv"),
path('export_excel', views.export_excel, name="export-excel"),
path('export_pdf', views.export_pdf, name="export-pdf"),
]
</code></pre>
<p>I want to add a button that has a link to the next page through JavaScript using the Django URL template tag. thanks in advance</p>
| [
{
"answer_id": 74370473,
"author": "Manoj Tolagekar",
"author_id": 17808039,
"author_profile": "https://Stackoverflow.com/users/17808039",
"pm_score": 0,
"selected": false,
"text": "<a href=\"{% url 'expense-edit' expense.id %}\" class=\"btn btn-secondary btn-sm\">Edit</a><a href=\"{% url 'expense-delete' expense.id %}\"><img src=\"{% static 'img/delete.png' %}\" width=\"35\" height=\"35\"/></a></td>\n"
},
{
"answer_id": 74370627,
"author": "ilyasbbu",
"author_id": 16475089,
"author_profile": "https://Stackoverflow.com/users/16475089",
"pm_score": 1,
"selected": false,
"text": "{% url 'expense-edit' expense.id %}"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20456219/"
] |
74,370,425 | <p>Need a solution to add a Shake View with a progress bar. This view is used as a Toast View in Android, I got a solution such that the View grows from the center and needs help in transforming into the expected result.
The current state is zipped in the drive with the actual video & expected video.</p>
<p><a href="https://drive.google.com/drive/folders/1YT4DFEyrV1V0kDRqbLCfiq2xfqscnoPK?usp=sharing" rel="nofollow noreferrer">Video and Current state source code</a></p>
<p>I tried this growFromCenter Extension function, I even tried using Object animator but got blocked while combining it with the progress bar.</p>
<pre><code>private fun View.growFromCenter(
duration: Long,
@FloatRange(from = 0.0, to = 1.0)
startScaleRatio: Float,
endAnimCallback: () -> Unit = {},
) {
val growFromCenter = ScaleAnimation(
startScaleRatio,
1f,
startScaleRatio,
1f,
Animation.RELATIVE_TO_SELF,
0.5f,
Animation.RELATIVE_TO_SELF,
0.5f
)
growFromCenter.duration = duration
growFromCenter.fillAfter = true
growFromCenter.interpolator = FastOutSlowInInterpolator()
growFromCenter.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(p0: Animation?) {
}
override fun onAnimationEnd(p0: Animation?) {
endAnimCallback.invoke()
}
override fun onAnimationRepeat(p0: Animation?) {
}
})
startAnimation(growFromCenter)
}
</code></pre>
| [
{
"answer_id": 74422828,
"author": "Jabbar",
"author_id": 16930239,
"author_profile": "https://Stackoverflow.com/users/16930239",
"pm_score": 2,
"selected": false,
"text": "SnackProgressBar"
},
{
"answer_id": 74458230,
"author": "Muhammad Ibrahim",
"author_id": 13935335,
"author_profile": "https://Stackoverflow.com/users/13935335",
"pm_score": 2,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<set \nxmlns:android=\"http://schemas.android.com/apk/res/android\"\nandroid:fillAfter=\"true\">\n<scale\n android:duration=\"350\"\n android:fromXScale=\"0.0\"\n android:fromYScale=\"0.5\"\n android:pivotX=\"100%\"\n android:pivotY=\"50%\"\n android:toXScale=\"1.0\"\n android:toYScale=\"1.0\" />\n<translate\n android:duration=\"175\"\n android:fromXDelta=\"0%\"\n android:repeatCount=\"5\"\n android:repeatMode=\"reverse\"\n android:toXDelta=\"7%\" />\n</set>\n"
},
{
"answer_id": 74487121,
"author": "Aniruddh Parihar",
"author_id": 8031784,
"author_profile": "https://Stackoverflow.com/users/8031784",
"pm_score": 0,
"selected": false,
"text": " val snackBarView = Snackbar.make(view, \"SnackBar Message\" , Snackbar.LENGTH_LONG)\n val view = snackBarView.view\n val params = view.layoutParams as FrameLayout.LayoutParams\n params.gravity = Gravity.TOP\n view.layoutParams = params\n view.background = ContextCompat.getDrawable(context,R.drawable.custom_drawable) // for custom background\n snackBarView.animationMode = BaseTransientBottomBar.ANIMATION_MODE_FADE\n snackBarView.show()\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4083142/"
] |
74,370,438 | <p>I am using Room databse in android and I want to update it by using object.</p>
<p>I want to do this. Is it possible?
`</p>
<pre><code>
@Query("UPDATE video_info_table SET videoStatus = :model.videoStatus WHERE id = :model.id")
fun delete(model: FileModelClass)
</code></pre>
<p>`</p>
| [
{
"answer_id": 74370527,
"author": "Somnath",
"author_id": 15660680,
"author_profile": "https://Stackoverflow.com/users/15660680",
"pm_score": 0,
"selected": false,
"text": "@Query(\"UPDATE video_info_table SET videoStatus =:status WHERE id = :id\")\nvoid update(String status, int id);\n"
},
{
"answer_id": 74370529,
"author": "MikeT",
"author_id": 4744514,
"author_profile": "https://Stackoverflow.com/users/4744514",
"pm_score": 3,
"selected": true,
"text": "@Update\nfun update(model: FileModelClass)\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10807840/"
] |
74,370,457 | <p>I am trying to remove an object from an existing <code>JArray</code>, but when I run the method to delete the property from the <code>JArray</code>, the property still exists.</p>
<p>I tried simply using the code below</p>
<pre class="lang-cs prettyprint-override"><code>JObject rss1 = JObject.Parse(File.ReadAllText("online.json"));
JObject uList = (JObject)rss1["uList"];
JArray newOnline = (JArray)uList["online"];
newOnline.Remove("value");
</code></pre>
<p>The code above is almost directly copied and pasted from the Newtonsoft.Json documentation on modifying Json, but only changed to remove the new item instead of adding it. I've tried other post's solutions, but none of them work. Adding the field works as expected, but trying to remove it does not work whatsoever.</p>
<p>Below is the JSON file's contents</p>
<pre class="lang-json prettyprint-override"><code>{
"uList": {
"placeHolder": "placeHolderValue",
"online": [
"value"
]
}
}
</code></pre>
<p>Below is the expected JSON output of the code being ran</p>
<pre class="lang-json prettyprint-override"><code>{
"uList": {
"placeHolder": "placeHolderValue",
"online": [
]
}
}
</code></pre>
<p>And, below, is the actual output of the code being ran</p>
<pre class="lang-json prettyprint-override"><code>{
"uList": {
"placeHolder": "placeHolderValue",
"online": [
"value"
]
}
}
</code></pre>
<p>Am I doing something wrong and not realizing it?</p>
| [
{
"answer_id": 74370639,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 2,
"selected": false,
"text": "string"
},
{
"answer_id": 74371043,
"author": "Prasad Telkikar",
"author_id": 6299857,
"author_profile": "https://Stackoverflow.com/users/6299857",
"pm_score": 1,
"selected": true,
"text": "value"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18762634/"
] |
74,370,533 | <p>trying to upload a an image file using Java selenium</p>
<p>Hi all, I am trying to upload a an image file using Java selenium</p>
<p>below is the code:<br />
first approach:</p>
<pre><code>WebElement upload_file = driver.findElement(By.xpath("xpath of upload button"));
upload_file .click();
// just passed a delay, it does not crate a problem I can remove it
java.lang.Thread.sleep(2000);
//full file path present in my local machine
uplaod_file.sendKeys("C:\\Users\\Lenovo\\Pictures\\Files\\image.jpg");
System.out.println("File is Uploaded Successfully");
</code></pre>
<p>Issue observed :org.openqa.selenium.ElementNotInteractableException: element not interactable</p>
<p>Second approach:</p>
<pre><code> By upload_file_button = By.xpath("xpath of upload button");
explicit_wait.until(ExpectedConditions.elementToBeClickable(upload_file_button));
driver.findElement(upload_file_button).click();
java.lang.Thread.sleep(2000);
((WebElement) upload_file_button).sendKeys("C:\\Users\\Lenovo\\Pictures\\Files\\image.jpg");
System.out.println("File is Uploaded Successfully");
</code></pre>
<p>Issue observed : org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: xpath of upload button (tried for 20 second(s) with 500 milliseconds interval)</p>
<p>need help for same, please do correct me If I am wrong.</p>
| [
{
"answer_id": 74371393,
"author": "Tal Angel",
"author_id": 5359846,
"author_profile": "https://Stackoverflow.com/users/5359846",
"pm_score": 0,
"selected": false,
"text": "upload_file.sendKeys(\"C:\\\\Users\\\\Lenovo\\\\Pictures\\\\Files\\\\image.jpg\");\nupload_button = driver.findElement(By.Xpath, '//*[text()=\"upload\"]');\nupload_button.click();\n"
},
{
"answer_id": 74372047,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 1,
"selected": false,
"text": "input"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20456170/"
] |
74,370,538 | <p>Need help for converting an array to array of object adding label.</p>
<p>For example I have an array:</p>
<pre><code>data = ["data1", "data2", "data3"]
</code></pre>
<p>I want to convert and adding label.
The result expected:</p>
<pre><code>[
{label: "data1", value: "data1"},
{label: "data2", value: "data2"},
{label: "data3", value: "data3"}
]
</code></pre>
| [
{
"answer_id": 74370563,
"author": "Sahil jangra",
"author_id": 19977538,
"author_profile": "https://Stackoverflow.com/users/19977538",
"pm_score": 1,
"selected": false,
"text": "const data = [\"data1\", \"data2\", \"data3\"];\nconst object = [];\ndata.forEach((element) => {\n const obj = { label: element, value: element };\n object.push(obj);\n});\nconsole.log(object);\n"
},
{
"answer_id": 74370573,
"author": "Amaarockz",
"author_id": 11281152,
"author_profile": "https://Stackoverflow.com/users/11281152",
"pm_score": 0,
"selected": false,
"text": "reduce"
},
{
"answer_id": 74370574,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 3,
"selected": true,
"text": "data.map(d => ({label:d,value:d}))"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8861535/"
] |
74,370,544 | <p>I am new to Java, and I am trying to get a Field Goal percentage calculation, and the output keeps giving me 0. Not sure if it has something to do with my constructor, or if it is not pulling the correct info out of my array.</p>
<pre><code>public Player(String newName, int newnumMade, int newnumAttempt)
{
name = newName;
numAttempt = newnumAttempt;
numMade = newnumMade;
if(newnumAttempt < newnumMade)
{
numMade = newnumAttempt;
numAttempt = newnumMade;
}
else
{
numAttempt = newnumAttempt;
numMade = newnumMade;
}
}
</code></pre>
<pre><code>public double getfgPercentage()
{
if(numAttempt > 0)
{
double first = (double)numMade / numAttempt;
fgPercentage = first * 100;
}
return fgPercentage;
}
</code></pre>
<p>I understand that int division always gives an int so I converted one of my ints into a double. Ive tested out multiple ways adding two numbers just to see if it would work, but the output is constantly giving me 0.</p>
| [
{
"answer_id": 74370563,
"author": "Sahil jangra",
"author_id": 19977538,
"author_profile": "https://Stackoverflow.com/users/19977538",
"pm_score": 1,
"selected": false,
"text": "const data = [\"data1\", \"data2\", \"data3\"];\nconst object = [];\ndata.forEach((element) => {\n const obj = { label: element, value: element };\n object.push(obj);\n});\nconsole.log(object);\n"
},
{
"answer_id": 74370573,
"author": "Amaarockz",
"author_id": 11281152,
"author_profile": "https://Stackoverflow.com/users/11281152",
"pm_score": 0,
"selected": false,
"text": "reduce"
},
{
"answer_id": 74370574,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 3,
"selected": true,
"text": "data.map(d => ({label:d,value:d}))"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20456375/"
] |
74,370,580 | <p>A print button is provided in the Rust book. After clicking it, a single page is created from all contents and printing options are displayed.</p>
<p><a href="https://doc.rust-lang.org/book/print.html" rel="nofollow noreferrer">https://doc.rust-lang.org/book/print.html</a></p>
<p>For Hugo template, I want to create a printed page similar to the Rust book and I checked <a href="https://gohugo.io/templates/output-formats" rel="nofollow noreferrer">Custom Output Format</a> but doesn't find solution for solve this issue.</p>
| [
{
"answer_id": 74370563,
"author": "Sahil jangra",
"author_id": 19977538,
"author_profile": "https://Stackoverflow.com/users/19977538",
"pm_score": 1,
"selected": false,
"text": "const data = [\"data1\", \"data2\", \"data3\"];\nconst object = [];\ndata.forEach((element) => {\n const obj = { label: element, value: element };\n object.push(obj);\n});\nconsole.log(object);\n"
},
{
"answer_id": 74370573,
"author": "Amaarockz",
"author_id": 11281152,
"author_profile": "https://Stackoverflow.com/users/11281152",
"pm_score": 0,
"selected": false,
"text": "reduce"
},
{
"answer_id": 74370574,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 3,
"selected": true,
"text": "data.map(d => ({label:d,value:d}))"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8415350/"
] |
74,370,592 | <p>I have an HTML file structure as below with hundred of such elements in main tag:</p>
<pre class="lang-html prettyprint-override"><code><main>
<div id="rows">
<p data-name="First Element">
<a target="_blank" href="localhost">
<strong>First Element</strong>
</a>
<strong class="date-field" data-date="2016-06-27">6 years</strong>
</p>
<p data-name="Second Element">
<a target="_blank" href="localhost">
<strong>Second Element</strong>
</a>
<strong class="date-field" data-date="2016-06-27">6 years</strong>
</p>
</div>
</main>
</code></pre>
<ol>
<li>In the first step, I want to find all <code><p></code> elements that have the <code>data-name</code> attribute,</li>
<li>and next for each p element I want to select the <code>strong</code> tag which has the <code>data-date</code> attribute</li>
<li>and the last extract these tags href and values in selected tags</li>
</ol>
<pre><code>from bs4 import BeautifulSoup
file = open('index.html', 'r')
file_text = file.read()
soup = BeautifulSoup(file_text, "html.parser")
results = soup.find("main").find(id="rows")
</code></pre>
| [
{
"answer_id": 74370563,
"author": "Sahil jangra",
"author_id": 19977538,
"author_profile": "https://Stackoverflow.com/users/19977538",
"pm_score": 1,
"selected": false,
"text": "const data = [\"data1\", \"data2\", \"data3\"];\nconst object = [];\ndata.forEach((element) => {\n const obj = { label: element, value: element };\n object.push(obj);\n});\nconsole.log(object);\n"
},
{
"answer_id": 74370573,
"author": "Amaarockz",
"author_id": 11281152,
"author_profile": "https://Stackoverflow.com/users/11281152",
"pm_score": 0,
"selected": false,
"text": "reduce"
},
{
"answer_id": 74370574,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 3,
"selected": true,
"text": "data.map(d => ({label:d,value:d}))"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5515287/"
] |
74,370,598 | <pre><code>how do i get the rupee symbol on the Y axis of the vega charts, i m getting the doller($) symbol through format but not getting rupee symbol
"axes": [
{
"orient": "bottom",
"scale": "x",
"labelAngle": -90,
"labelPadding": 29,
"format": "Q%q %Y",
"ticks": true,
"tickCount": "month",
"labelFontSize": 11
},
{"orient": "left", "scale": "y", "tickCount": 5,"format": "$,f"}
],
</code></pre>
<pre><code>"format": "$,f"
</code></pre>
<p>how do i get the rupee symbol on the Y axis of the vega charts, i m getting the doller($) symbol through format but not getting rupee symbol</p>
| [
{
"answer_id": 74378195,
"author": "Roy Ing",
"author_id": 17338310,
"author_profile": "https://Stackoverflow.com/users/17338310",
"pm_score": 2,
"selected": true,
"text": "\"axes\": [\n { \"orient\": \"bottom\", \"scale\": \"xscale\" },\n\n { \"orient\": \"left\", \n \"scale\": \"yscale\",\n \"encode\": {\n \"labels\": {\n \"update\": {\n \"text\": {\"signal\": \"'\\\\u20B9 ' + format(datum.value, '.2f')\"},\n \"fill\": {\"value\": \"steelblue\"},\n \"angle\": {\"value\": 0},\n \"fontSize\": {\"value\": 12},\n \"align\": {\"value\": \"right\"},\n \"baseline\": {\"value\": \"middle\"},\n \"dx\": {\"value\": -5}\n }\n }\n }\n }\n\n ],\n"
},
{
"answer_id": 74549406,
"author": "Roy Ing",
"author_id": 17338310,
"author_profile": "https://Stackoverflow.com/users/17338310",
"pm_score": 0,
"selected": false,
"text": " vega.expressionFunction(\"formatLakh\", (num) => new Intl.NumberFormat('en-IN', {style: \"currency\", currency: \"INR\", maximumFractionDigits: 2}).format(num));\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20456377/"
] |
74,370,616 | <p>Beginner here. I've just learned the basics of python using VS. I don't know why I get a syntax error in the VSCode text file but not on the terminal for the command.
Any assistance helping me understand would be great, thank you.
<a href="https://i.stack.imgur.com/Lxjhe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lxjhe.png" alt="screenshot of vscode" /></a></p>
<p>Tried to install boto3 with pip.</p>
| [
{
"answer_id": 74378195,
"author": "Roy Ing",
"author_id": 17338310,
"author_profile": "https://Stackoverflow.com/users/17338310",
"pm_score": 2,
"selected": true,
"text": "\"axes\": [\n { \"orient\": \"bottom\", \"scale\": \"xscale\" },\n\n { \"orient\": \"left\", \n \"scale\": \"yscale\",\n \"encode\": {\n \"labels\": {\n \"update\": {\n \"text\": {\"signal\": \"'\\\\u20B9 ' + format(datum.value, '.2f')\"},\n \"fill\": {\"value\": \"steelblue\"},\n \"angle\": {\"value\": 0},\n \"fontSize\": {\"value\": 12},\n \"align\": {\"value\": \"right\"},\n \"baseline\": {\"value\": \"middle\"},\n \"dx\": {\"value\": -5}\n }\n }\n }\n }\n\n ],\n"
},
{
"answer_id": 74549406,
"author": "Roy Ing",
"author_id": 17338310,
"author_profile": "https://Stackoverflow.com/users/17338310",
"pm_score": 0,
"selected": false,
"text": " vega.expressionFunction(\"formatLakh\", (num) => new Intl.NumberFormat('en-IN', {style: \"currency\", currency: \"INR\", maximumFractionDigits: 2}).format(num));\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15790774/"
] |
74,370,626 | <p>This might be trivial but I can't figure it out and can't find it online.
Let's say I survey people asking the reason they did something.
Two options: reason 1 and reason 2. They can also pick both options.</p>
<pre><code>data <- data.frame('reason'=c(rep('R1', 5),rep('R2', 3),rep('R1,R2', 4)))
data
reason
1 R1
2 R1
3 R1
4 R1
5 R1
6 R2
7 R2
8 R2
9 R1,R2
10 R1,R2
11 R1,R2
12 R1,R2
</code></pre>
<p>I want to plot the answers, but only counting R1 and R2. That is, if they answered R1 and R2 assign 1 count to each. The command,</p>
<pre><code>ggplot(data = data, aes(x = reason)) + geom_bar() + coord_flip()
</code></pre>
<p>would plot the multiple answer cases as a separate category.
<a href="https://i.stack.imgur.com/G3hWS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G3hWS.png" alt="enter image description here" /></a></p>
<p>What I want instead is R1 to have a count of 5+4=9 and R2 to have a count of 3+4=7, and no R1,R2 category.</p>
<p>I am interested in this because I have real data from a Qualtrics survey</p>
| [
{
"answer_id": 74370720,
"author": "stefan",
"author_id": 12993861,
"author_profile": "https://Stackoverflow.com/users/12993861",
"pm_score": 2,
"selected": false,
"text": "tidyr::separate_rows"
},
{
"answer_id": 74370725,
"author": "Edward",
"author_id": 7514527,
"author_profile": "https://Stackoverflow.com/users/7514527",
"pm_score": 0,
"selected": false,
"text": "mutate(data, \n R1=grepl('R1', reason),\n R2=grepl('R2', reason)) %>%\n select(-reason) %>%\n pivot_longer(everything(), names_to=\"reason\") %>%\n filter(value) %>%\n count(reason) %>%\n print() %>%\n ggplot(aes(x=reason, y=n)) +\n geom_col() +\n coord_flip()\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2424489/"
] |
74,370,634 | <p>I have my own servers and have hosted a few services (game servers, web servers, ...), and use to host these on a publicly accessible dynamic IP using DuckDNS.</p>
<p>I have recently moved to a rural area and use a satellite service for my internet that does not support publicly accessible IP address.</p>
<p>I would really like to host these things again, but the only way I can think of doing that, is to have an IP somewhere in the cloud and route that back into my network. I have been messing around in Azure but I can't seem to get what I want working. I am not stuck on Azure, just happens to be the one I am message about with.</p>
<p>I have pfSense as my router, so I can setup a VPN client on that and pretty much keep that alive indefinitely, so here is what I am thinking and I hope someone can point my in the right direction, or if you like, poke holes in the idea.</p>
<ol>
<li>I configure a VPN client on pfSense to be an WAN interface</li>
<li>create a VPN gateway in the cloud</li>
<li>connect pfSense VPN client to the VPN gateway</li>
<li>create a static external IP in the cloud</li>
<li>route traffic from the external ip through the VPN back to my pfSense server and into my internal network</li>
</ol>
<p>once I get the traffic coming into pfSense , I can route to computers / VMs on my internal network.</p>
<p>This way, I do not need a publicly accessible IP from my ISP, I can connect to the Azure and use its external IP and route back through the VPN to my internal network.</p>
<p>If this was real hardware, I would have had this built in 30 minutes, seems this virtual world is messing me up.</p>
<p>Any ideas on how to configure this or maybe another solution?</p>
<p>I am struggling with the whole Azure setup and have watch hours of videos about each of the bit in Azure, but I am lacking some key bits of knowledge to bring this together.</p>
| [
{
"answer_id": 74370720,
"author": "stefan",
"author_id": 12993861,
"author_profile": "https://Stackoverflow.com/users/12993861",
"pm_score": 2,
"selected": false,
"text": "tidyr::separate_rows"
},
{
"answer_id": 74370725,
"author": "Edward",
"author_id": 7514527,
"author_profile": "https://Stackoverflow.com/users/7514527",
"pm_score": 0,
"selected": false,
"text": "mutate(data, \n R1=grepl('R1', reason),\n R2=grepl('R2', reason)) %>%\n select(-reason) %>%\n pivot_longer(everything(), names_to=\"reason\") %>%\n filter(value) %>%\n count(reason) %>%\n print() %>%\n ggplot(aes(x=reason, y=n)) +\n geom_col() +\n coord_flip()\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20456308/"
] |
74,370,658 | <p>We have a django project in which we are storing images in the backend using image field.The image link is being stored on django admin site.However ,when I click on the link ,I get an error page.Here's my code.
<em><strong>models.py</strong></em></p>
<pre><code> images=models.ImageField(upload_to=upload_to,null=True)
def upload_to(instance, filename):
return 'images/{filename}'.format(filename=filename)
</code></pre>
<p><em><strong>urls.py</strong></em></p>
<pre><code>urlpatterns = [
path('admin/', admin.site.urls),
path('app/',include('firstapp.urls')),
path('',include('firstapp.api.urls')),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
</code></pre>
<p><em><strong>settings.py</strong></em></p>
<pre><code>MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media')
# URL used to access the media
MEDIA_URL = '/media/'
</code></pre>
<hr />
<p>I have created a folder named media but the images are not being stored there.Please help.</p>
| [
{
"answer_id": 74370712,
"author": "Manoj Tolagekar",
"author_id": 17808039,
"author_profile": "https://Stackoverflow.com/users/17808039",
"pm_score": 0,
"selected": false,
"text": "MEDIA_ROOT=os.path.join(BASE_DIR,'media') #Just add like this\n"
},
{
"answer_id": 74370865,
"author": "Ankit Tiwari",
"author_id": 14457833,
"author_profile": "https://Stackoverflow.com/users/14457833",
"pm_score": 1,
"selected": false,
"text": "os.path.dirname(...)"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16601612/"
] |
74,370,673 | <p>I want to <code>git push</code> on Ubuntu via a single command, such as:</p>
<pre class="lang-bash prettyprint-override"><code>echo -e "email\ntoken" | git push origin branchName
git push origin branchName && email && token
</code></pre>
<p>But after the command I have to put in my email:</p>
<p><a href="https://i.stack.imgur.com/VBl0i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VBl0i.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74370917,
"author": "Dan Bonachea",
"author_id": 3528321,
"author_profile": "https://Stackoverflow.com/users/3528321",
"pm_score": 1,
"selected": true,
"text": "git remote -vv"
},
{
"answer_id": 74370934,
"author": "Gabriel Staples",
"author_id": 4561887,
"author_profile": "https://Stackoverflow.com/users/4561887",
"pm_score": 1,
"selected": false,
"text": "# View your current remote servers and their URLs\ngit remote -v\n\n# Set your `origin` remote server to use the ssh URL instead\n# of the HTTPS one\ngit remote set-url origin https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world.git\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20137965/"
] |
74,370,681 | <p>dears, I cloned a simple project from Git hub .
It shows me a tons of error such as Flatt button,
is there any solution to use and lunch this project in Vscode.? or I should renew each peace of code which is deprecated?
here is the example: git address:
(gh repo clone asjqkkkk/flutter-todos)</p>
| [
{
"answer_id": 74370813,
"author": "Khyati Modi",
"author_id": 11647876,
"author_profile": "https://Stackoverflow.com/users/11647876",
"pm_score": 1,
"selected": false,
"text": "FlatButton "
},
{
"answer_id": 74370906,
"author": "MrShakila",
"author_id": 19292778,
"author_profile": "https://Stackoverflow.com/users/19292778",
"pm_score": 0,
"selected": false,
"text": "flutter clean"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20019751/"
] |
74,370,692 | <p>I am trying to subtract the value of count <code>routeid</code> from <code>capacity</code>.
It should be 350 - 1, I have no luck doing it code below</p>
<pre><code>(SELECT CAPACITY
FROM PLANE
WHERE SERIALNO = 'FH-FBT') -
(SELECT COUNT(ROUTEID)
FROM RESERVATION
WHERE ROUTEID = 'FBN001')
</code></pre>
| [
{
"answer_id": 74371278,
"author": "gsalem",
"author_id": 7398653,
"author_profile": "https://Stackoverflow.com/users/7398653",
"pm_score": 0,
"selected": false,
"text": "SELECT CAPACITY -(SELECT COUNT(ROUTEID)\n FROM RESERVATION \n WHERE ROUTEID = 'FBN001') \n FROM PLANE \n WHERE SERIALNO = 'FH-FBT' \n"
},
{
"answer_id": 74371535,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 2,
"selected": true,
"text": "dataset - dataset"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2906598/"
] |
74,370,714 | <p>I used to run this bot on replit with no code issues, but after it wiped some JSON files and got API banned, I switched to running it on my PC through VSCode. All functionality works fine, except it doesn't get any response from on_member_update anymore. I didn't change any of the code here, and made sure that all my intents were sorted as well. any ideas?</p>
<pre><code>import os
from os import path
import discord
import asyncio
from datetime import datetime, date
from pytz import timezone
from keep_alive import keep_alive
import json
from dotenv import load_dotenv
from heapq import nlargest
import random
from discord.ext import commands
load_dotenv()
client = discord.Client(intents=discord.Intents.all())
@client.event
async def on_member_update(before, after):
print('presence detected')
client.run(TOKEN)
</code></pre>
<p>Of course the vast majority of the code is filtered out, but I feel like this has all the relevant info. Starts fine, runs fine, modifies files fine, doesn't work with detecting presence changes in members. I tried copying the exact code over to replit again, and it detects just fine over there, so it's not the bot settings itself I believe. Maybe i'm missing some import or didn't download a pip or something that it hasn't warned me about? Any help would be great.</p>
<p>Edit 1: Still haven't found a solution to it, but I switched from on_member_update to on_presence_update, which seems to be functionally the same for my purposes. I'm still curious about what's going on though if anyone comes along.</p>
| [
{
"answer_id": 74374794,
"author": "Daniel Andersen",
"author_id": 19635097,
"author_profile": "https://Stackoverflow.com/users/19635097",
"pm_score": 0,
"selected": false,
"text": "presence detected"
},
{
"answer_id": 74376847,
"author": "goose.mp4",
"author_id": 14655252,
"author_profile": "https://Stackoverflow.com/users/14655252",
"pm_score": -1,
"selected": false,
"text": "Bot"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20456474/"
] |
74,370,752 | <p>How do I make <code>NavigationView</code> call <code>onAppear()</code>(or any other functions) whenever it appears, especially when I back out from its child view?</p>
<p>I linked 3 <code>NavigationView</code>s in this way: <code>TestView</code> -> <code>SecondView</code> -> <code>ThirdView</code>, and I put <code>onAppear()</code> function on <code>TestView</code> and <code>SecondView</code>.</p>
<pre><code>struct TestView: View {
@State var text:String = "This is page 1"
var body: some View {
NavigationView {
VStack {
Text(text)
NavigationLink(
destination: SecondView(),
label: { Text("go to page2") }
)
}
}
.onAppear() {
text += " called+1 "
}
}
}
struct SecondView: View {
@State var text:String = "This is page 2"
var body: some View {
NavigationView {
VStack {
Text(text)
NavigationLink(
destination: ThirdView(),
label: { Text("go to page3") }
)
}
}
.onAppear() {
text += " called+1 "
}
}
}
struct ThirdView: View {
var body: some View {
Text("This is page 3")
}
}
</code></pre>
<p>From the function name <code>onAppear()</code>, I thought it would be invoked every time the view appears. However, it turns out it will only be invoked once when I go deeper into a new view, but <strong>NOT</strong> invoked when I back out from its child view.</p>
<p>In other words, when the app launches, <code>TestView</code>'s <code>onAppear()</code> will be called. Then, when I click <code>go to page2</code>, <code>SecondView</code>'s <code>onAppear()</code> will be called. Then I click <code>go to page3</code>, and then I click the <code>back</code> button on the <code>ThirdView</code>, <code>SecondView</code>'s <code>onAppear()</code> will bot be invoked, even though the current view is <code>SecondView</code>. And it is the same when I click <code>back</code> on the <code>SecondView</code>, the <code>TestView</code>'s <code>onAppear()</code> is not invoked again.</p>
<p>How to call <code>onAppear()</code> when I click <code>Back</code>, or used other method to achieve the same result.</p>
| [
{
"answer_id": 74371134,
"author": "workingdog support Ukraine",
"author_id": 11969817,
"author_profile": "https://Stackoverflow.com/users/11969817",
"pm_score": 2,
"selected": true,
"text": "TestView"
},
{
"answer_id": 74382564,
"author": "malhal",
"author_id": 259521,
"author_profile": "https://Stackoverflow.com/users/259521",
"pm_score": 0,
"selected": false,
"text": "NavigationView"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10349656/"
] |
74,370,764 | <p>I am making angular application and where I have an empty arrays like these :</p>
<pre><code>orders: Order[];
order_details: Product[];
</code></pre>
<p>Then i am making a service call in ngOnInit to store the data into orders array and order_details array,</p>
<pre><code>ngOnInit(): void {
this.getOrders();
}
</code></pre>
<p>This is the getOrders() function which is supposed to fetch every Order. Order object has an order_id, product_id list which has all the product ids of the products being ordered and order_time</p>
<pre><code>getOrders() {
this.order_service.getOrderList().subscribe({
next: (data) => {
this.orders = data;
for (let order of this.orders) {
for (let val of order.product_ids) {
this.product_service.getProductById(val).subscribe({
next: (data) => {this.order_details.push(data);}
});
}
}
},
});
console.log(this.order_details);
}
</code></pre>
<p>getOrderList() uses api to return all orders</p>
<pre><code> getOrderList(): Observable<Order[]> {
return this.http_client.get<Order[]>(`${this.baseURL}`);
}
</code></pre>
<p>getProductById() uses api to return product by id</p>
<pre><code> getProductById(id: number): Observable<Product> {
return this.http_client.get<Product>(`${this.baseURL}/${id}`);
}
</code></pre>
<p>The Order object and Product object have fields like</p>
<pre><code>export class Order{
order_id: number;
product_ids: number[];
order_time: String;
}
</code></pre>
<pre><code>export class Product{
product_id: number;
product_name: String;
product_image: String;
product_description: String;
product_price: String;
}
</code></pre>
<p>I am trying so with the getOrders() function to fetch every order and from every order I access the product id array and find every product by id and then populate the order_details array with these products by using push()</p>
<p>So I was expecting a order_details array with products corresponding to the product_ids mentioned for every order in the orders array</p>
<p>However on doing so, error is being thrown and the order_details array is undefined</p>
<p>ERROR TypeError: Cannot read properties of undefined (reading 'push')</p>
| [
{
"answer_id": 74370895,
"author": "Đỗ văn Thắng",
"author_id": 11303128,
"author_profile": "https://Stackoverflow.com/users/11303128",
"pm_score": 0,
"selected": false,
"text": "this.product_service.getProductById(val).subscribe({\n next: (data) => {this.order_details.push(data);}\n });"
},
{
"answer_id": 74370931,
"author": "Jan Schab",
"author_id": 14450532,
"author_profile": "https://Stackoverflow.com/users/14450532",
"pm_score": 1,
"selected": false,
"text": "order_details: Product[] = [];\n"
},
{
"answer_id": 74371016,
"author": "Fabian Strathaus",
"author_id": 17298437,
"author_profile": "https://Stackoverflow.com/users/17298437",
"pm_score": 0,
"selected": false,
"text": "order_details"
},
{
"answer_id": 74371268,
"author": "Chris Hamilton",
"author_id": 12914833,
"author_profile": "https://Stackoverflow.com/users/12914833",
"pm_score": 0,
"selected": false,
"text": "orders: Order[] = [];\norder_details: Product[] = [];\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20448477/"
] |
74,370,774 | <p>I have created a api where I am sending some json format data to third party. But there is one column name as <code>RFEDates</code> whose I am getting as</p>
<p><code>"RFEDates":"\/Date(-62135596800000)\/"</code> .</p>
<p>So is there any way where I can convert that date into proper date format in <code>(dd-MM-yyyy)</code> format.</p>
<p>Below is my code.</p>
<pre><code>public void CallMasterService(IPCOLO_BLOCKCHAIN_FIELDS ObjIp, out string Msg, out string ErrorMsg)
{
Msg = "";
ErrorMsg = "";
NEDataBlockChain Tobj = new NEDataBlockChain();
NEDataBlockChain[] ObjArrayNEdata = new NEDataBlockChain[1];
if (string.IsNullOrEmpty(ObjIp.R4GSTATE))
{
Tobj.R4GState = "ABC";
}
else
{
Tobj.R4GState = Convert.ToString(ObjIp.R4GSTATE);
}
if (string.IsNullOrEmpty(ObjIp.CMP))
{
Tobj.CMP = "CMPState";
}
else
{
Tobj.CMP = Convert.ToString(ObjIp.CMP);
}
if (string.IsNullOrEmpty(ObjIp.VENDOR_CODE))
{
Tobj.SAPVendorCode = "ABC1234";
}
else
{
Tobj.SAPVendorCode = Convert.ToString(ObjIp.VENDOR_CODE);
}
if (string.IsNullOrEmpty(ObjIp.IP_COLO_SITEID))
{
Tobj.IPColoSiteId = "IN-123456";
}
else
{
Tobj.IPColoSiteId = Convert.ToString(ObjIp.IP_COLO_SITEID);
}
if (string.IsNullOrEmpty(ObjIp.SAP_ID))
{
Tobj.SAPId = "I-AB-ABCD-ENB-I111";
}
else
{
Tobj.SAPId = Convert.ToString(ObjIp.SAP_ID);
}
if (string.IsNullOrEmpty(ObjIp.INFRA_PROVIDER))
{
Tobj.InfraProvider = "Test";
}
else
{
Tobj.InfraProvider = Convert.ToString(ObjIp.INFRA_PROVIDER);
}
if (string.IsNullOrEmpty(ObjIp.SITE_NAME))
{
Tobj.SiteName = "Test";
}
else
{
Tobj.SiteName = Convert.ToString(ObjIp.SITE_NAME);
}
if (string.IsNullOrEmpty(ObjIp.SITE_ADDRESS))
{
Tobj.SiteAddress = "Test";
}
else
{
Tobj.SiteAddress = Convert.ToString(ObjIp.SITE_NAME);
}
if (string.IsNullOrEmpty(ObjIp.TOWER_TYPE))
{
Tobj.TowerType = "Test";
}
else
{
Tobj.TowerType = Convert.ToString(ObjIp.TOWER_TYPE);
}
if (string.IsNullOrEmpty(ObjIp.TOWER_TYPE))
{
Tobj.TowerType = "Test";
}
else
{
Tobj.TowerType = Convert.ToString(ObjIp.TOWER_TYPE);
}
string strRFCsDate = DateTime.Now.ToString("dd-MM-yyyy", CultureInfo.InvariantCulture);
if (string.IsNullOrEmpty(ObjIp.RFCDATE))
{
Tobj.RFCDates = strRFCsDate;
}
else
{
Tobj.RFCDates = Convert.ToString(ObjIp.RFCDATE);
}
if (string.IsNullOrEmpty(ObjIp.ID_OD_COUNTCHANGE))
{
Tobj.ID_OD = "Test";
}
else
{
Tobj.ID_OD = Convert.ToString(ObjIp.ID_OD_COUNTCHANGE);
}
if (string.IsNullOrEmpty(ObjIp.DG_NONDG))
{
Tobj.DG_NonDG = "Test";
}
else
{
Tobj.DG_NonDG = Convert.ToString(ObjIp.DG_NONDG);
}
if (string.IsNullOrEmpty(ObjIp.EB_NONEB))
{
Tobj.Eb_NonEB = "Test";
}
else
{
Tobj.Eb_NonEB = Convert.ToString(ObjIp.EB_NONEB);
}
Tobj.status = "Active"; // site status
if (string.IsNullOrEmpty(ObjIp.CITY_NAME))
{
Tobj.City_Name = "Test";
}
else
{
Tobj.City_Name = Convert.ToString(ObjIp.CITY_NAME);
}
if (string.IsNullOrEmpty(ObjIp.NEID))
{
Tobj.NEID = "INRJRJKRXXXXTW6001";
}
else
{
Tobj.NEID = Convert.ToString(ObjIp.NEID);
}
if (string.IsNullOrEmpty(ObjIp.FACILITY_LATITUDE))
{
Tobj.FacilityLATITUDE = "10.22";
}
else
{
Tobj.FacilityLATITUDE = Convert.ToString(ObjIp.FACILITY_LATITUDE);
}
if (string.IsNullOrEmpty(ObjIp.FACILITY_LONGITUDE))
{
Tobj.FacilityLONGITUDE = "90.50";
}
else
{
Tobj.FacilityLONGITUDE = Convert.ToString(ObjIp.FACILITY_LONGITUDE);
}
if (string.IsNullOrEmpty(ObjIp.RJ_STRUCTURE_TYPE))
{
Tobj.RJ_STRUCTURE_TYPE = "ENODEB";
}
else
{
Tobj.RJ_STRUCTURE_TYPE = Convert.ToString(ObjIp.RJ_STRUCTURE_TYPE);
}
if (string.IsNullOrEmpty(ObjIp.RJ_JC_NAME))
{
Tobj.RJ_JC_NAME = "Test";
}
else
{
Tobj.RJ_JC_NAME = Convert.ToString(ObjIp.RJ_JC_NAME);
}
if (string.IsNullOrEmpty(ObjIp.RJ_JC_CODE))
{
Tobj.RJ_JC_CODE = "12345";
}
else
{
Tobj.RJ_JC_CODE = Convert.ToString(ObjIp.RJ_JC_CODE);
}
if (string.IsNullOrEmpty(ObjIp.COMPANY_CODE))
{
Tobj.CompanyCode = "Test";
}
else
{
Tobj.CompanyCode = Convert.ToString(ObjIp.COMPANY_CODE);
}
if (string.IsNullOrEmpty(ObjIp.POLITICAL_STATE_NAME))
{
Tobj.POLITICAL_STATE_NAME = "Test";
}
else
{
Tobj.POLITICAL_STATE_NAME = Convert.ToString(ObjIp.POLITICAL_STATE_NAME);
}
if (string.IsNullOrEmpty(ObjIp.POLITICAL_STATE_CODE))
{
Tobj.POLITICAL_STATE_CODE = "1234";
}
else
{
Tobj.POLITICAL_STATE_CODE = Convert.ToString(ObjIp.POLITICAL_STATE_CODE);
}
//Web Api logic starts here
ObjArrayNEdata[0] = Tobj;
string apiUrl = ConfigurationManager.AppSettings["WebApiUrl"].ToString();
var inputIPColoMaster = new
{
NEdata = ObjArrayNEdata,
};
string json = "";
string inputJsonIPColoMaster = "";
try
{
inputJsonIPColoMaster = (new JavaScriptSerializer()).Serialize(inputIPColoMaster);
WebClient client = new WebClient();
client.Headers["Content-type"] = "application/json";
client.Encoding = Encoding.UTF8;
json = client.UploadString(apiUrl, inputJsonIPColoMaster);
DataTable dtRes = new DataTable();
string GISSendDate = System.DateTime.Now.Date.ToString("dd-MM-yyyy", new System.Globalization.CultureInfo("en-US"));
StringReader sr = new StringReader(json);
dtRes = JsonConvert.DeserializeObject<DataTable>(json);
CommonDB ObjDB = new CommonDB();
if (dtRes != null && dtRes.Rows.Count > 0)
{
MasterServiceResponse MSRobj = new MasterServiceResponse();
GlobalVariables.WriteMessageInfoInLogFile("IPCOLOMaster : " + "SAPID: " + ObjIp.SAP_ID + " Response Code " + dtRes.Rows[0]["response-code"].ToString() + " Response Message" + dtRes.Rows[0]["response-message"].ToString());
}
if (dtRes != null && dtRes.Rows.Count > 0)
{
CommonDB objDB = new CommonDB();
ObjIp.BLCHAIN_RESP_MSG = Convert.ToString(dtRes.Rows[0]["response-message"]);
ObjIp.BLCHAIN_RESP_CODE = Convert.ToString(dtRes.Rows[0]["response-code"]);
CommonDB.UPDATE_BLOCK_CHAIN_INFO(ObjIp);
}
}
catch (Exception ex)
{
GlobalVariables.WriteMessageInfoInLogFile_Error("Error - Invalid : " + inputJsonIPColoMaster + "Ex Message :" + ex.Message + " Service response "+ json);
Msg = "1";
ErrorMsg = ex.Message.ToString();
}
}
</code></pre>
| [
{
"answer_id": 74370895,
"author": "Đỗ văn Thắng",
"author_id": 11303128,
"author_profile": "https://Stackoverflow.com/users/11303128",
"pm_score": 0,
"selected": false,
"text": "this.product_service.getProductById(val).subscribe({\n next: (data) => {this.order_details.push(data);}\n });"
},
{
"answer_id": 74370931,
"author": "Jan Schab",
"author_id": 14450532,
"author_profile": "https://Stackoverflow.com/users/14450532",
"pm_score": 1,
"selected": false,
"text": "order_details: Product[] = [];\n"
},
{
"answer_id": 74371016,
"author": "Fabian Strathaus",
"author_id": 17298437,
"author_profile": "https://Stackoverflow.com/users/17298437",
"pm_score": 0,
"selected": false,
"text": "order_details"
},
{
"answer_id": 74371268,
"author": "Chris Hamilton",
"author_id": 12914833,
"author_profile": "https://Stackoverflow.com/users/12914833",
"pm_score": 0,
"selected": false,
"text": "orders: Order[] = [];\norder_details: Product[] = [];\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1216804/"
] |
74,370,777 | <p>I'm trying to make a simple to-do list app and seem to be running up against some List View idiosyncracies. I have a View that produces this:</p>
<p><a href="https://i.stack.imgur.com/8FCw5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8FCw5.png" alt="enter image description here" /></a></p>
<pre><code>struct TestView: View {
var body: some View {
VStack(alignment: .leading) {
Text("Wash the laundry")
.font(.headline)
Spacer()
HStack {
Label("9 days ago", systemImage: "calendar")
Spacer()
Label("No assignee", systemImage: "person.fill")
.labelStyle(.trailingIcon)
.foregroundColor(.gray)
}
.font(.caption)
}
.padding()
}
}
struct TestView_Previews: PreviewProvider {
static var previews: some View {
TestView()
.previewLayout(.fixed(width: 400, height: 60))
}
}
</code></pre>
<p>And yet when I put it into a list, it comes out like:</p>
<p><a href="https://i.stack.imgur.com/hiY1E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hiY1E.png" alt="enter image description here" /></a></p>
<pre><code>struct TestListView: View {
var body: some View {
NavigationView {
List {
TestView()
}
.navigationTitle("All Tasks")
.listStyle(.grouped)
}
}
}
</code></pre>
<p>Note the extra padding around the calendar icon (and seemingly the entire bottom row) that it added. How do I remove this?</p>
| [
{
"answer_id": 74371053,
"author": "Trupesh Vaghasiya",
"author_id": 9331686,
"author_profile": "https://Stackoverflow.com/users/9331686",
"pm_score": 2,
"selected": true,
"text": "9 Days ago"
},
{
"answer_id": 74371605,
"author": "Mojtaba Hosseini",
"author_id": 5623035,
"author_profile": "https://Stackoverflow.com/users/5623035",
"pm_score": 0,
"selected": false,
"text": "List"
},
{
"answer_id": 74371694,
"author": "davidtamas",
"author_id": 4208105,
"author_profile": "https://Stackoverflow.com/users/4208105",
"pm_score": 0,
"selected": false,
"text": "struct TestListView: View {\n var body: some View {\n NavigationView {\n List {\n TestView()\n .listRowInsets(EdgeInsets())\n }\n .navigationTitle(\"All Tasks\")\n .listStyle(.grouped)\n }\n }\n}"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/802593/"
] |
74,370,811 | <p>How to make <code>(886) 7199 2483</code> to <code>+886 7199 2483</code> using regex?</p>
<p>I can only extract the dial code by</p>
<pre><code>const dialCode = '(886) 7199 2483'.match(/\(([^)]+)\)/)[1]; // 886
</code></pre>
<p>but don't know how to do the next step</p>
| [
{
"answer_id": 74371053,
"author": "Trupesh Vaghasiya",
"author_id": 9331686,
"author_profile": "https://Stackoverflow.com/users/9331686",
"pm_score": 2,
"selected": true,
"text": "9 Days ago"
},
{
"answer_id": 74371605,
"author": "Mojtaba Hosseini",
"author_id": 5623035,
"author_profile": "https://Stackoverflow.com/users/5623035",
"pm_score": 0,
"selected": false,
"text": "List"
},
{
"answer_id": 74371694,
"author": "davidtamas",
"author_id": 4208105,
"author_profile": "https://Stackoverflow.com/users/4208105",
"pm_score": 0,
"selected": false,
"text": "struct TestListView: View {\n var body: some View {\n NavigationView {\n List {\n TestView()\n .listRowInsets(EdgeInsets())\n }\n .navigationTitle(\"All Tasks\")\n .listStyle(.grouped)\n }\n }\n}"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10686620/"
] |
74,370,824 | <p>I have collected data from a piece of software has separated the contents of a message between two messages. I am relatively new to using Pandas as a whole. Lets say I have a Pandas DataFrame in the following format:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Type</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>Start</td>
</tr>
<tr>
<td>A</td>
<td>End</td>
</tr>
<tr>
<td>A</td>
<td>Start2</td>
</tr>
<tr>
<td>A</td>
<td>End2</td>
</tr>
</tbody>
</table>
</div>
<p>I need to combine message pairs that share the same type. Multiple packet types can occur, however I only care about merging one type.
Most of the time the packets are separated in pairs so I was able to combine them using the following:</p>
<pre><code>group = ("A" != df['Type'].shift()).cumsum().rename('group')
df = df.groupby(['Type', group], sort=False)['Message'].agg(''.join).reset_index().drop('group', axis=1)
</code></pre>
<p>Example of packet pairs:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Type</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr>
<td>B</td>
<td>StartEnd</td>
</tr>
<tr>
<td>C</td>
<td>Start2End2</td>
</tr>
<tr>
<td>A</td>
<td>Start</td>
</tr>
<tr>
<td>A</td>
<td>End</td>
</tr>
<tr>
<td>B</td>
<td>Start4End4</td>
</tr>
<tr>
<td>C</td>
<td>Start5End5</td>
</tr>
<tr>
<td>A</td>
<td>Start</td>
</tr>
<tr>
<td>A</td>
<td>End</td>
</tr>
</tbody>
</table>
</div>
<p>The output using the current code gives:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Type</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr>
<td>B</td>
<td>StartEnd</td>
</tr>
<tr>
<td>C</td>
<td>Start2End2</td>
</tr>
<tr>
<td>A</td>
<td>StartEnd</td>
</tr>
<tr>
<td>B</td>
<td>Start4End4</td>
</tr>
<tr>
<td>C</td>
<td>Start5End5</td>
</tr>
<tr>
<td>A</td>
<td>StartEnd</td>
</tr>
</tbody>
</table>
</div>
<p>However this only solves the problem of consecutive messages with the same type.</p>
<p>The desired output is as follows:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Type</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>StartEnd</td>
</tr>
<tr>
<td>A</td>
<td>Start2End2</td>
</tr>
</tbody>
</table>
</div>
<p>I am unsure of a way to limit these groupings to only two items. I need to be able to preserve the type of each message as it is important for later processing.</p>
| [
{
"answer_id": 74371162,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "g"
},
{
"answer_id": 74371343,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 0,
"selected": false,
"text": "groupby.agg"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10626864/"
] |
74,370,860 | <pre class="lang-js prettyprint-override"><code>type A = [{a: 1}, {a: 'x'}]
type TupleToUnion<T, K> = ...
TupleToUnion<A, 'a'> // expected to be `1 | 'x'`
</code></pre>
<p>How can I define <code>TupleToUnion</code>?</p>
| [
{
"answer_id": 74370996,
"author": "Iain Shelvington",
"author_id": 548562,
"author_profile": "https://Stackoverflow.com/users/548562",
"pm_score": 3,
"selected": false,
"text": "type B = A[number]['a']\n"
},
{
"answer_id": 74371008,
"author": "sun0day",
"author_id": 19671034,
"author_profile": "https://Stackoverflow.com/users/19671034",
"pm_score": 1,
"selected": false,
"text": "type TupleToUnion<T, K> = T extends [infer R, ...infer Rest]\n ? K extends keyof R\n ? R[K] | TupleToUnion<Rest, K>\n : never\n : never;\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19671034/"
] |
74,370,871 | <p>I'm really new to Python so I hope this makes sense.
These are a sample of 2 dictionaries. What I cannot work out is how to subtract the current entries from the previous entries where the nested dictionary ie "Name2" matches in the previous dictionary.
Also I cannot introduce or use extra libraries.</p>
<pre><code>previous = {}
c = []
c.append("Date:07Nov22,Name:Name1,Type:InterTerm,C_Time:12.45.09,C_001:2873,C_002:2832,P_002:98.5,C_003:41,P_003:1.4,C_005:1,P_005:0.0,C_010:2873,C_011:8,P_011:0.2,C_012:9,P_012:0.3")
c.append("Date:07Nov22,Name:Name2,Type:InterTerm,C_Time:12.45.09,C_001:18981,C_002:18683,P_002:98.4,C_003:298,P_003:1.5,C_005:47,P_005:0.2,C_010:18981,C_011:39,P_011:0.2,C_012:86,P_012:0.4")
c.append("Date:07Nov22,Name:Name1,Type:InterTerm,C_Time:12.49.09,C_001:3145,C_002:3102,P_002:98.6,C_003:43,P_003:1.3,C_005:1,P_005:0.0,C_007:1,P_007:0.0,C_010:3145,C_011:12,P_011:0.3,C_012:13,P_012:0.4")
c.append("Date:07Nov22,Name:Name2,Type:InterTerm,C_Time:12.49.09,C_001:20742,C_002:20415,P_002:98.4,C_003:327,P_003:1.5,C_005:54,P_005:0.2,C_007:1,P_007:0.0,C_010:20742,C_011:42,P_011:0.2,C_012:96,P_012:0.4")
c.append("Date:07Nov22,Name:Name1,Type:InterTerm,C_Time:12.52.30,C_001:3357,C_002:3310,P_002:98.5,C_003:47,P_003:1.4,C_005:2,P_005:0.0,C_007:2,P_007:0.0,C_010:3357,C_011:13,P_011:0.3,C_012:15,P_012:0.4")
c.append("Date:07Nov22,Name:Name2,Type:InterTerm,C_Time:12.52.30,C_001:22176,C_002:21823,P_002:98.4,C_003:353,P_003:1.5,C_005:58,P_005:0.2,C_007:1,P_007:0.0,C_010:22176,C_011:44,P_011:0.1,C_012:102,P_012:0.4")
def setCMD():
for cmd in c:
print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print("$$$ $$$")
print("$$$ THIS IS THIS THE START $$$")
print("$$$ $$$")
print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
print("Using Command : ",cmd)
zw = dict(item.split(':') for item in cmd.split(','))
print("THIS IS ZW ",zw)
modForInter(zw)
def calcDiff(d1,d2):
print("In Function calDiff")
for x in d2:
for y in d1:
if x==y:
#print(d1[y],d2[x])
for i in d1[y]:
for i in d2[x]:
d1[y][i]=d1[y][i]-d2[x][i]
#print(d1[y][i])
break
return d1[y]
def modForInter(zw):
print("In Mod modForInter")
global previous
nameDict = {}
nameDict["Name"] = zw["Name"]
print("This is nameDict",nameDict)
zw1={ zw["Name"] }
print(zw1)
# List for extraction.
list1=["Date","Name","Type","C_Time",\
"C_001","","C_002","P_002","C_003","P_003","C_005","P_005",\
"C_007","P_007"]
# List for prev
list2=[
"C_001","C_002","C_003","C_005","C_007"]
current = {key:value for (key,value) in zw.items() if key in list1 }
zw = {k: int(v) if isinstance(v, str) and v.isdigit() else v for k, v in zw.items()}
current = {
key1 : {key:value for (key,value) in zw.items() if key in list1 } for key1 in zw1
}
print("current created")
result = {
key1 : {key:value for (key,value) in zw.items() if key in list1 } for key1 in zw1
}
number_of_elements = sum(len(v) for v in current.values())
if number_of_elements <= 4:
print("Number of elements is less than 4")
return
else:
print("Number of elements is greater than 4")
y=(str(zw1).replace("{'","").replace("'}",""))
print(y)
if "C_001" in previous[y]:
print("previous is NOT empty")
print("This is previous_dict :",previous)
x=calcDiff(current,previous)
print("This is X",x)
else:
print("previous_dict is empty and will be populated")
previous.update({
key1 : {key:value for (key,value) in zw.items() if key in list2 } for key1 in zw1
})
print("THIS IS PREVIOUS_DICT : ",previous)
del(current)
del(zw)
print("THIS IS RESULT",result)
setCMD()
</code></pre>
<p>Notice that C_007 was added and was not in the previous dictionary and Name2 is gone also.</p>
| [
{
"answer_id": 74370996,
"author": "Iain Shelvington",
"author_id": 548562,
"author_profile": "https://Stackoverflow.com/users/548562",
"pm_score": 3,
"selected": false,
"text": "type B = A[number]['a']\n"
},
{
"answer_id": 74371008,
"author": "sun0day",
"author_id": 19671034,
"author_profile": "https://Stackoverflow.com/users/19671034",
"pm_score": 1,
"selected": false,
"text": "type TupleToUnion<T, K> = T extends [infer R, ...infer Rest]\n ? K extends keyof R\n ? R[K] | TupleToUnion<Rest, K>\n : never\n : never;\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17324125/"
] |
74,370,875 | <p>Currently, I have this kind of JSON array with the same field, what I wanted is to split this data into an independent field and the field name is based on a "name" field</p>
<p>events.parameters (this is the field name of the JSON array)</p>
<pre><code>{
"name": "USER_EMAIL",
"value": "dummy@yahoo.com"
},
{
"name": "DEVICE_ID",
"value": "Wdk39Iw-akOsiwkaALw"
},
{
"name": "SERIAL_NUMBER",
"value": "9KJUIHG"
}
</code></pre>
<p>expected output:</p>
<pre><code>events.parameters.USER_EMAIL : dummy@yahoo.com
events.parameters.DEVICE_ID: Wdk39Iw-akOsiwkaALw
events.parameters.SERIAL_NUMBER : 9KJUIHG
</code></pre>
<p>Thanks.</p>
| [
{
"answer_id": 74370996,
"author": "Iain Shelvington",
"author_id": 548562,
"author_profile": "https://Stackoverflow.com/users/548562",
"pm_score": 3,
"selected": false,
"text": "type B = A[number]['a']\n"
},
{
"answer_id": 74371008,
"author": "sun0day",
"author_id": 19671034,
"author_profile": "https://Stackoverflow.com/users/19671034",
"pm_score": 1,
"selected": false,
"text": "type TupleToUnion<T, K> = T extends [infer R, ...infer Rest]\n ? K extends keyof R\n ? R[K] | TupleToUnion<Rest, K>\n : never\n : never;\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10904536/"
] |
74,370,980 | <p>I am working on angular app and I am very new to html and css. I am trying to make a progress bar. I want to divide each section of this progress bar into two sub sections with different background color as shown here in the image below.
<a href="https://i.stack.imgur.com/8vTud.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8vTud.png" alt="progress_bar" /></a></p>
<p>my code is as follows:</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> .wrap {
width: 100%;
height: 30px;
z-index: -2;
white-space: nowrap;
overflow: hidden;
}
.wrap div:first-child {
margin-left: -2%;
}
.progress {
margin: 0;
margin-left: 0.5%;
height: 30px;
width: 25%;
position: relative;
display: inline-block;
text-align: center;
line-height: 30px;
transition: all 0.8s;
}
.progress:before,
.progress:after {
content: "";
position: absolute;
transition: all 0.8s;
z-index: -1;
}
.progress:before {
height: 50%;
width: 100%;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.2);
transform: skew(45deg);
}
.progress:after {
height: 50%;
width: 100%;
top: 50%;
left: 0;
background: rgba(0, 0, 0, 0.2);
transform: skew(-45deg);
}
.progress:hover:before,
.progress:hover:after {
background: tomato;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <div class="wrap">
<div class="progress">
simple
</div>
<div class="progress">
as
</div>
<div class="progress">
complex
</div>
<div class="progress">
Web Development
</div>
</div></code></pre>
</div>
</div>
</p>
<p>How can I do this? Please help.</p>
| [
{
"answer_id": 74370996,
"author": "Iain Shelvington",
"author_id": 548562,
"author_profile": "https://Stackoverflow.com/users/548562",
"pm_score": 3,
"selected": false,
"text": "type B = A[number]['a']\n"
},
{
"answer_id": 74371008,
"author": "sun0day",
"author_id": 19671034,
"author_profile": "https://Stackoverflow.com/users/19671034",
"pm_score": 1,
"selected": false,
"text": "type TupleToUnion<T, K> = T extends [infer R, ...infer Rest]\n ? K extends keyof R\n ? R[K] | TupleToUnion<Rest, K>\n : never\n : never;\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74370980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17800542/"
] |
74,371,019 | <pre><code>public class binarysearch {
public static int search(num, target_value) {
int low = 0;
int mid;
int high = num.length - 1;
while (low < high) {
mid = (low + high) / 2;
if (num[mid] == target_value) {
return mid;
}
if (num[mid] < target_value){
low = mid + 1;
} else {
high = mid - 1;
}
}
}
public static void main(String[] args) {
binarysearch ob = new binarysearch();
int target_value = 69;
int[] num = {10,23,45,11,69,81};
int result = ob.search(num,target_value);
if (result == -1) {
System.out.println("Element not present");
} else {
System.out.println("Element is present" + mid);
}
}
}
</code></pre>
<p>Could someone help me what exactly I am doing wrong here. I am facing a compilation error while executing my code.</p>
<p>I was trying to implement Binary Search and I am receiving this error :</p>
<pre><code>/binarysearch.java:2: error: <identifier> expected
public static int search(num,target_value)
^
/binarysearch.java:2: error: <identifier> expected
public static int search(num,target_value)
^
2 errors
</code></pre>
| [
{
"answer_id": 74370996,
"author": "Iain Shelvington",
"author_id": 548562,
"author_profile": "https://Stackoverflow.com/users/548562",
"pm_score": 3,
"selected": false,
"text": "type B = A[number]['a']\n"
},
{
"answer_id": 74371008,
"author": "sun0day",
"author_id": 19671034,
"author_profile": "https://Stackoverflow.com/users/19671034",
"pm_score": 1,
"selected": false,
"text": "type TupleToUnion<T, K> = T extends [infer R, ...infer Rest]\n ? K extends keyof R\n ? R[K] | TupleToUnion<Rest, K>\n : never\n : never;\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16721568/"
] |
74,371,035 | <p>I am using iText 7.2.1.</p>
<p>I am trying to add some small icons (drawn by code) in my text. I find if small icons are added into my text, it's hard to have uniform line space.</p>
<p>If all elements of a paragraph are texts, I can just set <code>SetFixedLeading()</code> then no matter how big the font sizes are, my lines have always the same height.</p>
<p>But when I add some small icons inside my paragraph, <code>SetFixedLeading()</code> no longer works.</p>
<p>What I want is like the "Line spacing" option in Microsoft Word. If I give it a fixed value, it treats embedding images and texts equally so I always get fixed line spacing.</p>
<p>The following is my code:</p>
<pre><code>using iText.Kernel.Colors;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas;
using iText.Layout;
using iText.Kernel.Pdf.Xobject;
using iText.Layout.Element;
using iText.Kernel.Geom;
using iText.Kernel.Font;
using iText.IO.Font;
namespace iTextTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var writer = new PdfWriter("test.pdf");
var pdf_doc = new PdfDocument(writer);
var doc = new Document(pdf_doc, iText.Kernel.Geom.PageSize.DEFAULT, false);
// Make a text of various sizes
var mixed_paragraph = new Paragraph();
for (int i = 0; i < 100; i ++)
{
var style = new Style();
var size = (Math.Sin(i) + 2) * 10;
style.SetFontSize((float)size);
mixed_paragraph.Add(new Text("A").AddStyle(style));
}
// Make a 20x20 icon
var bounds = new iText.Kernel.Geom.Rectangle(0, 0, 20, 20);
var xobj = new PdfFormXObject(bounds);
var pdf_canvas = new PdfCanvas(xobj, pdf_doc);
pdf_canvas.SetFillColor(ColorConstants.RED);
pdf_canvas.Rectangle(0, 0, 20, 20);
pdf_canvas.Fill();
var icon = new iText.Layout.Element.Image(xobj);
mixed_paragraph.Add(icon);
// Fixed leading
mixed_paragraph.SetFixedLeading(10);
doc.Add(mixed_paragraph);
doc.Close();
pdf_doc.Close();
writer.Close();
MessageBox.Show("OK");
}
}
}
</code></pre>
<p>This is what it looks like. The second line is right but the third line has more space than fixed leading 10.</p>
<p><a href="https://i.stack.imgur.com/LKvvl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LKvvl.png" alt="enter image description here" /></a></p>
<p>I need this because, in my case, I need some small rectanglular icons that each contain two lines of integers and other info.</p>
<p>These icons have bigger height than my text (or else it's hard to read), but theoretically they can still fit because my text has enough spacing.</p>
<p>Unfortunately, my line spaces become uneven. Fixed leading seems not affecting non-text images, so lines with icons have wider line spaces.</p>
<p>I have been considering a workaround: add empty spaces in text and put icons at these fixed positions. It's still hard. I don't know how to get these positions.</p>
| [
{
"answer_id": 74662785,
"author": "Jonathon Leach",
"author_id": 20663311,
"author_profile": "https://Stackoverflow.com/users/20663311",
"pm_score": 1,
"selected": false,
"text": "using iText.Kernel.Colors;\nusing iText.Kernel.Pdf;\nusing iText.Kernel.Pdf.Canvas;\nusing iText.Layout;\nusing iText.Kernel.Pdf.Xobject;\nusing iText.Layout.Element;\nusing iText.Kernel.Geom;\nusing iText.Kernel.Font;\nusing iText.IO.Font;\n\nnamespace iTextTest\n{\n public partial class Form1 : Form\n {\n public Form1()\n {\n InitializeComponent();\n }\n\n private void button1_Click(object sender, EventArgs e)\n {\n var writer = new PdfWriter(\"test.pdf\");\n var pdf_doc = new PdfDocument(writer);\n var doc = new Document(pdf_doc, iText.Kernel.Geom.PageSize.DEFAULT, false);\n\n // Make a text of various sizes\n var mixed_paragraph = new Paragraph();\n for (int i = 0; i < 100; i ++)\n {\n var style = new Style();\n var size = (Math.Sin(i) + 2) * 10;\n style.SetFontSize((float)size);\n mixed_paragraph.Add(new Text(\"A\").AddStyle(style));\n } \n\n // Make a 20x20 icon\n var bounds = new iText.Kernel.Geom.Rectangle(0, 0, 20, 20);\n var xobj = new PdfFormXObject(bounds);\n var pdf_canvas = new PdfCanvas(xobj, pdf_doc);\n pdf_canvas.SetFillColor(ColorConstants.RED);\n pdf_canvas.Rectangle(0, 0, 20, 20);\n pdf_canvas.Fill();\n var icon = new iText.Layout.Element.Image(xobj);\n mixed_paragraph.Add(icon);\n\n // Set the minimum height of each line in the paragraph\n mixed_paragraph.SetMinHeight(20);\n\n doc.Add(mixed_paragraph);\n\n doc.Close();\n pdf_doc.Close();\n writer.Close();\n\n MessageBox.Show(\"OK\");\n }\n }\n}\n"
},
{
"answer_id": 74662821,
"author": "Benjamin Woolston",
"author_id": 20188398,
"author_profile": "https://Stackoverflow.com/users/20188398",
"pm_score": 1,
"selected": false,
"text": "Paragraph mixedParagraph = new Paragraph();\n\n// Add some text to the paragraph\nmixedParagraph.Add(new Text(\"A\"));\n\n// Make a 20x20 icon\nRectangle bounds = new Rectangle(0, 0, 20, 20);\nPdfFormXObject xobj = new PdfFormXObject(bounds);\nPdfCanvas canvas = new PdfCanvas(xobj, pdfDoc);\ncanvas.SetFillColor(ColorConstants.RED);\ncanvas.Rectangle(0, 0, 20, 20);\ncanvas.Fill();\nImage icon = new Image(xobj);\nmixedParagraph.Add(icon);\n\n// Set the line spacing to be 1.5 times the font size\nmixedParagraph.SetMultipliedLeading(1.5f);\n\n// Add the paragraph to the document\ndocument.Add(mixedParagraph);\n"
},
{
"answer_id": 74666286,
"author": "Sahaj Raj Malla",
"author_id": 11773575,
"author_profile": "https://Stackoverflow.com/users/11773575",
"pm_score": 0,
"selected": false,
"text": "public class CustomLineSpacingHandler : LineSpacingHandler {\n public float Handle(ILeafElement currentElement, float lineHeight) {\n if (currentElement is PdfTextElement) {\n // Calculate line spacing for text element\n } else if (currentElement is PdfImageXObject) {\n // Calculate line spacing for image element\n }\n // Return calculated line spacing\n }\n}\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3745149/"
] |
74,371,089 | <p><a href="https://i.stack.imgur.com/hBNCW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hBNCW.png" alt="enter image description here" /></a></p>
<p>The Render Box is the porblem as the image show below :)
I have a problem with the trailing Column
When i reduce the container height to 30 the overflowed is gone but i wanna make this text fit with others devices without render Box :)</p>
<ul>
<li><p>So how can i fix this in the same i can run it in multiple devices</p>
<pre><code> ListView.separated(
separatorBuilder: (context, index) => Divider(
color: ColorManager.lightGrey,
),
itemCount: value.transfersModel!.data!.length,
itemBuilder: (context, index) {
var data = value.transfersModel!.data![index];
return ListTile(
leading: IconButton(
onPressed: () {},
icon: Icon(Icons.copy_sharp)),
title: Text("${data.office!.name}"),
subtitle: Text("${data.recipientName}"),
trailing: Column(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
FittedBox(
child: Container(
child: ButtonTheme(
alignedDropdown: true,
child: DropdownButton(
dropdownColor:
ColorManager.white,
icon: Icon(
Icons
.keyboard_arrow_down_outlined,
color: ColorManager.lightGrey
.withOpacity(0.51),
),
underline: Container(),
items: value.transfersStatus
.map((item) {
print(
"${item.keys.single} : ${item.values.single} ${data.status.toString()}");
return new DropdownMenuItem(
child: new Text(
item.values.single
.toString(),
style: TextStyle(
fontSize: 13.0,
),
),
value: item.keys.single
.toString());
}).toList(),
value: data.status.toString(),
onChanged: (String? value) {
setState(() {
data.status = value;
});
},
),
),
height: 50.h,
padding: EdgeInsets.zero,
decoration: BoxDecoration(
color: ColorManager
.tabBarBackground,
borderRadius: BorderRadius.all(
Radius.circular(5))),
),
),
Text(
"${data.createdAt}".replaceHHMMa(),
style: TextStyle(fontSize: 12.sp),
)
],
),
);
}),
</code></pre>
</li>
</ul>
| [
{
"answer_id": 74662785,
"author": "Jonathon Leach",
"author_id": 20663311,
"author_profile": "https://Stackoverflow.com/users/20663311",
"pm_score": 1,
"selected": false,
"text": "using iText.Kernel.Colors;\nusing iText.Kernel.Pdf;\nusing iText.Kernel.Pdf.Canvas;\nusing iText.Layout;\nusing iText.Kernel.Pdf.Xobject;\nusing iText.Layout.Element;\nusing iText.Kernel.Geom;\nusing iText.Kernel.Font;\nusing iText.IO.Font;\n\nnamespace iTextTest\n{\n public partial class Form1 : Form\n {\n public Form1()\n {\n InitializeComponent();\n }\n\n private void button1_Click(object sender, EventArgs e)\n {\n var writer = new PdfWriter(\"test.pdf\");\n var pdf_doc = new PdfDocument(writer);\n var doc = new Document(pdf_doc, iText.Kernel.Geom.PageSize.DEFAULT, false);\n\n // Make a text of various sizes\n var mixed_paragraph = new Paragraph();\n for (int i = 0; i < 100; i ++)\n {\n var style = new Style();\n var size = (Math.Sin(i) + 2) * 10;\n style.SetFontSize((float)size);\n mixed_paragraph.Add(new Text(\"A\").AddStyle(style));\n } \n\n // Make a 20x20 icon\n var bounds = new iText.Kernel.Geom.Rectangle(0, 0, 20, 20);\n var xobj = new PdfFormXObject(bounds);\n var pdf_canvas = new PdfCanvas(xobj, pdf_doc);\n pdf_canvas.SetFillColor(ColorConstants.RED);\n pdf_canvas.Rectangle(0, 0, 20, 20);\n pdf_canvas.Fill();\n var icon = new iText.Layout.Element.Image(xobj);\n mixed_paragraph.Add(icon);\n\n // Set the minimum height of each line in the paragraph\n mixed_paragraph.SetMinHeight(20);\n\n doc.Add(mixed_paragraph);\n\n doc.Close();\n pdf_doc.Close();\n writer.Close();\n\n MessageBox.Show(\"OK\");\n }\n }\n}\n"
},
{
"answer_id": 74662821,
"author": "Benjamin Woolston",
"author_id": 20188398,
"author_profile": "https://Stackoverflow.com/users/20188398",
"pm_score": 1,
"selected": false,
"text": "Paragraph mixedParagraph = new Paragraph();\n\n// Add some text to the paragraph\nmixedParagraph.Add(new Text(\"A\"));\n\n// Make a 20x20 icon\nRectangle bounds = new Rectangle(0, 0, 20, 20);\nPdfFormXObject xobj = new PdfFormXObject(bounds);\nPdfCanvas canvas = new PdfCanvas(xobj, pdfDoc);\ncanvas.SetFillColor(ColorConstants.RED);\ncanvas.Rectangle(0, 0, 20, 20);\ncanvas.Fill();\nImage icon = new Image(xobj);\nmixedParagraph.Add(icon);\n\n// Set the line spacing to be 1.5 times the font size\nmixedParagraph.SetMultipliedLeading(1.5f);\n\n// Add the paragraph to the document\ndocument.Add(mixedParagraph);\n"
},
{
"answer_id": 74666286,
"author": "Sahaj Raj Malla",
"author_id": 11773575,
"author_profile": "https://Stackoverflow.com/users/11773575",
"pm_score": 0,
"selected": false,
"text": "public class CustomLineSpacingHandler : LineSpacingHandler {\n public float Handle(ILeafElement currentElement, float lineHeight) {\n if (currentElement is PdfTextElement) {\n // Calculate line spacing for text element\n } else if (currentElement is PdfImageXObject) {\n // Calculate line spacing for image element\n }\n // Return calculated line spacing\n }\n}\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9483327/"
] |
74,371,097 | <p>i have applications and i need to use splash screen with background color and app <strong>icon</strong> in center of it.</p>
<p><a href="https://i.stack.imgur.com/8v36t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8v36t.png" alt="enter image description here" /></a></p>
<p>THE problem with <strong>MIPMAP</strong> , if i used image inside drawble directory it will work, but i need <strong>mipmap</strong> because it has multiple <strong>dhp</strong> sizes.</p>
<p>Anyone know solution of this?</p>
<p><strong>NOTE:</strong> i know that the android 32 has special demonstration, i need solution that word in all version.</p>
<p>thank you.</p>
| [
{
"answer_id": 74371996,
"author": "batuhand",
"author_id": 10376031,
"author_profile": "https://Stackoverflow.com/users/10376031",
"pm_score": 0,
"selected": false,
"text": " runApp(MaterialApp(\n theme: ThemeData(\n colorScheme: ColorScheme.light().copyWith(\n primary: Colors.red,\n ),\n ),\n home: SplashPage(), // here is your splash screen page\n ));\n"
},
{
"answer_id": 74429112,
"author": "jon",
"author_id": 8371825,
"author_profile": "https://Stackoverflow.com/users/8371825",
"pm_score": -1,
"selected": false,
"text": "dev_dependencies"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15199247/"
] |
74,371,099 | <p>I'm truing to get the employees that have birthday within next 3 days. I tried to do that by using the following query.</p>
<pre><code>public function upcomingBirthdays()
{
$from = now()->format('m-d');
$to = now()->addDays(3)->format('m-d');
$employees = Employees::whereRaw("DATE_FORMAT(dob, '%m-%d') BETWEEN '{$from}' AND '{$to}'")
->where('team_id', 13)
->where('status', 1)
->orderBy('dob', 'DESC')
->get();
return view('frontend.employee.birthdays', compact('employees'));
}
// End Method
</code></pre>
<p>But this is not returning expected data.</p>
<p>Today is <strong>2022-11-09</strong></p>
<p>This is returning employees with birthdays <strong>between</strong> <em>2022-11-08</em> and <em>2022-11-10</em>. But <strong>not returning</strong> employees that have <strong>birthdays on 11-11 and 11-12</strong>.</p>
| [
{
"answer_id": 74371996,
"author": "batuhand",
"author_id": 10376031,
"author_profile": "https://Stackoverflow.com/users/10376031",
"pm_score": 0,
"selected": false,
"text": " runApp(MaterialApp(\n theme: ThemeData(\n colorScheme: ColorScheme.light().copyWith(\n primary: Colors.red,\n ),\n ),\n home: SplashPage(), // here is your splash screen page\n ));\n"
},
{
"answer_id": 74429112,
"author": "jon",
"author_id": 8371825,
"author_profile": "https://Stackoverflow.com/users/8371825",
"pm_score": -1,
"selected": false,
"text": "dev_dependencies"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15338342/"
] |
74,371,103 | <p>Im trying to add ROW_NUMBER() in a select query on top of a calculated field and get unique rownum for unique calculated field. But Im getting sequuential rownum for all the values in calculated field.</p>
<p>How can I achieve it in Postgres SQL?</p>
<p>Thanks in advance.</p>
<pre><code>select m.subscriber, count(distinct s.session_id) as num_session
,ROW_NUMBER() OVER (partition by count(distinct s.session_id) ORDER BY count(distinct s.session_id) DESC) AS rownum
from dbms.music_stream m, dbms.session s, dbms.users u
where m.session_id = s.session_id
and m.subscriber = u.user_id
and lower(u.subscription_type) = 'premium'
and lower(s.platform) = 'app'
group by m.subscriber
</code></pre>
<p>Im applying row_number on count(distinct s.session_id) and I expect the distinct value of count(distinct s.session_id) have same rownum but I get it in an order as below.</p>
<pre><code> subscriber | num_session | rownum
------------+-------------+--------
118 | 2 | 1
73 | 2 | 2
139 | 2 | 3
59 | 2 | 4
81 | 1 | 1
103 | 1 | 2
</code></pre>
<p>But this is what I expect :</p>
<pre><code> subscriber | num_session | rownum
------------+-------------+--------
118 | 2 | 1
73 | 2 | 1
139 | 2 | 1
59 | 2 | 1
81 | 1 | 2
103 | 1 | 2
</code></pre>
| [
{
"answer_id": 74371241,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 1,
"selected": false,
"text": "DENSE_RANK()"
},
{
"answer_id": 74371242,
"author": "BU123",
"author_id": 14141539,
"author_profile": "https://Stackoverflow.com/users/14141539",
"pm_score": 0,
"selected": false,
"text": "select m.subscriber as user_id, u.first_name, u.last_name, u.gender, count(distinct s.session_id) as num_session \n,DENSE_RANK() OVER (ORDER BY count(distinct s.session_id) DESC) as rank\nfrom dbms.music_stream m, dbms.session s, dbms.users u\nwhere m.session_id = s.session_id\nand m.subscriber = u.user_id\nand lower(u.subscription_type) = 'premium'\nand lower(s.platform) = 'app'\ngroup by m.subscriber, u.first_name, u.last_name, u.gender\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14141539/"
] |
74,371,170 | <p>I'm using a an Api to get manga cover arts , and to do so I need to save part of the Json response as a variable.</p>
<pre><code>import requests
import json
title = "prison-school"
base_url = "https://api.mangadex.org"
r = requests.get(
f"{base_url}/manga",
params={"title": title}
)
lol = [manga["id"] for manga in r.json()["data"]]
idManga = lol[0]
r2 = requests.get(
f"{base_url}/manga/{idManga}?includes[]=cover_art"
)
lol2 = r2.json()
lol3 = json.dumps(lol2)
print(lol3)
</code></pre>
<p>this gives me a response of :</p>
<pre><code>{"result": "ok", "response": "entity", "data": {"id": "371a7405-bee1-402c-b0d7-74ea3fb4d587", "type": "manga", "attributes": {"title": {"en": "Prison School"}, "altTitles": [{"ja-ro": "Kangoku Gakuen"}, {"id": "Penjara Di Sekolah"}, {"ru": "\u0428\u043a\u043e\u043b\u0430-\u0422\u044e\u0440\u044c\u043c\u0430"}, {"ja": "\u30d7\u30ea\u30ba\u30f3\u30b9\u30af\u30fc\u30eb"}, {"zh-hk": "\u76e3\u7344\u5b66\u5712"}], "description": {"en": "Hachimitsu Academy, known for its strict academic standards and even stricter school code, is making a giant change this year. In the first time in school history, they are allowing boys to be admitted. As Fujino Kiyoshi starts his first day at Hachimitsu Academy he is shocked to find out that there are only 4 other guys in the entire school, making the ratio of girls to boys 200:1. And to their dismay, not one of the thousand girls will talk to them or even acknowledge them. But Kiyoshi and the guys are about to find out about the shadow student council that has been threatening the female students about interacting with male students \n\n\n---", "ru": "\u0427\u0430\u0441\u0442\u043d\u0430\u044f \u0416\u0435\u043d\u0441\u043a\u0430\u044f \u0410\u043a\u0430\u0434\u0435\u043c\u0438\u044f \u0425\u0430\u0447\u0438\u043c\u0438\u0442\u0441\u0443 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430 \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u0442\u0440\u043e\u0433\u0438\u043c\u0438 \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u0442\u0440\u043e\u0433\u0438\u043c\u0438 \u0448\u043a\u043e\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438. \u0412\u043f\u0435\u0440\u0432\u044b\u0435, \u0437\u0430 \u0432\u0441\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0448\u043a\u043e\u043b\u044b, \u043c\u0430\u043b\u044c\u0447\u0438\u043a\u0438 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043a \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044e \u0432 \u044d\u0442\u0443 \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u044e. \u0424\u0443\u0434\u0436\u0438\u043d\u043e \u041a\u0438\u0451\u0448\u0438 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u0434\u0435\u043d\u044c \u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u043a\u0443\u043b\u044c\u0442\u0443\u0440\u043d\u044b\u0439 \u0448\u043e\u043a, \u0443\u0437\u043d\u0430\u0432, \u0447\u0442\u043e \u0432 \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u044e \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u043e \u0442\u043e\u043b\u044c\u043a\u043e 5 \u043f\u0430\u0440\u043d\u0435\u0439, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0434\u0435\u0432\u0443\u0448\u0435\u043a \u0438 \u043f\u0430\u0440\u043d\u0435\u0439 - 200:1. \u041f\u0430\u0440\u043d\u0438, \u0442\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0432 \u043c\u0430\u043b\u0438\u043d\u0435. \u041d\u043e \u043d\u0435 \u0442\u0443\u0442-\u0442\u043e \u0431\u044b\u043b\u043e. \u041a \u0438\u0445 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u043c\u0443 \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u044b\u0441\u044f\u0447\u0438 \u0434\u0435\u0432\u0443\u0448\u0435\u043a \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0441 \u043d\u0438\u043c\u0438 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u0441\u0432\u043e\u0438\u0445 \u0441\u043e\u043a\u0443\u0440\u0441\u043d\u0438\u043a\u043e\u0432. \u041a\u0438\u0451\u0448\u0438 \u0438 \u043f\u0430\u0440\u043d\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043e\u0431\u043b\u0430\u0447\u0438\u0442\u044c \u041f\u043e\u0434\u043f\u043e\u043b\u044c\u043d\u044b\u0439 \u0421\u0442\u0443\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0439 \u0421\u043e\u0432\u0435\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0433\u0440\u043e\u0436\u0430\u0435\u0442 \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u043a\u0430\u043c \u0425\u0430\u0447\u0438\u043c\u0438\u0442\u0441\u0443. \n \nWon the Kodansha Manga Award 2013 for best general manga."}, "isLocked": false, "links": {"al": "55297", "ap": "prison-school", "bw": "series/4390", "kt": "18452", "mu": "63043", "amz": "https://www.amazon.co.jp/gp/product/B077JMRFL3", "ebj": "https://ebookjapan.yahoo.co.jp/books/141809/", "mal": "25297", "raw": "https://comic-days.com/episode/10834108156629480592", "engtl": "https://yenpress.com/9781975330248/prison-school-vol-28/"}, "originalLanguage": "ja", "lastVolume": "28", "lastChapter": "277", "publicationDemographic": "seinen", "status": "completed", "year": 2011, "contentRating": "suggestive", "tags": [{"id": "0a39b5a1-b235-4886-a747-1d05d216532d", "type": "tag", "attributes": {"name": {"en": "Award Winning"}, "description": {}, "group": "format", "version": 1}, "relationships": []}, {"id": "423e2eae-a7a2-4a8b-ac03-a8351462d71d", "type": "tag", "attributes": {"name": {"en": "Romance"}, "description": {}, "group": "genre", "version": 1}, "relationships": []}, {"id": "4d32cc48-9f00-4cca-9b5a-a839f0764984", "type": "tag", "attributes": {"name": {"en": "Comedy"}, "description": {}, "group": "genre", "version": 1}, "relationships": []}, {"id": "caaa44eb-cd40-4177-b930-79d3ef2afe87", "type": "tag", "attributes": {"name": {"en": "School Life"}, "description": {}, "group": "theme", "version": 1}, "relationships": []}], "state": "published", "chapterNumbersResetOnNewVolume": false, "createdAt": "2018-02-07T22:21:15+00:00", "updatedAt": "2022-02-15T22:29:07+00:00", "version": 7, "availableTranslatedLanguages": ["es", "ru", "pl", "en", "ar", "fa"], "latestUploadedChapter": "835c358c-7844-452c-bb09-4b6fc6e42c4d"}, "relationships": [{"id": "bb7c8f8b-f82d-4a73-9f87-02713ca82722", "type": "author"}, {"id": "bb7c8f8b-f82d-4a73-9f87-02713ca82722", "type": "artist"}, {"id": "416e58a6-ac84-4f50-92e0-aac6636a2bca", "type": "cover_art", "attributes": {"description": "", "volume": null, "fileName": "e039f18a-eb05-43d1-ac68-598aa09da9c2.jpg", "locale": "ja", "createdAt": "2021-05-24T16:39:34+00:00", "updatedAt": "2021-05-24T16:39:34+00:00", "version": 1}}, {"id": "0924201b-89b1-4a07-82aa-f504eb67d509", "type": "manga", "related": "doujinshi"}, {"id": "1db29ef5-1231-47df-b6a4-3e25182b341c", "type": "manga", "related": "doujinshi"}, {"id": "985f8295-978d-48d4-bc43-4b035e527f77", "type": "manga", "related": "spin_off"}, {"id": "e9fcd6db-1ba2-4140-9813-9028a996ff7c", "type": "manga", "related": "side_story"}]}}
</code></pre>
<p>i need to save the "filename" as a variable but every time i do</p>
<pre><code>filename = lol3['filename']
</code></pre>
<p>I get this error :</p>
<pre><code>string indices must be integers
</code></pre>
| [
{
"answer_id": 74371241,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 1,
"selected": false,
"text": "DENSE_RANK()"
},
{
"answer_id": 74371242,
"author": "BU123",
"author_id": 14141539,
"author_profile": "https://Stackoverflow.com/users/14141539",
"pm_score": 0,
"selected": false,
"text": "select m.subscriber as user_id, u.first_name, u.last_name, u.gender, count(distinct s.session_id) as num_session \n,DENSE_RANK() OVER (ORDER BY count(distinct s.session_id) DESC) as rank\nfrom dbms.music_stream m, dbms.session s, dbms.users u\nwhere m.session_id = s.session_id\nand m.subscriber = u.user_id\nand lower(u.subscription_type) = 'premium'\nand lower(s.platform) = 'app'\ngroup by m.subscriber, u.first_name, u.last_name, u.gender\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20287896/"
] |
74,371,182 | <p>I've a json looking like</p>
<pre><code>[
{
"name": "Architektur"
},
{
"name": "Computer",
"children": [
{
"name": "Icon"
},
{
"name": "Pattern"
},
{
"name": "Button",
"children": [
{
"name": "grün"
},
{
"name": "braun"
}
]
}
]
},
{
"name": "Fahrzeug"
},
{
"name": "Kamera",
"children": [
{
"name": "Histogramm"
},
{
"name": "Weißableich",
"children": [
{
"name": "Auto"
},
{
"name": "Sonne"
},
{
"name": "Bewölkt",
"children": [
{
"name": "Am Tag"
},
{
"name": "In der Nacht"
}
]
}
]
},
{
"name": "Sensor"
}
]
}
]
</code></pre>
<p>I would now need to get the first level <em>name</em> (f.e. Computer) as parent and search for all children names of any depth (f.e. Icon, Pattern). Those child names should be added as array to the first level parent value. If there are no children at all (f.e. Architektur) the array should stay empty. This is what it should look like:</p>
<pre><code>{
"Architektur": [],
"Computer": ["Icon", "Pattern", "grün", "braun"],
"Fahrzeug": [],
"Kamera": ["Histogramm","Auto", "Sonne", "Am Tag", "In der Nacht"],
"Sensor": []
}
</code></pre>
<p>Unfortunately with jq I could not arrive to somewhere useful, (Missing knowledge), but before diving in python I would like to ask if this is possible?</p>
| [
{
"answer_id": 74371254,
"author": "peak",
"author_id": 997358,
"author_profile": "https://Stackoverflow.com/users/997358",
"pm_score": 2,
"selected": true,
"text": ".."
},
{
"answer_id": 74372133,
"author": "Philippe",
"author_id": 2125671,
"author_profile": "https://Stackoverflow.com/users/2125671",
"pm_score": 0,
"selected": false,
"text": "jq '\ndef get_values:\n if has(\"children\") then (.children[]? | get_values) else .name end;\nmap({name,value:[.children[]? | get_values]}) | from_entries\n' input.json\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1305062/"
] |
74,371,210 | <p>The code below gives different result depending on environments:</p>
<pre class="lang-rust prettyprint-override"><code>fn main() {
let n: usize = 5489031744;
let n_cbrt: usize = (n as f64).cbrt().floor() as usize;
println!("{}", n_cbrt);
}
</code></pre>
<p><a href="https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=988f79bf3dcd814fe3629d581343783a" rel="nofollow noreferrer">Rust Playground</a> and my Linux server (Ryzen) gives</p>
<pre><code>1763
</code></pre>
<p>though M1 Macbook Air gives</p>
<pre><code>1764
</code></pre>
<p>Mathematically, <code>1764.pow(3)</code> exactly equals <code>5489031744</code> so the latter result is correct. But, anyway, the problem is the inconsistency rather than mathematical correctness.</p>
<p>Is this inconsistency a bug? If not, does this mean we cannot write a cross-platform application whose behavior is fully predictable and consistent in Rust?</p>
<p>By the way, the C++ program below gives <code>1764</code> in both my Linux server (Ryzen) and M1 Macbook Air (and in <a href="https://onlinegdb.com/fyIC0CyPvr" rel="nofollow noreferrer">an online compiler</a>).</p>
<pre class="lang-cpp prettyprint-override"><code>#include <iostream>
#include <cmath>
int main() {
std::cout << cbrt(5489031744) << "\n";
}
</code></pre>
<p>Very strange as it seems Rust's <code>cbrt()</code> calls C++'s <code>cbrt()</code> directly (<a href="https://doc.rust-lang.org/src/std/f64.rs.html#550-552" rel="nofollow noreferrer">source</a>):</p>
<pre class="lang-rust prettyprint-override"><code>pub fn cbrt(self) -> f64 {
unsafe { cmath::cbrt(self) }
}
</code></pre>
<p>Summary:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Environment</th>
<th>Rust</th>
<th>C++</th>
</tr>
</thead>
<tbody>
<tr>
<td>Linux (Ryzen)</td>
<td><em><strong>1763</strong></em></td>
<td>1764 (<code>clang++</code>, <code>g++</code>)</td>
</tr>
<tr>
<td>macOS (M1)</td>
<td>1764</td>
<td>1764 (<code>clang++</code>, <code>g++</code>)</td>
</tr>
<tr>
<td><a href="https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=988f79bf3dcd814fe3629d581343783a" rel="nofollow noreferrer">Rust Playground</a></td>
<td><em><strong>1763</strong></em></td>
<td></td>
</tr>
<tr>
<td><a href="https://onlinegdb.com/fyIC0CyPvr" rel="nofollow noreferrer">C++ online compiler</a></td>
<td></td>
<td>1764 (<code>g++</code>)</td>
</tr>
<tr>
<td>FreeBSD (Intel)</td>
<td>1764</td>
<td>1764 (<code>clang++</code>, <code>g++</code>)</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74371254,
"author": "peak",
"author_id": 997358,
"author_profile": "https://Stackoverflow.com/users/997358",
"pm_score": 2,
"selected": true,
"text": ".."
},
{
"answer_id": 74372133,
"author": "Philippe",
"author_id": 2125671,
"author_profile": "https://Stackoverflow.com/users/2125671",
"pm_score": 0,
"selected": false,
"text": "jq '\ndef get_values:\n if has(\"children\") then (.children[]? | get_values) else .name end;\nmap({name,value:[.children[]? | get_values]}) | from_entries\n' input.json\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8776746/"
] |
74,371,239 | <p>I have been trying to create a column for a dataframe where each new observation depends on the value of the observations of other columns. I tried to come up with code that would do that but haven't been any lucky</p>
<p>I also checked these answers <a href="https://stackoverflow.com/questions/50988447/add-column-with-values-depending-on-another-column-to-a-dataframe"></a>) but couldn't make them work if anyone has an idea on how to do it I would be truly grateful</p>
<pre><code> for (dff$prcganancia in dff){
if(dff$grupo == 1){
prcganancia == 0.3681
}elseif(dff$grupo == 2){
prcganancia == 0.2320
}elseif(dff$grupo == 3){
prcganancia == 0.2851
}elseif(dff$grupo == 4){
prcganancia == 0.4443
}elseif(dff$grupo == 5){
prcganancia == 0.3353
}elseif(dff$grupo == 6){
prcganancia == 0.2656
}elseif(dff$grupo == 7){
prcganancia == 0.2597
}elseif(dff$grupo == 8){
prcganancia == 0.2211
}elseif(dff$grupo == 9){
prcganancia == 0.3782
}elseif(dff$grupo == 10){
prcganancia == 0.3752}
}
</code></pre>
<p>What my lousy code is trying to do is make the observation for prcganancia where grupo equals to 1, 0.3681 (every obsrvation where grupo == 1 the observation for prcganancia == 0.3681) and so on</p>
| [
{
"answer_id": 74371768,
"author": "Stephan",
"author_id": 8598377,
"author_profile": "https://Stackoverflow.com/users/8598377",
"pm_score": 0,
"selected": false,
"text": "dplyr"
},
{
"answer_id": 74371804,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "["
},
{
"answer_id": 74372076,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 1,
"selected": true,
"text": "dplyr::recode()"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17139852/"
] |
74,371,277 | <p>This is my JSON file. When I click the button named <code>info{}</code> object it makes changes on all 5 data at the same time. How should I filter data as per the <code>fid</code> or index value of the data?</p>
<pre><code>{
"response_code": "1",
"message": "Data Found",
"workout": [
{
"fid": "1",
"uid": "1",
"wdid": "1",
"type": "0",
"info": {
"id": "1",
"goalid": "3",
"levelid": "1",
"workname": "At - Home Cardio for Fat Loss",
"dow": "4",
"image": "https://sparksapps.in/gym/uploads/6218a2c119f28.jpg",
"fid": "1"
}
},........X5 data inside workout
const [data, setData] = useState();
useEffect(() => {
(async () => {
setData(resp.workout);
})();
},[] );
return (
{data?.map((element, i) => {
return (
<div className="col-md-4" key={element.fid}>
<div className="card card-cascade wider" style={{ display: "flex", justifyContent: "start" }}>
<div className="card-body card-body-cascade text-center pb-0">
<h5 id={element.fid} className="card-title">fid:{element.fid}</h5>
<h5 className="card-title">uid:{element.uid}</h5>
<h5 className="card-title">wdid:{element.wdid}</h5>
<h5 className="card-title">type:{element.type}</h5>
<div>
{" "}
<button onClick={clickedMe} type="button">{element.fid}{element.info.info}</button>
{data?.filter(element=> element.fid === '1')?
<div>
<div className="view view-cascade overlay">
<img className="card-img-top"src={element.info.image}alt="Card image cap"/>
</div>{" "}
<h5 className="card-title">id:{element.info.id}</h5>
<h5 className="card-title">goalid:{element.info.goalid}</h5>
<h5 className="card-title">levelid:{element.info.levelid}</h5>
<h5 className="card-title">workname:{element.info.workname}</h5>
<h5 className="card-title">dow:{element.info.dow}</h5>
<img src={element.info.image} alt="" width={'100%'}/>
</div>
:null}
</div>
<div className="card-footer text-muted text-center mt-4">
2 days ago
</div>
</div>
</div>
</div>
);
})}
)
</code></pre>
<p>Alike [0][1][2][3][4] if I click button on button of info inside [1] the data inside object <code>info{}</code> available at [1] should display of 1 only and the rest should remain unClicked.</p>
| [
{
"answer_id": 74371768,
"author": "Stephan",
"author_id": 8598377,
"author_profile": "https://Stackoverflow.com/users/8598377",
"pm_score": 0,
"selected": false,
"text": "dplyr"
},
{
"answer_id": 74371804,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "["
},
{
"answer_id": 74372076,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 1,
"selected": true,
"text": "dplyr::recode()"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20456827/"
] |
74,371,279 | <p>Have two tables payment, payment_info , trying with left join and union to get the ordnums, it gives me duplicate records, below is my tables data structure.</p>
<p>Payment Table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>invoice</th>
<th>cardpay</th>
<th>gpay</th>
<th>phonepe</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>4567</td>
<td>0000123</td>
<td>null</td>
<td>null</td>
</tr>
<tr>
<td>2</td>
<td>4567</td>
<td>null</td>
<td>dummy@dummy</td>
<td>null</td>
</tr>
<tr>
<td>3</td>
<td>4567</td>
<td>null</td>
<td>null</td>
<td>P@dummy</td>
</tr>
<tr>
<td>4</td>
<td>4568</td>
<td>0000124</td>
<td>null</td>
<td>null</td>
</tr>
</tbody>
</table>
</div>
<p>Payment_info Table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ordnum</th>
<th>payment_method</th>
<th>payment_value</th>
</tr>
</thead>
<tbody>
<tr>
<td>101</td>
<td>C</td>
<td>0000123</td>
</tr>
<tr>
<td>102</td>
<td>G</td>
<td>dummy@dummy</td>
</tr>
<tr>
<td>103</td>
<td>C</td>
<td>0000124</td>
</tr>
</tbody>
</table>
</div>
<p>Query:</p>
<pre><code>select pinfo.ordnum from
payment p
left join payment_info pinfo
on (select payment_info.ordnum
from payment_info
where payment_info.payment_method = 'C'
and payment_info.payment_value = p.cardpay
union
select payment_info.ordnum
from payment_info
where payment_info.payment_method = 'G'
and payment_info.payment_value = p.gpay
union
select payment_info.ordnum
from payment_info
where payment_info.payment_method = 'P'
and payment_info.payment_value = p.phonepe ) = pinfo.ordnum
where p.invoice = '4567'
</code></pre>
<p>Result: It gives 3 duplicate records.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ordnum</th>
</tr>
</thead>
<tbody>
<tr>
<td>101</td>
</tr>
<tr>
<td>101</td>
</tr>
<tr>
<td>101</td>
</tr>
</tbody>
</table>
</div>
<p>Expected result value is : 101,102, null</p>
<p>Can you please explain me on why it is generating duplicate records, also please let me know how can I solve this, it works good with "OR", but that would cause performance issue, any other solution that that would be really helpful.</p>
<p>Also in sql server it works good.</p>
| [
{
"answer_id": 74371768,
"author": "Stephan",
"author_id": 8598377,
"author_profile": "https://Stackoverflow.com/users/8598377",
"pm_score": 0,
"selected": false,
"text": "dplyr"
},
{
"answer_id": 74371804,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "["
},
{
"answer_id": 74372076,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 1,
"selected": true,
"text": "dplyr::recode()"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3387870/"
] |
74,371,312 | <p>I have a nodejs app that has one getUsers endpoint, this endpoint gets the first 10 users from a mongodb database and returns them in a JSON response.</p>
<p>Lets say this is a sync process (async wont make any sense here since i need to fetch and return the result in the same request) and the entire process takes 1 sec. So, if I have 4 CPU in a virtual machine and I am running the nodejs in cluster mode (meaning 4 nodejs processes running together).</p>
<p>Q1) Does this mean my app can handle 4 simultaneous request per second? If this is true, how can my app handle 1000 request per second?</p>
<p>Q2) I know nodejs is single threaded but Is there anyway the nodejs instance can use more than 1 thread per CPU so that it can handle more request per cpu per second?</p>
| [
{
"answer_id": 74371859,
"author": "Jaood_xD",
"author_id": 18891587,
"author_profile": "https://Stackoverflow.com/users/18891587",
"pm_score": 1,
"selected": false,
"text": "N - 1"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/468975/"
] |
74,371,328 | <p>I'm developing a School Management System for my thesis and I've been stuck at implementing a grading module for 3 weeks now, I have gotten close to achieving my wanted result. I can now list all the students on a page depending on a selected subject and a field where the faculty can input a grade beside the student's name. The problem is the fields are not prefilled with the grades added to the database for students, it also creates a new object whenever I input a value rather than updating the grade if it's for the same student and same subject within the same quarter and academic year. <strong>Current Output:</strong><a href="https://imgur.com/dxxMVq2" rel="nofollow noreferrer"><img src="https://i.imgur.com/dxxMVq2.png" title="source: imgur.com" /></a></p>
<p><strong>Desired Output:</strong><a href="https://imgur.com/2yeRY2x" rel="nofollow noreferrer"><img src="https://i.imgur.com/2yeRY2x.png" title="source: imgur.com" /></a></p>
<p>This is the view responsible for adding grade</p>
<pre><code>def add_gradebook_for(request, id):
global student, s
current_year = AcademicYear.objects.get(active=True)
current_quarter = Quarter.objects.get(active=True)
if request.method == 'GET':
subjects = Subject.objects.filter(faculty_id=request.user.id)
subject = Subject.objects.get(pk=id)
students = Students.objects.filter(section__subject_section__in=[subject])
context = {
"subjects": subjects,
"subject": subject,
"students": students,
}
return render(request, 'grading/add_gradebook_for.html', context)
if request.method == 'POST':
ids = ()
data = request.POST.copy()
data.pop('csrfmiddlewaretoken', None)
subject = Subject.objects.get(pk=id)
for key in data.keys():
ids = ids + (str(key),)
for s in range(0, len(ids)):
student = Students.objects.get(id=ids[s])
score = data.getlist(ids[s])
total_grade = score[0]
obj = Students.objects.get(id=ids[s])
obj.total_grade = total_grade
try:
a = Gradebook.objects.get(student=student, subject=subject, total_grade=total_grade, academic_year=current_year, quarter=current_quarter)
a.total_grade = total_grade
a.subject = subject
a.save()
except:
Gradebook.objects.update_or_create(student=student, subject=subject, total_grade=total_grade, academic_year=current_year, quarter=current_quarter)
messages.success(request, "Grades Successfully Recorded!")
return HttpResponseRedirect(reverse_lazy('add_gradebook_for', kwargs={'id': id}))
</code></pre>
<p>Html Template (irrelevant parts omitted) :</p>
<pre><code><div class="card-body">
<div id="table" class="table-editable">
<table class="table table-bordered table-responsive-md table-striped text-center">
<tr>
<th class="text-center">Student</th>
<th class="text-center">Grade</th>
</tr>
{% for student in students %}
<tr>
<td class="pt-3-half" name="{{ student.id }}">
{{ student.first_Name }} {{ student.last_Name }}
</td>
<td class="pt-3-half">
<input id="total_grade" class="score" type="number" name="{{ student.id }}" value="{{ student.total_grade }}">
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</code></pre>
<p>Models (irrelevant fields omitted):</p>
<pre><code>class Gradebook(models.Model):
subject = models.ForeignKey(Subject, on_delete=models.CASCADE)
student = models.ForeignKey(Students, on_delete=models.CASCADE)
total_grade = models.FloatField(blank=True, null=True, default=0, max_length=5)
academic_year = models.ForeignKey(AcademicYear, on_delete=models.CASCADE)
quarter = models.ForeignKey(Quarter, on_delete=models.CASCADE)
class Subject(models.Model):
section = models.ForeignKey(Section, on_delete=models.CASCADE)
name = models.CharField(max_length=255)
faculty = models.ForeignKey(AUTH_USER_MODEL, on_delete=models.CASCADE)
class Section(models.Model):
level = models.ForeignKey(Level, null=True, on_delete=models.CASCADE)
section = models.CharField(max_length=15)
class Students(models.Model):
name = models.CharField(max_length=50)
section = models.ForeignKey(Section, on_delete=models.CASCADE)
</code></pre>
| [
{
"answer_id": 74378566,
"author": "haduki",
"author_id": 18229792,
"author_profile": "https://Stackoverflow.com/users/18229792",
"pm_score": 0,
"selected": false,
"text": "\"\""
},
{
"answer_id": 74384706,
"author": "CORSICANA",
"author_id": 20456826,
"author_profile": "https://Stackoverflow.com/users/20456826",
"pm_score": 1,
"selected": false,
"text": "def add_gradebook_for(request, id):\n global student, s\n current_year = AcademicYear.objects.get(active=True)\n current_quarter = Quarter.objects.get(active=True)\n if request.method == 'GET':\n subjects = Subject.objects.filter(faculty_id=request.user.id)\n subject = Subject.objects.get(pk=id)\n students = Students.objects.filter(section__subject_section__in=[subject])\n grades = Gradebook.objects.filter(subject_id=subject)\n context = {\n \"subjects\": subjects,\n \"subject\": subject,\n \"students\": students,\n \"grades\": grades\n }\n return render(request, 'grading/add_gradebook_for.html', context)\n\n if request.method == 'POST':\n ids = ()\n data = request.POST.copy()\n data.pop('csrfmiddlewaretoken', None)\n subject = Subject.objects.get(pk=id)\n for key in data.keys():\n ids = ids + (str(key),) # gather all the students id in a tuple\n for s in range(0, len(ids)):\n student = Students.objects.get(id=ids[s])\n score = data.getlist(ids[s]) # get list of score for current student in the loop\n total_grade = score[0]\n obj = Students.objects.get(id=ids[s])\n obj.total_grade = total_grade\n Gradebook.objects.update_or_create(student=student, subject=subject, academic_year=current_year, quarter=current_quarter, defaults={'total_grade':total_grade})\n messages.success(request, \"Grades Successfully Recorded!\")\n return HttpResponseRedirect(reverse_lazy('add_gradebook_for', kwargs={'id': id}))\n \n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20456826/"
] |
74,371,333 | <p>I have two tables:</p>
<pre><code>CREATE TABLE users
(
id INTEGER PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(68) NOT NULL,
oldPassword VARCHAR(68),
enabled BOOLEAN NOT NULL
);
</code></pre>
<p>and</p>
<pre><code>CREATE TABLE authorities (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL,
authority VARCHAR(50) NOT NULL,
FOREIGN KEY (username) REFERENCES users(username)
);
CREATE UNIQUE INDEX ix_auth_username on authorities (username,authority);
</code></pre>
<p>Unfortunatelly instead of joining with <code>authority_id</code> which should be in <code>users</code> table I just have <code>username</code> which is the same in both tables.</p>
<p>In models I tried (ommited getters and setters):</p>
<pre><code>@Entity(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String username;
private String password;
private String oldPassword;
private boolean enabled;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "username", referencedColumnName = "username")
private Authorities authority;
}
</code></pre>
<p>and</p>
<pre><code>@Entity
public class Authorities {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String username;
private String authority;
@OneToOne(mappedBy = "authority")
private User user;
}
</code></pre>
<p>but then I have an error: <code>Repeated column in mapping for entity column: username (should be mapped with insert="false" update="false")</code></p>
| [
{
"answer_id": 74378566,
"author": "haduki",
"author_id": 18229792,
"author_profile": "https://Stackoverflow.com/users/18229792",
"pm_score": 0,
"selected": false,
"text": "\"\""
},
{
"answer_id": 74384706,
"author": "CORSICANA",
"author_id": 20456826,
"author_profile": "https://Stackoverflow.com/users/20456826",
"pm_score": 1,
"selected": false,
"text": "def add_gradebook_for(request, id):\n global student, s\n current_year = AcademicYear.objects.get(active=True)\n current_quarter = Quarter.objects.get(active=True)\n if request.method == 'GET':\n subjects = Subject.objects.filter(faculty_id=request.user.id)\n subject = Subject.objects.get(pk=id)\n students = Students.objects.filter(section__subject_section__in=[subject])\n grades = Gradebook.objects.filter(subject_id=subject)\n context = {\n \"subjects\": subjects,\n \"subject\": subject,\n \"students\": students,\n \"grades\": grades\n }\n return render(request, 'grading/add_gradebook_for.html', context)\n\n if request.method == 'POST':\n ids = ()\n data = request.POST.copy()\n data.pop('csrfmiddlewaretoken', None)\n subject = Subject.objects.get(pk=id)\n for key in data.keys():\n ids = ids + (str(key),) # gather all the students id in a tuple\n for s in range(0, len(ids)):\n student = Students.objects.get(id=ids[s])\n score = data.getlist(ids[s]) # get list of score for current student in the loop\n total_grade = score[0]\n obj = Students.objects.get(id=ids[s])\n obj.total_grade = total_grade\n Gradebook.objects.update_or_create(student=student, subject=subject, academic_year=current_year, quarter=current_quarter, defaults={'total_grade':total_grade})\n messages.success(request, \"Grades Successfully Recorded!\")\n return HttpResponseRedirect(reverse_lazy('add_gradebook_for', kwargs={'id': id}))\n \n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4952262/"
] |
74,371,361 | <p>This is the code that I have with me:</p>
<pre><code>%let data=sashelp.cars;
proc transpose data=&data(obs=0) out=names;
var _all_;
run;
proc sql;
select cats('_',_name_,'=missing(',_name_,');') into: stmts separated by ' ' from names;
run;
data missing;
set &data;
_BIGN = 1;
/*%m_expand_varlist(data=&data,expr=cats('_',_name_,'=missing(',_name_,');'));*/
&stmts;
keep _:;
run;
proc summary data=missing;
var _numeric_;
output out=smry sum=;
run;
proc transpose data=smry(drop=_type_ _freq_) out=smry_;
run;
</code></pre>
<p>The goal of this code is to output the number of missing values for both character and numeric variables in the data set. The code accomplishes that objective but I have difficulty in understanding the purpose of certain lines in the code.</p>
<p>May I know what the following part of the code does?</p>
<pre><code> select cats('_',_name_,'=missing(',_name_,');') into: stmts separated by ' ' from names;
</code></pre>
<p>I understand that the into part just stores the value into the macro variable stmts but what does "separated by ' ' from names" in the above line mean?</p>
<pre><code>data missing;
set &data;
_BIGN = 1;
&stmts;
keep _:;
run;
</code></pre>
<p>And in the above portion of the code, what is the purpose of "keep <em>:"? What does the "</em>:" do in that? And is the "_BIGN = 1" necessary?</p>
<p>And also in the final output table called smry_, I get underscores before the names of the variables. But I don't need these underscores. What can I do to remove them? When I removed the underscore after the "keep <em>:", the underscores in the smry</em> table went away but I was left with only 10 rows instead of 15. Help would be appreciated. Thank you.</p>
| [
{
"answer_id": 74371560,
"author": "gregor",
"author_id": 20198546,
"author_profile": "https://Stackoverflow.com/users/20198546",
"pm_score": 1,
"selected": false,
"text": "keep _:;\n"
},
{
"answer_id": 74371853,
"author": "saslearner ",
"author_id": 20344621,
"author_profile": "https://Stackoverflow.com/users/20344621",
"pm_score": 0,
"selected": false,
"text": "data _smry_(drop = _name_);\nset smry_;\nname=compress(_name_, , 'kas');\nrun;\n"
},
{
"answer_id": 74376588,
"author": "data _null_",
"author_id": 2196220,
"author_profile": "https://Stackoverflow.com/users/2196220",
"pm_score": 0,
"selected": false,
"text": "%let data=sashelp.heart;\nproc transpose data=&data(obs=0) out=names;\n var _all_;\n run;\nproc sql;\n select cats('Label _',_name_,'=',quote(_label_),';') into: lb_stmts separated by ' ' from names;\n select cats('_',_name_,'=missing(',_name_,');') into: stmts separated by ' ' from names;\n select cats('_',_name_,'=',_name_) into: rn_stmts separated by ' ' from names;\n run;\n\noptions symbolgen=1;\ndata missingV / view=missingV;\n set &data;\n &stmts;\n &lb_stmts;\n rename &rn_stmts;\n keep _:;\n run;\noptions symbolgen=0;\nods output summary=summary;\nproc means data=missingV Sum Mean N STACKODSOUTPUT;\n var _numeric_;\n run;\nods output close;\nproc print width=minimum label;\n label sum='#Missing' mean='%Missing';\n format sum 8. mean percentn8.1;\n run;\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344621/"
] |
74,371,364 | <p>I want to count the 0s between two 1s from a list.
For example:</p>
<p><code>l = [0,1,0,0,0,0,1,1,1,0,0,1,0,1,1,0]</code></p>
<p>I want the output to be <code>[4,2,1]</code>. How can I do that in python?</p>
| [
{
"answer_id": 74371425,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 0,
"selected": false,
"text": "l = [0,1,0,0,0,0,1,1,1,0,0,1,0,1,1,0]\n\ns = pd.Series(l)\n\nout = (s[s.eq(0)&s.cummax()&s.loc[::-1].cummax()]\n .rsub(1).groupby(s.ne(0).cumsum()).sum()\n .tolist()\n )\n"
},
{
"answer_id": 74371588,
"author": "Mortz",
"author_id": 4248842,
"author_profile": "https://Stackoverflow.com/users/4248842",
"pm_score": 1,
"selected": false,
"text": "itertools.groupby"
},
{
"answer_id": 74371860,
"author": "B. de Jong",
"author_id": 19092246,
"author_profile": "https://Stackoverflow.com/users/19092246",
"pm_score": 0,
"selected": false,
"text": "l = [0,1,0,0,0,0,1,1,1,0,0,1,0,1,1,0]\noutput = []\n\nfor i in range(len(l)): #this goes through every index in l (1,2,3,...15, 16)\n if l[i] == 1: #if in the list at the current index is a 1 it\n zeros = 0 #sets zeros to 0\n while l[i+1+zeros] == 0: #and starts a while loop as long as the current index+1+'the amount of zeros after the last number 1' is a zero. (so it stops when it reaches another 1)\n zeros += 1 # because the while loop still runs it adds another 0\n if i+1+zeros == len(l): #the current index + 1 + 'the amount of zeros' = the length of our list\n zeros = 0 # it sets zeros back to 0 so the program doesn't add them to the output (else the output would be [4, 2, 1, 1])\n break #breaks out of the loop\n if zeros > 0: #if the zeros counted between two 1s are more then 0:\n output.append(zeros) # it adds them to our final output\n \nprint(output) #prints [4, 2, 1] to the terminal\n"
},
{
"answer_id": 74372231,
"author": "0x0fba",
"author_id": 20339407,
"author_profile": "https://Stackoverflow.com/users/20339407",
"pm_score": 0,
"selected": false,
"text": "def count(l: list[int]) -> list[int]:\n res = []\n counter = 0\n lastx = l[0]\n for x in l[1:]:\n rising = (x-lastx) > 0\n if rising and counter != 0:\n res.append(counter)\n counter = counter+1 if x==0 else 0\n lastx = x\n return res\n\ncount([0,1,0,0,0,0,1,1,1,0,0,1,0,1,1,0]) # [4, 2, 1]\n"
},
{
"answer_id": 74374374,
"author": "chrslg",
"author_id": 20037042,
"author_profile": "https://Stackoverflow.com/users/20037042",
"pm_score": 1,
"selected": true,
"text": "itertools"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19189066/"
] |
74,371,386 | <p>I'm doing a cool animation, I've divided the whole animation into many segments, and I've calculated the proportion of time each segment takes. I plan to generate a <code>Tween</code> object for each time period, and then generate successive property values. But now I find that I can only provide a <code>Tween</code> object for a property, and a <code>Tween</code> object can only set a time slice.</p>
<p>How to provide value for the same property with multiple <code>Tween</code>? Or is there a better way without <code>Tween</code>?</p>
<pre class="lang-dart prettyprint-override"><code>class TextAnimation extends StatelessWidget {
const TextAnimation({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
Animation<double> yOffset = Tween<double>(
begin: .0,
end: 180.0,
).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(
0.0,
0.5,
curve: Curves.easeIn,
),
),
);
// The previous Tween is not working and has been overwritten
yOffset = Tween<double>(
begin: .0,
end: -100.0,
).animate(
CurvedAnimation(
parent: animationController,
curve: const Interval(
0.5,
1.0,
curve: Curves.easeOut,
),
),
);
return AnimatedBuilder(
animation: animationController,
builder: (BuildContext context, Widget? child) {
return Transform.translate(
offset: Offset(0, yOffset.value),
child: const Text("Hello"),
);
},
);
}
}
</code></pre>
| [
{
"answer_id": 74371425,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 0,
"selected": false,
"text": "l = [0,1,0,0,0,0,1,1,1,0,0,1,0,1,1,0]\n\ns = pd.Series(l)\n\nout = (s[s.eq(0)&s.cummax()&s.loc[::-1].cummax()]\n .rsub(1).groupby(s.ne(0).cumsum()).sum()\n .tolist()\n )\n"
},
{
"answer_id": 74371588,
"author": "Mortz",
"author_id": 4248842,
"author_profile": "https://Stackoverflow.com/users/4248842",
"pm_score": 1,
"selected": false,
"text": "itertools.groupby"
},
{
"answer_id": 74371860,
"author": "B. de Jong",
"author_id": 19092246,
"author_profile": "https://Stackoverflow.com/users/19092246",
"pm_score": 0,
"selected": false,
"text": "l = [0,1,0,0,0,0,1,1,1,0,0,1,0,1,1,0]\noutput = []\n\nfor i in range(len(l)): #this goes through every index in l (1,2,3,...15, 16)\n if l[i] == 1: #if in the list at the current index is a 1 it\n zeros = 0 #sets zeros to 0\n while l[i+1+zeros] == 0: #and starts a while loop as long as the current index+1+'the amount of zeros after the last number 1' is a zero. (so it stops when it reaches another 1)\n zeros += 1 # because the while loop still runs it adds another 0\n if i+1+zeros == len(l): #the current index + 1 + 'the amount of zeros' = the length of our list\n zeros = 0 # it sets zeros back to 0 so the program doesn't add them to the output (else the output would be [4, 2, 1, 1])\n break #breaks out of the loop\n if zeros > 0: #if the zeros counted between two 1s are more then 0:\n output.append(zeros) # it adds them to our final output\n \nprint(output) #prints [4, 2, 1] to the terminal\n"
},
{
"answer_id": 74372231,
"author": "0x0fba",
"author_id": 20339407,
"author_profile": "https://Stackoverflow.com/users/20339407",
"pm_score": 0,
"selected": false,
"text": "def count(l: list[int]) -> list[int]:\n res = []\n counter = 0\n lastx = l[0]\n for x in l[1:]:\n rising = (x-lastx) > 0\n if rising and counter != 0:\n res.append(counter)\n counter = counter+1 if x==0 else 0\n lastx = x\n return res\n\ncount([0,1,0,0,0,0,1,1,1,0,0,1,0,1,1,0]) # [4, 2, 1]\n"
},
{
"answer_id": 74374374,
"author": "chrslg",
"author_id": 20037042,
"author_profile": "https://Stackoverflow.com/users/20037042",
"pm_score": 1,
"selected": true,
"text": "itertools"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11822156/"
] |
74,371,406 | <p>how can I increase the laravel 8 <code>dd()</code> limitations? I have lots of nested relationship and I cant view most of them due to many data. For example this</p>
<pre><code> #relations: array:4 [▼
"activecourses" => Illuminate\Database\Eloquent\Collection {#1346 ▼
#items: array:3 [▼
0 => App\Models\Studentcourse {#1353 ▶}
1 => App\Models\Studentcourse {#1354 ▼
#guarded: []
#connection: "mysql"
#table: "studentcourses"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: false
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#escapeWhenCastingToString: false
#attributes: array:22 [ …22]
#original: array:22 [ …22]
#changes: []
#casts: []
#classCastCache: []
#attributeCastCache: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: array:1 [ …1]
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: []
}
2 => App\Models\Studentcourse {#1355 ▶}
]
#escapeWhenCastingToString: false
}
</code></pre>
<p>I found this link <a href="https://stackoverflow.com/questions/39011241/laravel-dd-function-limitations">Laravel dd function limitations</a> but I think its outdated since the new dd function for laravel 8 is</p>
<p>this is from vendor folder.</p>
<pre><code>use Symfony\Component\VarDumper\VarDumper;
if (!function_exists('dump')) {
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
function dump($var, ...$moreVars)
{
VarDumper::dump($var);
foreach ($moreVars as $v) {
VarDumper::dump($v);
}
if (1 < func_num_args()) {
return func_get_args();
}
return $var;
}
}
if (!function_exists('dd')) {
/**
* @return never
*/
function dd(...$vars)
{
if (!in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && !headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
foreach ($vars as $v) {
VarDumper::dump($v);
}
exit(1);
}
}
</code></pre>
<p>Tried adding this lines before <code>dd()</code> but doesnt work</p>
<pre><code> ini_set('xdebug.var_display_max_depth', 100);
ini_set('xdebug.var_display_max_children', 2000);
ini_set('xdebug.var_display_max_data', 2000);
</code></pre>
<p>Is there any way or alternative in viewing nested data? I dont want to use <code>var_dump</code> or <code>print_r</code> since the browser becomes slow when there are lots of data. Thanks in advance.</p>
| [
{
"answer_id": 74416422,
"author": "Eskay Amadeus",
"author_id": 8722948,
"author_profile": "https://Stackoverflow.com/users/8722948",
"pm_score": 1,
"selected": false,
"text": "Log::debug($activeForces)"
},
{
"answer_id": 74418232,
"author": "Mtxz",
"author_id": 5608694,
"author_profile": "https://Stackoverflow.com/users/5608694",
"pm_score": 3,
"selected": true,
"text": "VarDumper"
},
{
"answer_id": 74422245,
"author": "CloudTheWolf",
"author_id": 3715170,
"author_profile": "https://Stackoverflow.com/users/3715170",
"pm_score": 1,
"selected": false,
"text": "dd($myArray)"
},
{
"answer_id": 74460401,
"author": "Neo",
"author_id": 405238,
"author_profile": "https://Stackoverflow.com/users/405238",
"pm_score": 1,
"selected": false,
"text": "dd($variable['activecourses'][0]);\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11667606/"
] |
74,371,407 | <p>I need to parse a date that I receive in a String with the following format: "Mon, 07 Nov 2022 21:00:00 +0100"</p>
<p>I have to dump the date to an object of type LocalDateTime and I use the following code:</p>
<pre><code>String fecha = "Mon, 07 Nov 2022 21:00:00 +0100";
DateTimeFormatter formato = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss XXXX");
LocalDateTime fechaHora = LocalDateTime.parse(fecha, formato);
</code></pre>
<p>but I get a DateTimeParseException. I can't find the error. Can you help me?
Thank you</p>
| [
{
"answer_id": 74371643,
"author": "Christoph Dahlen",
"author_id": 20370596,
"author_profile": "https://Stackoverflow.com/users/20370596",
"pm_score": 3,
"selected": true,
"text": "String fecha = \"Mon, 07 Nov 2022 21:00:00 +0100\";\n \nDateTimeFormatter formato = DateTimeFormatter.RFC_1123_DATE_TIME; \nLocalDateTime fechaHora = LocalDateTime.parse(fecha, formato);\n"
},
{
"answer_id": 74371826,
"author": "Savi",
"author_id": 19209168,
"author_profile": "https://Stackoverflow.com/users/19209168",
"pm_score": 0,
"selected": false,
"text": "String sDate1=\"Mon, 07 Nov 2022 21:00:00 +0100\"; \nDate date1=new SimpleDateFormat(\"EEE, dd MMM yyyy HH:mm:ssZ\").parse(sDate1); \nSystem.out.println(date1); \n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7359013/"
] |
74,371,420 | <p>I have an jCal JSON array which I'd like to filter with jq. JSON arrays are somewhat new to me and I have been banging my head to the wall on this for hours...</p>
<p>The file looks like this:</p>
<pre class="lang-json prettyprint-override"><code>[
"vcalendar",
[
[
"calscale",
{},
"text",
"GREGORIAN"
],
[
"version",
{},
"text",
"2.0"
],
[
"prodid",
{},
"text",
"-//SabreDAV//SabreDAV//EN"
],
[
"x-wr-calname",
{},
"unknown",
"Call log private"
],
[
"x-apple-calendar-color",
{},
"unknown",
"#ffaa00"
],
[
"refresh-interval",
{},
"duration",
"PT4H"
],
[
"x-published-ttl",
{},
"unknown",
"PT4H"
]
],
[
[
"vevent",
[
[
"dtstamp",
{},
"date-time",
"2015-04-05T16:42:10Z"
],
[
"created",
{},
"date-time",
"2015-02-18T16:44:04Z"
],
[
"uid",
{},
"text",
"9b23142b-8d86-3e17-2f44-2bed65b2e471"
],
[
"last-modified",
{},
"date-time",
"2015-04-05T16:42:10Z"
],
[
"description",
{},
"text",
"Phone call to +49xxxxxxxxxx lasted for 0 seconds."
],
[
"summary",
{},
"text",
"Outgoing: +49xxxxxxx"
],
[
"dtstart",
{},
"date-time",
"2015-02-18T10:58:12Z"
],
[
"dtend",
{},
"date-time",
"2015-02-18T10:58:44Z"
],
[
"transp",
{},
"text",
"OPAQUE"
]
],
[]
],
[
"vevent",
[
[
"dtstamp",
{},
"date-time",
"2015-04-05T16:42:10Z"
],
[
"created",
{},
"date-time",
"2015-01-09T19:12:05Z"
],
[
"uid",
{},
"text",
"c337e092-a012-5f5a-497f-932fbc6159e5"
],
[
"last-modified",
{},
"date-time",
"2015-04-05T16:42:10Z"
],
[
"description",
{},
"text",
"Phone call to +1xxxxxxxxxx lasted for 39 seconds."
],
[
"summary",
{},
"text",
"Outgoing: +1xxxxxxxxxx"
],
[
"dtstart",
{},
"date-time",
"2015-01-09T17:23:16Z"
],
[
"dtend",
{},
"date-time",
"2015-01-09T17:24:19Z"
],
[
"transp",
{},
"text",
"OPAQUE"
]
],
[]
],
]
]
</code></pre>
<p>I would like to filter out dtstart, dtend, the target phone number and the connection duration from the description for each vevent which was created e.g. in January 2019 ("2019-01.*") and output them as a CSV.</p>
| [
{
"answer_id": 74371643,
"author": "Christoph Dahlen",
"author_id": 20370596,
"author_profile": "https://Stackoverflow.com/users/20370596",
"pm_score": 3,
"selected": true,
"text": "String fecha = \"Mon, 07 Nov 2022 21:00:00 +0100\";\n \nDateTimeFormatter formato = DateTimeFormatter.RFC_1123_DATE_TIME; \nLocalDateTime fechaHora = LocalDateTime.parse(fecha, formato);\n"
},
{
"answer_id": 74371826,
"author": "Savi",
"author_id": 19209168,
"author_profile": "https://Stackoverflow.com/users/19209168",
"pm_score": 0,
"selected": false,
"text": "String sDate1=\"Mon, 07 Nov 2022 21:00:00 +0100\"; \nDate date1=new SimpleDateFormat(\"EEE, dd MMM yyyy HH:mm:ssZ\").parse(sDate1); \nSystem.out.println(date1); \n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11669787/"
] |
74,371,430 | <p><a href="https://i.stack.imgur.com/MRkN4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MRkN4.png" alt="enter image description here" /></a></p>
<p>Hello can anyone help me how to solve the issue of RenderFlex overflowed by 2772 pixels on the bottom.</p>
<p>This is my code.</p>
<pre><code>Container(
width: MediaQuery.of(context).size.width >= 1000
? 1000
: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text('Insurance & Takaful/Out patient',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold)),
SizedBox(height: 30),
Row(
children: [
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPPanel,
'Panel',
1,
true),
),
SizedBox(width: 15),
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPPolicyNumber,
'Policy number',
1,
true),
),
SizedBox(width: 15),
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPPolicyEffectiveDate,
'Policy effective date',
1,
true),
),
],
),
SizedBox(height: 10),
Row(
children: [
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPPolicyExpireDate,
'Policy expiry date',
1,
true),
),
SizedBox(width: 15),
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPGPLimit,
'GP limit',
1,
true),
),
SizedBox(width: 15),
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPGPUtilised,
'GP utilised',
1,
true),
)
],
),
SizedBox(height: 10),
Row(
children: [
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPGPBalance,
'GP balance',
1,
true),
),
SizedBox(width: 15),
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPSPLimit,
'SP limit',
1,
true),
),
SizedBox(width: 15),
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPSPUtilised,
'SP utilised',
1,
true),
)
],
),
SizedBox(height: 10),
Row(
children: [
Expanded(
flex: 1,
child: textformfieldBuild(
insuranceOPSPBalance,
'SP balance',
1,
true),
),
SizedBox(width: 15),
Expanded(
flex: 1,
child: Container(),
),
SizedBox(width: 15),
Expanded(
flex: 1,
child: Container(),
)
],
),
SizedBox(height: 10),
],
),
),
</code></pre>
<p>How to solve this problem without using the SingleChildScrollView widget? Or this is the only solution available to solve this problem? I hope someone can help me to solve this problem. Thank you.</p>
| [
{
"answer_id": 74371643,
"author": "Christoph Dahlen",
"author_id": 20370596,
"author_profile": "https://Stackoverflow.com/users/20370596",
"pm_score": 3,
"selected": true,
"text": "String fecha = \"Mon, 07 Nov 2022 21:00:00 +0100\";\n \nDateTimeFormatter formato = DateTimeFormatter.RFC_1123_DATE_TIME; \nLocalDateTime fechaHora = LocalDateTime.parse(fecha, formato);\n"
},
{
"answer_id": 74371826,
"author": "Savi",
"author_id": 19209168,
"author_profile": "https://Stackoverflow.com/users/19209168",
"pm_score": 0,
"selected": false,
"text": "String sDate1=\"Mon, 07 Nov 2022 21:00:00 +0100\"; \nDate date1=new SimpleDateFormat(\"EEE, dd MMM yyyy HH:mm:ssZ\").parse(sDate1); \nSystem.out.println(date1); \n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18275286/"
] |
74,371,446 | <p>I have the issue with Java sort. In SQL, I can sort independently on each field. I need something similar in Java.</p>
<pre class="lang-sql prettyprint-override"><code>SELECT * FROM Stuff ORDER BY name ASC,last_name DSC;
</code></pre>
<p>When using <code>sort(Comparator.comparing(Stuff::getName).thenComparing(Stuff::getLastName).reversed()</code> I get the whole sort reversed, and I want only for the second sort to be in reversed order. Is there a library for it, or a simple way to solve that?</p>
| [
{
"answer_id": 74371527,
"author": "Thomas",
"author_id": 637853,
"author_profile": "https://Stackoverflow.com/users/637853",
"pm_score": 3,
"selected": true,
"text": "thenComparing()"
},
{
"answer_id": 74372085,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "orderBy"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3587082/"
] |
74,371,454 | <p>I am facing this error, can someone help in this -
Error:
<em>TypeError: Cannot read properties of null (reading 'useState')</em></p>
<p><strong>Menu.tsx</strong></p>
<pre><code>export const MainMenu: FC = () => {
const [toogle, setToggle] = useState(false);
return(
<>
<SubMenu />
<div>
<button onClick={() => setToggle(!toogle)}>click</button>
</div>
</>
);
}
export const SubMenu: FC = () => {
return(
<>
<div className="menu">
<Image src={imgUrl} width="20" height="20" />
</div>
{toogle && (<span className="menu-text">{title}</span> )}
</>
);
}
</code></pre>
<p><strong>App.tsx</strong></p>
<pre><code>import { MainMenu} from '../Memu';
function App() {
return (
<MainMenu />
);
}
export default App;
</code></pre>
| [
{
"answer_id": 74371495,
"author": "user20386762",
"author_id": 20386762,
"author_profile": "https://Stackoverflow.com/users/20386762",
"pm_score": 2,
"selected": false,
"text": "toggle"
},
{
"answer_id": 74371537,
"author": "Anh Le Hoang",
"author_id": 16315750,
"author_profile": "https://Stackoverflow.com/users/16315750",
"pm_score": 1,
"selected": false,
"text": "toggle"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5444560/"
] |
74,371,457 | <p>i have multiple markdown files that contain images without alt that look like:</p>
<pre class="lang-markdown prettyprint-override"><code># my file

# this is an example image

</code></pre>
<p>i want to replace them with alt from the filename but without the <code>.png</code> extension & without <code>./</code> & replacing hyphens (<code>-</code> ) with empty spaces.</p>
<p>so the above markdown would look like:</p>
<pre class="lang-markdown prettyprint-override"><code># my file

# this is an example image

</code></pre>
<p>i can't do this manually as i have 100+ images so would love to automate this with a regex using vscode's find & replace.</p>
<p>i had <a href="https://stackoverflow.com/questions/74149194/find-replace-markdown-image-in-vscode-using-regex">previously removed alt</a> but want it back now. i didn't version control it so can't go back either.</p>
<p>how do i do it?</p>
| [
{
"answer_id": 74387405,
"author": "deadcoder0904",
"author_id": 6141587,
"author_profile": "https://Stackoverflow.com/users/6141587",
"pm_score": 0,
"selected": false,
"text": "regex101"
},
{
"answer_id": 74392671,
"author": "Mark",
"author_id": 836330,
"author_profile": "https://Stackoverflow.com/users/836330",
"pm_score": 2,
"selected": true,
"text": "keybindings.json"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6141587/"
] |
74,371,460 | <p>I have a drop down spinner where i am able to get the category_title . how to get selected category_id i have created a two mutableStateOf of selected title and Id .is there any other way to get the selected category id</p>
<pre><code>var mSelectedText by remember { mutableStateOf("") }
var mSelectedCategoryId by remember { mutableStateOf("") }
</code></pre>
<p>data class</p>
<pre><code>data class MainCategory(
var category_id: String? = null,
var category_name: String? = null,
var categoryImage_url: String? = null,
var category_priority:Int? = null
)
</code></pre>
<p>list variable</p>
<pre><code>val mCategories = mainCategories.mapTo(arrayListOf()){it.category_name}
</code></pre>
<p>DropDownMenu</p>
<pre><code> @OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainCatDownloadContent(
mainCategories: Categories,
mainCategoryOnClick: (categoryId: String, categoryTitle:
String) -> Unit,
) {
var mExpanded by remember { mutableStateOf(false) }
val mCategories = mainCategories.mapTo(arrayListOf()){it.category_name}
var mSelectedText by remember { mutableStateOf("") }
var mSelectedCategoryId by remember { mutableStateOf("") }
var mTextFieldSize by remember { mutableStateOf(Size.Zero) }
// Up Icon when expanded and down icon when collapsed
val icon = if (mExpanded)
Icons.Filled.KeyboardArrowUp
else
Icons.Filled.KeyboardArrowDown
Column(Modifier.padding(20.dp)) {
OutlinedTextField(
value = mSelectedText, onValueChange = { mSelectedText = it },
modifier = Modifier
.fillMaxWidth()
.onGloballyPositioned { coordinates ->
mTextFieldSize = coordinates.size.toSize()
},
readOnly = true,
label = { Text(text = "Select MainCategory")},
trailingIcon = {
Icon(icon,"contentDescription",
Modifier.clickable { mExpanded = !mExpanded })
}
)
mCategories.forEach{ mainCategory ->
DropdownMenuItem(onClick = {
mSelectedText = mainCategory.toString()
mExpanded = false }) {
Text(text = mainCategory.toString())
}
}
}
}
</code></pre>
<p>For ex if there is list of items like this</p>
<pre><code>[MainCategory(category_id=11, category_name=Fruits,
categoryImage_url=https:www category_priority=1),
MainCategory(category_id=22, category_name=Vegetable ,
categoryImage_url=https:www, category_priority=2),
MainCategory(category_id=33, category_name=Greens,
categoryImage_url=https:www, category_priority=3)
</code></pre>
<p>if selected item lets assume is "Fruits"! how to get its category_id which is "11" and assign to the mSelectedCategoryId variable</p>
| [
{
"answer_id": 74373246,
"author": "Gabriele Mariotti",
"author_id": 2016562,
"author_profile": "https://Stackoverflow.com/users/2016562",
"pm_score": 3,
"selected": true,
"text": "@Parcelize"
},
{
"answer_id": 74378361,
"author": "AndroidRocket",
"author_id": 13075886,
"author_profile": "https://Stackoverflow.com/users/13075886",
"pm_score": 1,
"selected": false,
"text": " val selectCategory by rememberSaveable {\n mutableStateOf(mainCategories)\n}\n"
}
] | 2022/11/09 | [
"https://Stackoverflow.com/questions/74371460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4232013/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.