qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,136,417 | <p>I am trying to use bounded types with generics to create generic objects of subclasses (these implement an interface). But I am getting type mismatch errors when initializing objects with the subclasses.</p>
<p>Here is the interface:</p>
<pre><code>public interface ScannableEntity {
}
</code></pre>
<p>Here's the class that implements this interface:</p>
<pre><code>public final class Attachment implements ScannableEntity {
.
.
.
}
</code></pre>
<p>Now I created 2 classes (<strong>SegmentPageScanResult</strong> and <strong>ItemProcessor</strong>) with the bounded generic type as:</p>
<pre><code>@Builder
public class SegmentPageScanResult<TEntity extends ScannableEntity> {
.
.
.
}
</code></pre>
<p>and</p>
<pre><code>public class ItemProcessor<TEntity extends ScannableEntity> {
void submitAndExecute(SegmentPageScanResult<TEntity> pageScanResult) {
. . .
}
}
</code></pre>
<p>When I am trying to initialize the SegmentPageScanResult and try calling <code>submitAndExecute</code> method of ItemProcessor from a Unit test as follows:</p>
<pre><code>@ExtendWith(MockitoExtension.class)
public class ScanTest {
@Mock
private ItemProcessor<Attachment> itemProcessor;
@Test
public void testDoScan() {
Attachment mockRecord = new Attachment();
SegmentPageScanResult<Attachment> segmentPageScanResult = SegmentPageScanResult.builder()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.scannedItems(ImmutableList.of(mockRecord))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.isLastPage(true)
^^^^^^^^^^^^^^^^^
.build();
^^^^^^^^^
verify(itemProcessor).submitAndExecute(segmentPageScanResult);
}
}
</code></pre>
<p>I get the error -</p>
<pre><code>Required type: SegmentPageScanResult<Attachment>
Provided:SegmentPageScanResult<ScannableEntity>
</code></pre>
<p>Can someone please help me understand why I am not able to initialize the generic object with the class implementing the interface?</p>
| [
{
"answer_id": 74136972,
"author": "dortus47",
"author_id": 14532657,
"author_profile": "https://Stackoverflow.com/users/14532657",
"pm_score": 2,
"selected": false,
"text": "colorInvert"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5430031/"
] |
74,136,421 | <p>I need to develop a function that accept 2 type of input.</p>
<pre class="lang-js prettyprint-override"><code>type InputA = {
name: string
content: string
color: string
}
type InputB = {
name: string
content: number
}
type Input = InputA | InputB
</code></pre>
<p>When I try to implement the function accepting this 2 inputs, I would like to check if the input has the <code>color</code> attribute, so I can distinct the 2 types.</p>
<p>However this will lead me to a compiler error:</p>
<pre class="lang-js prettyprint-override"><code>
function foo(input:Input){
const color = (input.color) ? input.color : undefined;
// ^
// | Property 'color' does not exist on type 'Input'.
// | Property 'color' does not exist on type 'InputB'.
...
}
</code></pre>
<p>I know I can implement a new attribute, like <code>type_name</code>, that exists in both types and then check on that one. But I would like to avoid it since I don't like having an extra attribute only for this reason in this particular function.</p>
<p>Is there a better way?</p>
| [
{
"answer_id": 74136538,
"author": "Tobias S.",
"author_id": 8613630,
"author_profile": "https://Stackoverflow.com/users/8613630",
"pm_score": 3,
"selected": true,
"text": "in"
},
{
"answer_id": 74136827,
"author": "Svetoslav Petkov",
"author_id": 11612861,
"author_pr... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13484284/"
] |
74,136,446 | <p>I am working on a code like below, which slices the address column. For this I have created a dictionary and created an empty list <code>final</code> to append all the pre processing.see code</p>
<pre><code>import pandas as pd
data = {'id': ['001', '002', '003'],
'address': ["William J. Clare\\n290 Valley Dr.\\nCasper, WY 82604\\nUSA",
"1180 Shelard Tower\\nMinneapolis, MN 55426\\nUSA",
"William N. Barnard\\n145 S. Durbin\\nCasper, WY 82601\\nUSA"]
df_dict = df.to_dict('records')
final = []
for row in df_dict:
add = row["address"]
# print(add.split("\\n") , len(add.split("\\n")))
if len(add.split("\\n")) > 3:
target = add.split("\\n")
target = target[-3:]
target = '\\n'.join(target)
else:
target = add.split("\\n")
target = '\\n'.join(target)
final.append(target)
print(target)
</code></pre>
<p>After preprocessing I am appending the empty list. Now, I want to update the <code>df_dict</code> with the <code>final</code> list. and convert the <code>df_dict</code> to pandas dataframe.</p>
<p>sample out put:</p>
<pre><code>id address
1 290 Valley Dr.\\nCasper, WY 82604\\nUSA
2 1180 Shelard Tower\\nMinneapolis, MN 55426\\nUSA
3 145 S. Durbin\\nCasper, WY 82601\\nUSA
</code></pre>
<p>Your help will be greatly appreciated.</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 74136538,
"author": "Tobias S.",
"author_id": 8613630,
"author_profile": "https://Stackoverflow.com/users/8613630",
"pm_score": 3,
"selected": true,
"text": "in"
},
{
"answer_id": 74136827,
"author": "Svetoslav Petkov",
"author_id": 11612861,
"author_pr... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19382789/"
] |
74,136,454 | <p>I'm writing a code for django to list posts in a ListView and DetailView:
converting from functional to class view. I can get all the posts to show up, but I want only published posts to show on the list.</p>
<p>I know I can use
published = Post.objects.exclude(published_date__exact=None)
<em>posts</em> = published.order_by('-published_date')</p>
<p>but how do I get only the <em>posts</em> variable to render in the template, instead of all Post objects in post_list (in list.html template)?</p>
<p>views.py:</p>
<pre><code>from blogging.models import Post
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
class PostListView(ListView):
model = Post
template_name = 'blogging/list.html'
published = Post.objects.exclude(published_date__exact=None)
posts = published.order_by('-published_date')
class PostDetailView(DetailView):
model = Post
template_name = 'blogging/detail.html'
</code></pre>
<p>urls.py</p>
<pre><code>from django.urls import path
from blogging.views import PostListView, PostDetailView
urlpatterns = [
path('', PostListView.as_view(), name="blog_index"),
path('posts/<int:pk>/', PostDetailView.as_view(), name="blog_detail"),
]
</code></pre>
<p>list.html:</p>
<pre><code>{% extends "base.html" %}{% block content %}
<h1>Recent Posts</h1>
{% comment %} here is where the query happens {% endcomment %}
{% for post in post_list %}
<div class="post">
<h2><a href="{% url 'blog_detail' post.pk %}">{{ post }}</a></h2>
<p class="byline">
Posted by {{ post.author.username }} &mdash; {{ post.published_date }}
</p>
<div class="post-body">
{{ post.text }}
</div>
<ul class="categories">
{% for category in post.categories.all %}
<li>{{ category }}</li>
{% endfor %}
</ul>
</div>
{% endfor %}
{% endblock %}
</code></pre>
| [
{
"answer_id": 74136601,
"author": "Christine Kim",
"author_id": 20260139,
"author_profile": "https://Stackoverflow.com/users/20260139",
"pm_score": 1,
"selected": false,
"text": "from blogging.models import Post\nfrom django.views.generic.list import ListView\n#...\n\nclass PostListView... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20260139/"
] |
74,136,530 | <p>I have Paraquet files in my S3 bucket which is not AWS S3.</p>
<p>Is there a tool that connects to any S3 service (like Wasabi, Digital Ocean, MinIO), and allows me to query the Parquet files?</p>
| [
{
"answer_id": 74165348,
"author": "shetty15",
"author_id": 6563567,
"author_profile": "https://Stackoverflow.com/users/6563567",
"pm_score": 2,
"selected": true,
"text": "-- Execute these commnds one by one or run as a script from DBeaver\nINSTALL httpfs;\nLOAD httpfs;\nSET s3_region='u... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16100168/"
] |
74,136,567 | <p>I have simple RunBase Dialog:</p>
<pre><code>Dialog dialog;
DialogField fieldFilenameOpen;
dialog = super();
fieldFilenameOpen = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(['xml','*.xml']);
return dialog;
</code></pre>
<p>Is it possible to set the dialog to allow the selection of multiple files?</p>
<p>Best Regards</p>
| [
{
"answer_id": 74157959,
"author": "Alex Kwitny",
"author_id": 1179573,
"author_profile": "https://Stackoverflow.com/users/1179573",
"pm_score": 2,
"selected": false,
"text": "WinAPI::getOpenFileName(...)"
},
{
"answer_id": 74177829,
"author": "Tomasz Filipek",
"author_id... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4733546/"
] |
74,136,594 | <p>So let's say I have a string like so :</p>
<pre class="lang-py prettyprint-override"><code>foo = '''
some
important
stuff
'''
</code></pre>
<p>Is it possible to comment something inside it ? for instance :</p>
<pre class="lang-py prettyprint-override"><code>foo = '''
some
# important
stuff
'''
</code></pre>
| [
{
"answer_id": 74136718,
"author": "DeepSpace",
"author_id": 1453822,
"author_profile": "https://Stackoverflow.com/users/1453822",
"pm_score": 1,
"selected": false,
"text": "'''"
},
{
"answer_id": 74136894,
"author": "Ovski",
"author_id": 8610346,
"author_profile": "h... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12025753/"
] |
74,136,615 | <p>Wen I try to compile my file stack-zero.c with the command <code>gcc stack-zero.c -o stack0</code> it show this as error <code>stack-zero.c:19:17: error: expected ‘)’ before ‘LEVELNAME’</code></p>
<p>The code is as follows</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define BANNER \
"Welcome to " LEVELNAME ", brought to you by https://exploit.education"
char *gets(char *);
int main(int argc, char **argv) {
struct {
char buffer[64];
volatile int changeme;
} locals;
printf("%s\n", BANNER);
locals.changeme = 0;
gets(locals.buffer);
if (locals.changeme != 0) {
puts("Well done, the 'changeme' variable has been changed!");
} else {
puts(
"Uh oh, 'changeme' has not yet been changed. Would you like to try "
"again?");
}
exit(0);
}
</code></pre>
| [
{
"answer_id": 74136715,
"author": "Gerhard",
"author_id": 34989,
"author_profile": "https://Stackoverflow.com/users/34989",
"pm_score": 1,
"selected": false,
"text": "LEVELNAME"
},
{
"answer_id": 74136737,
"author": "Aatif Shaikh",
"author_id": 12703411,
"author_prof... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20289600/"
] |
74,136,622 | <p>I have a question</p>
<p>I want to join two tables (Table1 and Table2) on custID column.</p>
<p>However for the join to work I need to edit Table1s custID column vlaues by removing the first two characters ('CC') and replacing them with 0s so the final output is padded to 8 digits.</p>
<p>So if Table1 had a value in custID of CC34054 then this would need to be converted to 00034054 for the join to identify that value in Table2.custID. If for instance the custID value in Table1 was CC3356, the value would need to be revised to 00003356 for the join to match.</p>
<p>Ive made some tables below so I can illustrate what I mean.</p>
<p>Table1</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>CustID</th>
</tr>
</thead>
<tbody>
<tr>
<td>CC34054</td>
</tr>
<tr>
<td>CC3356</td>
</tr>
<tr>
<td>CC87901</td>
</tr>
</tbody>
</table>
</div>
<p>Table2</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>CustID</th>
</tr>
</thead>
<tbody>
<tr>
<td>00034054</td>
</tr>
<tr>
<td>00003356</td>
</tr>
<tr>
<td>00087901</td>
</tr>
</tbody>
</table>
</div>
<p>I hope this makes sense. thanks!</p>
| [
{
"answer_id": 74136715,
"author": "Gerhard",
"author_id": 34989,
"author_profile": "https://Stackoverflow.com/users/34989",
"pm_score": 1,
"selected": false,
"text": "LEVELNAME"
},
{
"answer_id": 74136737,
"author": "Aatif Shaikh",
"author_id": 12703411,
"author_prof... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14652524/"
] |
74,136,628 | <p>Here is my json file</p>
<pre><code> {
"file-list":[
"ab3bdc2c3d-f2fg63-42c3-abasd53-e78c66afc77d"
],
"metadata":{
"X-Object-Meta-Favourite":"true"
}
}
</code></pre>
<p>So i want to change <code>"X-Object-Meta-Favourite":"true"</code> 's value to false.</p>
<p>First i read</p>
<pre><code>public static JSONObject favourite() throws IOException {
String body = new String(Files.readAllBytes(Paths.get("src/test/resources/config/environments/FileSystem/Favourite.json")));
return new JSONObject(body);
}
</code></pre>
<p>And it returns JSONObject. So i use this body int his method:</p>
<pre><code>public void fovurite(String action) throws IOException {
action = "false";
JSONObject body = readFiles.favourite();
body.put(body.getJSONObject("metadata").getString("X-Object-Meta-Favourite"),action);
</code></pre>
<p>But added <code>true = "false"</code> value. I couldnt change <code>X-Object-Meta-Favourite</code> ' value.</p>
<p>I also tried <code>body.put("metadata['X-Object-Meta-Favourite']",action)</code> but this time added <code>metadata['X-Object-Meta-Favourite'] = "false"</code></p>
<p>In short how can i change this value ? Thank you for your advice</p>
| [
{
"answer_id": 74136715,
"author": "Gerhard",
"author_id": 34989,
"author_profile": "https://Stackoverflow.com/users/34989",
"pm_score": 1,
"selected": false,
"text": "LEVELNAME"
},
{
"answer_id": 74136737,
"author": "Aatif Shaikh",
"author_id": 12703411,
"author_prof... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19672397/"
] |
74,136,632 | <p>I am working on a react app using mainly functional components. This is all tested with the react - testing library. I would like to test the focus of some elements to show that after some interactions certain elements gain focus but I cant see anything to support this.
Is it possible ?</p>
<p>thanks</p>
| [
{
"answer_id": 74136920,
"author": "Agos",
"author_id": 107613,
"author_profile": "https://Stackoverflow.com/users/107613",
"pm_score": 2,
"selected": true,
"text": "jest-dom"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/665893/"
] |
74,136,673 | <p>For abstraction purposes I need to implement a function that accept different types of inputs.</p>
<pre class="lang-js prettyprint-override"><code>type ContentA = string
type ContentB = number
type InputA = {
name: 'method_a'
content: ContentA
}
type InputB = {
name: 'method_b'
content: ContentB
}
type Input = InputA | InputB
</code></pre>
<p>Each input is needed for a different method:</p>
<pre class="lang-js prettyprint-override"><code>const my_methods = {
method_a: (content:ContentA) => {
// ...
},
method_b: (content:ContentB) => {
// ...
}
}
</code></pre>
<p>Now I need to implement a generic function that accept all of the inputs, this is because the input types can be a lot, now there are only 2, but in my real application they are around 16.</p>
<p>I would like to have an implementation like this one, however it lead me to a compilation error:</p>
<pre class="lang-js prettyprint-override"><code>function foo(input:Input){
return my_methods[input.name](input.content);
// ^
// | Argument of type 'string | number' is not
// | assignable to parameter of type 'never'.
// | Type 'string' is not assignable to type 'never'.
}
</code></pre>
<p>Is there a way for Typescript to infer that since I am using <code>input.name</code> then the argument of the method is correct - since they will always match <code>input.name</code> and <code>input.content</code>?</p>
<p><a href="https://www.typescriptlang.org/play?#code/C4TwDgpgBAwg9gO2BJBBKBeKBnYAnASwQHMAoU0SWRZJAIUygQFcBbAIwj3MugEkEYZsHRYA3qSYBDVhABcUAOSzgACzgATAPpTFkgMY0UwBfCTHUpAL49w-QcIbjJCGfKUr129nqiHzSKZG9Na2VAJCwIwRwugAPlAxwHTk-rhQrCBanprYjBIZEGqaOgoAFP60JmZVqACUmAB8UAVQAPRtUAB0PZJWADSSOd7llcZyNcZ0DRjNrR3dvVA2NqQAZswI+sAEiFBrcHBlRJFySXUFeEXMeAgZWcPYANonwl2usgC6xw7AXWNIOoAbmsQA" rel="nofollow noreferrer">Playground link</a></p>
| [
{
"answer_id": 74137138,
"author": "Agos",
"author_id": 107613,
"author_profile": "https://Stackoverflow.com/users/107613",
"pm_score": 0,
"selected": false,
"text": "function foo(input: Input) {\n switch(input.name) {\n case 'method_a': {\n // input.content is guara... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13484284/"
] |
74,136,688 | <p>I have a collection A in cloud Firestore which is empty for now but later it will be filled, I want to display a widget like Text("No Data") when there is no data in it.
This is my code</p>
<pre><code>class Green extends StatefulWidget {
const Green({Key? key}) : super(key: key);
@override
State<Green> createState() => _GreenState();
}
class _GreenState extends State<Green> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance
.collection(uid)
.where("gatename", isEqualTo: "A")
.snapshots(),
builder: (_, snapshot2) {
if (snapshot2.hasError) return Text('Error = ${snapshot2.error}');
if (snapshot2.hasData) {
final ds = snapshot2.data!.docs;
return Padding(
padding: const EdgeInsets.all(38.0),
child: Container(
height: 600,
child: ListView.builder(
itemCount: ds.length,
itemBuilder: (_, i) {
final d = ds[i].data();
return ListTile(
title: Text(d["time"].toString()),
leading: Text(d["gatename"].toString()),
);
},
),
),
);
}
return const Center(child: CircularProgressIndicator());
},
));
}
}
</code></pre>
<p>I have used <code>else if (snapshot.data!.docs.isEmpty){}</code>
but it is still showing white screen.</p>
| [
{
"answer_id": 74137138,
"author": "Agos",
"author_id": 107613,
"author_profile": "https://Stackoverflow.com/users/107613",
"pm_score": 0,
"selected": false,
"text": "function foo(input: Input) {\n switch(input.name) {\n case 'method_a': {\n // input.content is guara... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20253906/"
] |
74,136,694 | <p>Normally, when the latest parameter of a function is a lambda , I can use such as <code>function(first,...) {latest}</code> to pass the lambda parameter.</p>
<p>The Code A and Code B are from the official sample <a href="https://github.com/android/nowinandroid" rel="nofollow noreferrer">project</a>.</p>
<p>There are three lambda parameters in fun <code>NiaFilledButton</code> which are <code>text</code>, <code>leadingIcon</code> and <code>trailingIcon</code> in Code A.</p>
<p>When the author invoke the function with Code B, which parameter will be assigned with the value of <code>Text(text = "Enabled")</code> ?</p>
<p><strong>Code A</strong></p>
<pre><code>@Composable
fun NiaFilledButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
small: Boolean = false,
colors: ButtonColors = NiaButtonDefaults.filledButtonColors(),
text: @Composable () -> Unit,
leadingIcon: @Composable (() -> Unit)? = null,
trailingIcon: @Composable (() -> Unit)? = null
) {
...
}
</code></pre>
<p><strong>Code B</strong></p>
<pre><code>NiaFilledButton(onClick = {}) {
Text(text = "Enabled")
}
</code></pre>
| [
{
"answer_id": 74136877,
"author": "TheLibrarian",
"author_id": 3434763,
"author_profile": "https://Stackoverflow.com/users/3434763",
"pm_score": 0,
"selected": false,
"text": "fun main() {\n foo(o= { println(\"o\")} ) { println(\"b\") }\n}\n\nfun foo(\n o: () -> Unit,\n b: (() ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/828896/"
] |
74,136,730 | <p>I feel like i've seen this question somewhere before but i cannot find it and i'm pretty sure ruby has a one liner for looping over something and adding the items to an array:</p>
<pre><code>items = []
some_stuff.each do |stuff|
items << stuff
end
items
</code></pre>
| [
{
"answer_id": 74136811,
"author": "Ursus",
"author_id": 3857758,
"author_profile": "https://Stackoverflow.com/users/3857758",
"pm_score": 1,
"selected": false,
"text": "items = some_stuff.inject([]) { |acc, item| acc + [item] }\n"
},
{
"answer_id": 74136851,
"author": "Rajag... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19940362/"
] |
74,136,732 | <p>I am trying to grant access to <strong>IoT Hub</strong> based on <strong>Azure AD</strong>. But when I try to get token, it is throwing this error in <strong>Postman</strong>
<a href="https://i.stack.imgur.com/Kdxn9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kdxn9.png" alt="enter image description here" /></a></p>
<p><strong>####### Update ######</strong>
I have already created the Application in Azure AD
<a href="https://i.stack.imgur.com/I2uAV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I2uAV.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/SxRaH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SxRaH.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74136811,
"author": "Ursus",
"author_id": 3857758,
"author_profile": "https://Stackoverflow.com/users/3857758",
"pm_score": 1,
"selected": false,
"text": "items = some_stuff.inject([]) { |acc, item| acc + [item] }\n"
},
{
"answer_id": 74136851,
"author": "Rajag... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8018614/"
] |
74,136,753 | <p>I have small problem in app. Backend is Laravel and Front end is Nuxtjs.
When User registered on app,then users must be wait antill Administartor approved.
When Admin approved this user we give them 3 months subscription.</p>
<p>In my code this part is not working.</p>
<pre><code>$user->activated_at = now();
$user->activated_at = date('Y-m-d H:i');
</code></pre>
<pre><code> {
$user = User::find($id);
if (is_null($user)) {
return $this->sendError('admin_messages.user_not_found');
}
$user->status = User::ACTIVE;
$user->activated_at = now();
$user->activated_at = date('Y-m-d H:i');
dd($user->activated_at);
$user->save();
Mail::to($user->email)->queue(new ApproveNotificationMail($user));
return $this->sendResponse('admin_messages.user_activated');
}
</code></pre>
| [
{
"answer_id": 74136811,
"author": "Ursus",
"author_id": 3857758,
"author_profile": "https://Stackoverflow.com/users/3857758",
"pm_score": 1,
"selected": false,
"text": "items = some_stuff.inject([]) { |acc, item| acc + [item] }\n"
},
{
"answer_id": 74136851,
"author": "Rajag... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1808731/"
] |
74,136,803 | <p>I am begginer,I am faced with a challenge to take few numbers and multiply the odd numbers in them to apply the lunhs alogrithm.</p>
<p>Ex- If user inputs 100034341341313413941391341393413.
Is there any way I can take this input and specifically filter out the numbers in the odd places and even places and add them ?</p>
<p>Please just show me the way or how I can get it the number in a array and approach it.The rest i'll figure out.</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 74136914,
"author": "erenalyoruk",
"author_id": 12463055,
"author_profile": "https://Stackoverflow.com/users/12463055",
"pm_score": 2,
"selected": true,
"text": "%"
},
{
"answer_id": 74163434,
"author": "Luis Colorado",
"author_id": 3899431,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10868538/"
] |
74,136,808 | <pre><code> if(diff != 0){
if(diff >= 50){
if(userGuess > toGuess){
cout << "Very high" << endl;
} else if (userGuess < toGuess){
cout << "Very low" << endl;
}
}
if(diff >= 30 && diff < 50){
if(userGuess > toGuess){
cout << "high" << endl;
} else if (userGuess < toGuess){
cout << "low" << endl;
}
}
if(diff >= 15 && diff < 30){
if(userGuess > toGuess){
cout << "Moderately high" << endl;
} else if (userGuess < toGuess){
cout << "Moderately low" << endl;
}
}
if(diff > 0 && diff < 15){
if(userGuess > toGuess){
cout << "Somewhat high" << endl;
} else if (userGuess < toGuess){
cout << "Somewhat low" << endl;
}
}
</code></pre>
<p>}</p>
<p>These if statement are in loops that run until the correct number is guessed, my question is, instead of having all these if statements can I make it better with a big loop.</p>
| [
{
"answer_id": 74136944,
"author": "Locke",
"author_id": 5987669,
"author_profile": "https://Stackoverflow.com/users/5987669",
"pm_score": 1,
"selected": false,
"text": "// Add size prefix based on difference\nif (diff > 50) {\n cout << \"Very \";\n} else if (diff >= 30) {\n // No ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20289819/"
] |
74,136,815 | <p>I have this list of lists:</p>
<pre><code>regions <- list(c("AO", "BI", "BW", "DJ", "DZ", "ET", "GH", "GM", "KE", "LS", "MA", "MR", "MW", "MZ", "NG", "SL", "SZ", "TN", "TZ", "UG", "ZA", "ZM", "ZR", "ZW"),
c("BD", "CN", "HK", "ID", "IN", "KR", "MU", "MY", "PH", "PK", "SG", "TH", "TW", "VN", "AU", "NZ"),
c("AT", "BA", "BE", "BL", "CH", "CI", "CT", "CY", "CZ", "DE", "DK", "EO", "ES", "EU", "FI", "FR", "GA", "GB", "GG", "GR", "HU", "IC", "IE", "IT", "JR", "KZ", "LN", "LU", "LV", "MK", "MT", "NL", "NO", "PO", "PT", "RM", "RS", "RU", "SE", "SJ", "SX", "TR", "UR"),
c("AD", "AE", "BH", "DU", "EG", "IQ", "IR", "IS", "JO", "KW", "LB", "OM", "PS", "QA", "SA", "SY", "YE"),
c("CA", "KY", "US"),
c("AR", "BR", "CB", "CL", "EC", "MX", "PA", "PE", "PY", "UY", "VE"),
c("JP"))
</code></pre>
<p>There are 7 lists, and I would like this data in a tibble format, with a region ID for each list:</p>
<pre><code>country | region_id
"AO" | 1
"BI" | 1
"BW" | 1
...
"BD" | 2
"CN" | 2
"HK" | 2
...
</code></pre>
| [
{
"answer_id": 74136850,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 3,
"selected": true,
"text": "enframe"
},
{
"answer_id": 74137017,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_pr... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13622404/"
] |
74,136,817 | <p>I have the following method in my Spring Boot app in my Repository:</p>
<pre><code>@Query("""
SELECT tw FROM TW tw
INNER JOIN tw.docks d // TW entity has list of docks
WHERE d.id = :dockId
AND tw.status <> 'DELETED'
""")
List<TW> findAllTWs(long dockId);
</code></pre>
<p>How to check if TW has exactly one dock (tw.docks.size() == 1)? I have to filter out tw.docks with more than 1 dock (I want only list of TWs with one dock)
Probably I need native query for that</p>
| [
{
"answer_id": 74136850,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 3,
"selected": true,
"text": "enframe"
},
{
"answer_id": 74137017,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_pr... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6022333/"
] |
74,136,823 | <p>everyone. Im new to apex, I was trying for code coverage of atleast 75% on my batch apex code through test class. But im getting the error " System.QueryException: List has no rows for assignment to SObject ". Execute method is not covering in the code. Will anyone point out whats wrong with the testclass?</p>
<p>Batch Apex Class:-</p>
<pre><code>Global class BatchApexOnAccount implements Database.Batchable<sObject> {
Global Database.QueryLocator start (Database.BatchableContext Bc){
return Database.getQueryLocator('Select Id, Name from Account');
}
Global void Execute(Database.BatchableContext Bc, List<Account> AccList){
List<Account> AccEmpty = new List<Account>();
for(Account Acc : AccList){
Acc.Name = 'Salesforce';
Acc.Description = 'Update Account ' + system.today();
AccEmpty.add(Acc);
}
Update AccEmpty;
}
Global void Finish (Database.BatchableContext Bc){
}
</code></pre>
<p>}</p>
<p>Test class:-</p>
<p><a href="https://i.stack.imgur.com/vskwd.png" rel="nofollow noreferrer">Test code</a></p>
| [
{
"answer_id": 74136850,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 3,
"selected": true,
"text": "enframe"
},
{
"answer_id": 74137017,
"author": "ThomasIsCoding",
"author_id": 12158757,
"author_pr... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20289749/"
] |
74,136,824 | <p>We have made an app where users can upload a profile photo. We want to make sure that the photos are of the users themselves and not celebrities or memes, so we send out a mail to moderators every time a photo is uploaded with a link to <a href="https://lens.google.com/uploadbyurl?url=.." rel="nofollow noreferrer">https://lens.google.com/uploadbyurl?url=..</a>. . This works great on desktop, but on mobile the link gives a 404, with or without the Google app installed.</p>
<p>Does anyone know why, or have a link that works on mobile as well?</p>
| [
{
"answer_id": 74506758,
"author": "Bohdan",
"author_id": 15171133,
"author_profile": "https://Stackoverflow.com/users/15171133",
"pm_score": 2,
"selected": true,
"text": "https://www.google.com/searchbyimage?sbisrc=4chanx&image_url=%IMG&safe=off\n"
},
{
"answer_id": 74577717,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2837999/"
] |
74,136,846 | <pre><code> const [name, setName] = useState("");
const [age, setAge] = useState("");
const initialValues = {
name: "",
age: "",
};
const [formValues, setFormValues] = useState(initialValues);
const [formErrors, setFormErrors] = useState({});
const [isSubmit, setIsSubmit] = useState(false);
const handleChange = (e) => {
const { name, value } = e.target;
setFormValues({ ...formValues, [name]: value });
};
const handleSubmit = (e) => {
setFormErrors(validate(formValues));
setIsSubmit(true);
};
const validate = (values) => {
const errors = {};
if (!values.name) {
errors.name = "Name is required";
}
if (!values.age) {
errors.age= "Age is required";
}
return errors;
};
const userCreate = async () => {
await api.post("/createuser", {
name,
age,
});
};
return (
<div class="container">
<Form
onSubmit={
Object.keys(formErrors).length === 0 && isSubmit
? userCreate
: handleSubmit
}
>
<Form.Field>
<label>Name</label>
<input
name="name"
onChange={(e) => {
setName(e.target.value);
handleChange(e);
}}
values={formValues.name}
/>
<span className="error-message">{formErrors.name}</span>
</Form.Field>
<Form.Field>
<label>Age</label>
<input
name="age"
onChange={(e) => {
setAge(e.target.value);
handleChange(e);
}}
values={formValues.age}
/>
<p className="error-message">{formErrors.age}</p>
</Form.Field>
<Button type="submit">Submit</Button>
</Form>
</div>
);
</code></pre>
<p>I'm trying to use <strong>axios</strong> to do POST method for creating user.</p>
<p>I got everything works fine but there's one small problem but I don't know how to fix.</p>
<p>The problem is that I always need to submit the form 2 times to make the POST request. There's nothing happen in the first submit, but it will work in the second submit.</p>
<p>Does anyone know what's wrong with my code?</p>
<p><strong>Edited</strong></p>
<p>According to @DBS solution.
I'm trying to follow the steps but now the form can't submit anymore. Can someone let me know if I missed something?</p>
<pre><code>const [name, setName] = useState("");
const [age, setAge] = useState("");
const initialValues = {
name: "",
age: "",
};
const [formValues, setFormValues] = useState(initialValues);
const [formErrors, setFormErrors] = useState({});
const [isSubmitting, setIsSubmitting] = useState(false);
const handleChange = (e) => {
const { name, value } = e.target;
setFormValues({ ...formValues, [name]: value });
};
const handleSubmit = (e) => {
if (!Object.keys(formErrors).length && !isSubmitting) {
setFormErrors(validate(formValues));
} else {
userCreate();
setisSubmitting(true);
}
};
const validate = (values) => {
const errors = {};
if (!values.name) {
errors.name = "Name is required";
}
if (!values.age) {
errors.age= "Age is required";
}
return errors;
};
const userCreate = async () => {
await api.post("/createuser", {
name,
age,
});
};
return (
<div class="container">
<Form
onSubmit={handleSubmit}
>
<Form.Field>
<label>Name</label>
<input
name="name"
onChange={(e) => {
setName(e.target.value);
handleChange(e);
}}
values={formValues.name}
/>
<span className="error-message">{formErrors.name}</span>
</Form.Field>
<Form.Field>
<label>Age</label>
<input
name="age"
onChange={(e) => {
setAge(e.target.value);
handleChange(e);
}}
values={formValues.age}
/>
<p className="error-message">{formErrors.age}</p>
<
</code></pre>
| [
{
"answer_id": 74137012,
"author": "DBS",
"author_id": 1650337,
"author_profile": "https://Stackoverflow.com/users/1650337",
"pm_score": 2,
"selected": false,
"text": "isSubmit"
},
{
"answer_id": 74138673,
"author": "Helphin",
"author_id": 3314078,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20279498/"
] |
74,136,847 | <p>I'd like to add sleep to this request so as not to stress the server with too many requests at a go. I've tried adding sleep but I don't get the expected behaviour. The help is appreciated.</p>
<pre><code>xargs -I{} curl --location --request POST 'https://g.com' \
--header 'Authorization: Bearer cc' \
--header 'Content-Type: application/json' \
--data-raw '{
"c_ids": [
"{}"
]
}' '; sleep 5m' < ~/recent.txt
</code></pre>
| [
{
"answer_id": 74137012,
"author": "DBS",
"author_id": 1650337,
"author_profile": "https://Stackoverflow.com/users/1650337",
"pm_score": 2,
"selected": false,
"text": "isSubmit"
},
{
"answer_id": 74138673,
"author": "Helphin",
"author_id": 3314078,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/932337/"
] |
74,136,848 | <p>im using the antd model to popup a visual. I need to remove the cancel and Ok button but keep the X button working so that i can close the popup using that button.</p>
<p>i removed the Cancel and Ok button using below code <strong>but after that clicking on X is not working and can't close</strong></p>
<pre><code> <Modal
title="Lost Assets"
visible={isModalOpen}
width="95%"
style={{ top: "20px" }}
bodyStyle={{ height: "calc(100vh - 170px)" }}
footer={null}
</code></pre>
<p>How can i make the <strong>X button workable</strong> and make it <strong>a little bit large in size?</strong></p>
<p><a href="https://i.stack.imgur.com/tMznk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tMznk.png" alt="enter image description here" /></a></p>
<p>Remove the below two buttons and keep the top X workable.</p>
| [
{
"answer_id": 74136952,
"author": "Fried noodles",
"author_id": 11344953,
"author_profile": "https://Stackoverflow.com/users/11344953",
"pm_score": 2,
"selected": true,
"text": "closable"
},
{
"answer_id": 74137109,
"author": "Helphin",
"author_id": 3314078,
"author_... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20148710/"
] |
74,136,875 | <p>I am really stuck at a place where I want a regex for a cron Expression where the scenario is the length of cron Expression should be equal to 5.</p>
<p>Also it should accept every possible cron expression but it should be equal to 5.</p>
<p>For Example :-</p>
<ol>
<li><code>0 0 12 * * ?</code> -> this is invalid as this expression is not equalTo 5</li>
<li><code>0 0 12 * *</code> -> this is valid cron</li>
</ol>
<p>similarly,</p>
<ol start="3">
<li><p><code>* * * * *</code> -> this is valid cron expression as it is == 5</p>
</li>
<li><p><code>* * * * * *</code> -> this is invalid as it is !== 5</p>
</li>
<li><p><code>0 15 10 * * ? 2005</code> -> this also invalid cron</p>
</li>
<li><p><code>0 15 10 * 2005</code> -> this is valid cron</p>
</li>
<li><p><code>0 0-5 14</code> -> Invalid</p>
</li>
<li><p><code>0 0-5 14 * *</code> -> Valid</p>
</li>
</ol>
<p>This are scenarios where the cron expression should be === 5 if it is less than 5 or greater than 5 then it should give error as (CronExpression is invalid)</p>
<p>Any way we can only do this through regex or can write a javascript function which will handle such case for cronExpression ?</p>
<p>I have search everywhere for this regex but couldn't found any regex with such scenario</p>
<p>Any help with example will be appreciated!!!</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 74137004,
"author": "Roberto Falcon",
"author_id": 14146695,
"author_profile": "https://Stackoverflow.com/users/14146695",
"pm_score": 3,
"selected": true,
"text": "function validateCron(cron){\nreturn cron.split(' ').length === 5;\n}\n"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11422199/"
] |
74,136,930 | <p>Using groupby and agg, is it possible to, in the same expression, get the 'count' divided by 'sum' returned?</p>
<pre><code>data=pd.DataFrame({'id':[1,1,1,2,2,3,3,3,3,4, 4],
'val':[10,11,10,13,12,15,12,9, 8, 14, 2]})
data.groupby(['id'])['val'].agg(['count','sum'])
</code></pre>
| [
{
"answer_id": 74136938,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 2,
"selected": true,
"text": "mean"
},
{
"answer_id": 74136941,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8510149/"
] |
74,136,934 | <p>I'm trying to add 3 spans in the same line but they keep taking up all the width of the page each and ending up in different lines.</p>
<p>This is the code and below is the style:
<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>.image-container {
position: relative;
width: 600px;
height: 300px;
text-align: center;
margin-top: 20px;
margin-left: 20px;
margin-right: 20px;
}
.info-container {
position: relative;
width: 200px;
height: 280px;
text-align: center;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="image-container">
<span class=info-container>
<div class="dot"></div>
<div class="dot-text">Test</div>
</span>
<span class=info-container>
<div class="dot"></div>
<div class="dot-text">Test</div>
</span>
<span class=info-container>
<div class="dot"></div>
<div class="dot-text">Test</div>
</span>
</div></code></pre>
</div>
</div>
</p>
<p>I've tried with the <code>image-container</code> as both <code><div></code> and <code><span></code> but neither works. Dot and dot-text have <code>100px</code> of both height and width</p>
| [
{
"answer_id": 74136938,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 2,
"selected": true,
"text": "mean"
},
{
"answer_id": 74136941,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20289874/"
] |
74,136,936 | <p>I have a list like below -</p>
<pre><code>[{'amount': 1100000, 'target': 120000, time': '2022-09-30T00:00:00.000Z'}, {'amount': 1100000, 'target': 120000, time': '2022-09-30T00:00:00.000Z'},
{'amount': 1100000, 'target': 120000, time': '2022-09-30T00:00:00.000Z'}]
</code></pre>
<p>Need to add index key and its value in these three records.
Expected output -</p>
<pre><code>[{'amount': 1100000, 'target': 120000, time': '2022-09-30T00:00:00.000Z','index':0}, {'amount': 1100000, 'target': 120000, time': '2022-09-30T00:00:00.000Z','index':1},
{'amount': 1100000, 'target': 120000, time': '2022-09-30T00:00:00.000Z','index':2}]
</code></pre>
<p>Please help.</p>
| [
{
"answer_id": 74136938,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 2,
"selected": true,
"text": "mean"
},
{
"answer_id": 74136941,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19540408/"
] |
74,136,950 | <p>I have a dataframe of string texts example:</p>
<pre><code>descripton
..32 cars are coming full of attendees..
..64 attendees..
..8 participants are allowed..
</code></pre>
<p>I want to extract using regex the number plus a specific word "participant or participants, attendant or attendees" after it immediately, so the output from this column should be:</p>
<pre><code>64 attendees
8 participants
</code></pre>
<p>and I will save the output in a new column using pandas.</p>
<p>I tried this code:</p>
<pre><code>data['affluence0'] = data['description'].str.findall(r'\d+(?= [personnes|participants|membres])')
</code></pre>
<p>but it's extracting all digits from the column and all these specific 3 words from every row. I want only the number followed by these specific keywords.</p>
| [
{
"answer_id": 74136938,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 2,
"selected": true,
"text": "mean"
},
{
"answer_id": 74136941,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14779367/"
] |
74,136,968 | <p>I'd like to write a function that will idempotently output either True or False on alternate datetime days, starting from a non-specific date and going on indefinitely.</p>
<p>For example, passing a datetime representing October 1st might output True, then October 2nd will output False, then October 3rd True, and so on... It should be possible to pass any datetime into this function and always get the same result for that datetime.</p>
<p>It should look something like:</p>
<pre><code>def date_check(date_to_check):
if [condition related to date_to_check]:
return True
else:
return False
</code></pre>
<p>I just can't figure out what the condition should be to always return True or False on alternating days.</p>
<p>I've considered calculating based on day of week but this isn't possible due to odd number of days in the week. I've considered calculating based on whether the day of the month is odd or not but this won't work as months containing 31 days will produce two odd numbered days in a row (31 and 1).</p>
<p>EDIT: I considered also calculating based on whether the day of the year is odd or not but again: day 365 and day 1 will produce the same value consecutively.</p>
<p>Is there any way to do this?</p>
| [
{
"answer_id": 74137047,
"author": "Jiří Baum",
"author_id": 683329,
"author_profile": "https://Stackoverflow.com/users/683329",
"pm_score": 3,
"selected": true,
"text": "datetime"
},
{
"answer_id": 74137094,
"author": "Mortz",
"author_id": 4248842,
"author_profile": ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11316432/"
] |
74,136,976 | <p>I have a mega menu design with the following data structure</p>
<pre class="lang-js prettyprint-override"><code>const megaMenuLink = [
{
name: 'E-services',
link: '/e-services',
hasSubmenu: true,
subMenuItems: [
{
name: "Access E-services",
link: "/access",
},
{
name: "Register",
link: "/register"
}
]
},
{
name: "Other services",
link: "/services",
hasSubmenu: false,
}
]
</code></pre>
<p>I have accessed the name property with {#each} block</p>
<pre class="lang-html prettyprint-override"><code>{#each megaMenuLink as link}
<li>{link.name}</li>
{/each}
</code></pre>
<p>How do I loop through the inner subMenuItems based on condition of 'hasSubmenu' is true?</p>
| [
{
"answer_id": 74137631,
"author": "Corrl",
"author_id": 15388872,
"author_profile": "https://Stackoverflow.com/users/15388872",
"pm_score": 3,
"selected": true,
"text": "#if"
},
{
"answer_id": 74137968,
"author": "Naveen Kumar",
"author_id": 20290088,
"author_profile... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7065562/"
] |
74,136,994 | <p>I'm using MySQL 8.0
Table NameL: sc (score)<br />
Columns: student_id, course_id, score<br />
Some dummy data:</p>
<pre><code>create table sc(SId varchar(10),CId varchar(10),score decimal(18,1));
insert into sc values('01' , '01' , 80);
insert into sc values('01' , '02' , 90);
insert into sc values('01' , '03' , 99);
insert into sc values('02' , '01' , 70);
insert into sc values('02' , '02' , 60);
insert into sc values('02' , '03' , 80);
insert into sc values('03' , '01' , 80);
insert into sc values('03' , '02' , 80);
insert into sc values('03' , '03' , 80);
insert into sc values('04' , '01' , 50);
insert into sc values('04' , '02' , 30);
insert into sc values('04' , '03' , 20);
insert into sc values('05' , '01' , 76);
insert into sc values('05' , '02' , 87);
insert into sc values('06' , '01' , 31);
insert into sc values('06' , '03' , 34);
insert into sc values('07' , '02' , 89);
insert into sc values('07' , '03' , 98);
</code></pre>
<p>The question is: <strong>Output all the scores and the average scores of each student, and order the results in descending order of average score.</strong></p>
<p>I came up with two solutions:</p>
<pre><code>-- Solution 1
SELECT
sc.*,
AVG(score) OVER (PARTITION BY sid) AS avg_score
FROM sc
ORDER BY avg_score DESC
</code></pre>
<pre><code>-- Solution 2
select * from sc
left join (
select sid,avg(score) as avscore from sc
group by sid
)r
on sc.sid = r.sid
order by avscore desc;
</code></pre>
<h3>But is there a difference in the performance of the efficiency of these two solutions if the table is really big?</h3>
<p>Here's the screenshot of EXPLAIN for these two queries:
<a href="https://i.stack.imgur.com/oODCt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oODCt.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74137631,
"author": "Corrl",
"author_id": 15388872,
"author_profile": "https://Stackoverflow.com/users/15388872",
"pm_score": 3,
"selected": true,
"text": "#if"
},
{
"answer_id": 74137968,
"author": "Naveen Kumar",
"author_id": 20290088,
"author_profile... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74136994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11207179/"
] |
74,137,001 | <p>I tried to create new React Native project and it failed due to error of multiple podfiles were found.</p>
<pre><code>error: warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
</code></pre>
| [
{
"answer_id": 74151122,
"author": "LukasMod",
"author_id": 15073323,
"author_profile": "https://Stackoverflow.com/users/15073323",
"pm_score": 2,
"selected": false,
"text": "npx react-native init AwesomeProject"
},
{
"answer_id": 74152318,
"author": "Kartik Rana",
"autho... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8200791/"
] |
74,137,016 | <p>I've currently got a <code>SectionList</code>. I'd like to wrap all items within a section in a <code>FlatList</code>. e.g. For the section <code>Queues Near You</code>, The three <code>RestaurantCard</code>s of Tonkotsu, Burgerville and Fried Fries should be in a <code>FlatList</code> that is horizontal, Restaraunt A,B,C should be in its own <code>FlatList</code>, etc. How can I achieve this?</p>
<pre><code>const sectionData = [
{
title: "Queues Near You",
data: ["Tonkotsu", "BurgerVille", "Fried Fries"],
},
{
title: "Restaurants Near You",
data: ["Restaurant A", "Restaurant B", "Resto C"],
},
{
title: "Additional Places Near You",
data: ["Resto D", "Resto E", "Resto F"],
},
];
</code></pre>
<pre><code>export default function App() {
const renderItem = ({item}) => {
const restaurantName = item
return <RestaurantCard restaurantName={restaurantName} />;
};
return (
<View style={tw`flex-1 bg-black`}>
<SectionList
sections={sectionData}
renderSectionHeader={({ section: { title } }) => {
return <SubHeader style={tw`flex-grow-0`} name={title} />
}}
renderItem={renderItem}
/>
</View>
);
}
</code></pre>
| [
{
"answer_id": 74151122,
"author": "LukasMod",
"author_id": 15073323,
"author_profile": "https://Stackoverflow.com/users/15073323",
"pm_score": 2,
"selected": false,
"text": "npx react-native init AwesomeProject"
},
{
"answer_id": 74152318,
"author": "Kartik Rana",
"autho... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10613037/"
] |
74,137,030 | <p>I have a static web with HTML, CSS and JS.</p>
<p>As an accessibility request, I must avoid the tabulation to read what's inside a closed toggle menu.</p>
<p>As well, once it's open, I must avoid the tabulation to exit the list of the menu until you select one, or when you exit the menu with escape or the exit button.</p>
<p><a href="https://i.stack.imgur.com/VM5bl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VM5bl.png" alt="enter image description here" /></a></p>
<p>I actually don´t know how to approach this.</p>
| [
{
"answer_id": 74151122,
"author": "LukasMod",
"author_id": 15073323,
"author_profile": "https://Stackoverflow.com/users/15073323",
"pm_score": 2,
"selected": false,
"text": "npx react-native init AwesomeProject"
},
{
"answer_id": 74152318,
"author": "Kartik Rana",
"autho... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14333857/"
] |
74,137,036 | <p>I'm making a sidebar with React and Tailwind. This is the content of <code>Sidebar.jsx</code>.</p>
<pre><code>import { FC } from "react";
import React, { useState } from 'react'
import { Link, NavLink } from "react-router-dom";
import HomeIcon from '@mui/icons-material/Home';
import ConstructionIcon from '@mui/icons-material/Construction';
import ContentPasteIcon from '@mui/icons-material/ContentPaste';
import SettingsIcon from '@mui/icons-material/Settings';
import SummarizeIcon from '@mui/icons-material/Summarize';
import {FaBars} from "react-icons/fa"
const SideBar: FC = () => {
const [open, setOpen] = useState(true);
const toggle = () => {
setOpen(!open);
};
return (
<div className="flex">
<div className={'bg-black w-[300px] h-100vh ${open: "w-[300px]" ? "w-[50px]"} transition-all duration-500'}>
<div className={'flex align-center px-[15px] py-[20px]'}>
<h1 className={'${open? "block" : "hidden"} text-white text-[30px]'}>
Logo
</h1>
<div className={'${open: "ml-[50px]": "ml-[0px]"} flex text-white text-[25px] mt-[12px] ml-[50px]'}>
<FaBars onClick={toggle}/>
</div>
</div>
<NavLink
className={'flex text-white px-[15px] py-[20px] gap-[15px] transition-all duration-500'}
to="/"
>
<HomeIcon className={'text-[20px]'}/>
<div className={'${open? "block": "hidden"} text-[20px]'}>
DASHBOARD
</div>
</NavLink>
</div>
</div>
);
};
export default SideBar;
</code></pre>
<p>Problem: On clicking the <code><FaBars /></code> icon, I need the sidebar to toggle between expanding and contracting, and I need the text of the NavLink to disappear, but it's not showing any change in width on click. Why is the "hidden" class not working, and why is the width of the sidebar not changed?</p>
<p>My attempts: I've inspected the output, and made sure the toggle function is being called. I just don't know why the width isn't changing from <code>w-[300px]</code> to <code>w-[50px]</code></p>
| [
{
"answer_id": 74137318,
"author": "Mutesa Cedric",
"author_id": 17977165,
"author_profile": "https://Stackoverflow.com/users/17977165",
"pm_score": 0,
"selected": false,
"text": "<div className={`bg-black w-[300px] h-100vh ${open? \"w-[300px]\" : \"w-[50px]\"} transition-all duration-50... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5211997/"
] |
74,137,046 | <p>I'm trying to filter account in laravel.1 user can have many accounts with different format. It doesnt seem to work.The query:</p>
<pre><code>$accounts = $user->account()->where('account_no','like', ['34%','35%','3303%','3304%'])->get();
</code></pre>
<p>i'm wondering if this can be done or not?</p>
| [
{
"answer_id": 74137187,
"author": "José A. Zapata",
"author_id": 8611195,
"author_profile": "https://Stackoverflow.com/users/8611195",
"pm_score": 0,
"selected": false,
"text": "$accounts = $user->account()->where('account_no','like','34%')\n ->orWhere('account_no','like','35%')\n ->o... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19973869/"
] |
74,137,068 | <p>I am attempting to create GA4 analytics events by POST-ing to the URL with the same details as a web app:</p>
<pre><code>curl -X POST "https://www.google-analytics.com/collect?v=2&tid=<MY_TID>&cid=<MY_CID>&t=event&en=someNonsense&ep.aParameter=value&z=1234567890" -H "Content-Type: text/plain;charset=UTF-8" -H "sec-fetch-mode: no-cors" -H "sec-fetch-site: cross-site" -H "sec-fetch-dest: empty" -H "pragma: no-cache" -H "cache-control: no-cache" -H "origin: http://localhost:5000" -H "content-length: 0" -H "accept-language: en-US,en;q=0.9" -H "accept-encoding: gzip, deflate, br" -H "user-agent: dummy"
</code></pre>
<p>All of these events show up perfectly in the realtime view, and if I add <code>&_dbg=1</code> to the URL, these events and all their parameters show up consistently and reliably in the DebugView too.</p>
<p>I waited 48 hours and the events didn't show up. I did the following to try to bring things to life:</p>
<ul>
<li>added all the event parameters as custom metrics</li>
<li>disabled the internal traffic filter which is active by default</li>
<li>dug through the settings and agreed to the "Data Processing Terms"</li>
</ul>
<p>I then waited a further 48 hours and nothing has changed. Things seem to work just fine if I do them through a browser with firebase-analytics.js.</p>
<p>Does anyone have any idea what I've missed/broken?</p>
<p>Is Google doing some post processing on events to make sure they're coming from a real web page? I can mimic the HTTPS requests of the browser and the events still wont get recorded.</p>
| [
{
"answer_id": 74137187,
"author": "José A. Zapata",
"author_id": 8611195,
"author_profile": "https://Stackoverflow.com/users/8611195",
"pm_score": 0,
"selected": false,
"text": "$accounts = $user->account()->where('account_no','like','34%')\n ->orWhere('account_no','like','35%')\n ->o... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4214803/"
] |
74,137,078 | <p>I'm having some issues compiling the code I wrote which has a custom class with an overloaded <code>=</code>.</p>
<p>rnumber.hpp:</p>
<pre class="lang-cpp prettyprint-override"><code>#include <string>
class rnumber {
public:
std::string number;
// I added this constructor in an edit
rnumber(std::string s) { number = s; }
void operator=(std::string s) { number = s; }
bool operator==(std::string s) { return number == s; }
friend std::ostream &operator<<(std::ostream &os, const rnumber n);
};
std::ostream &operator<<(std::ostream &os, const rnumber n) {
os << n.number;
return os;
}
</code></pre>
<p>main.cpp:</p>
<pre class="lang-cpp prettyprint-override"><code>#include "rnumber.hpp"
#include <iostream>
#include <string>
int main() {
rnumber a = "123";
}
</code></pre>
<p>For some reason, this does not compile with the error <code>conversion from ‘const char [4]’ to non-scalar type ‘rnumber’ requested</code>. This shouldn't be a problem, because <code>rnumber</code> has an overload for <code>=</code>. Why am I getting this error?</p>
<p>EDIT: Even after adding a constructor, it doesn't work.</p>
| [
{
"answer_id": 74137200,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 1,
"selected": false,
"text": "rnumber a = \"123\";"
},
{
"answer_id": 74137210,
"author": "Caleth",
"author_id": 2610810,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14830457/"
] |
74,137,110 | <p>I am using android studio and flutter. I want to build the screen as shown below in the image:<a href="https://i.stack.imgur.com/p0ZDz.png" rel="nofollow noreferrer">screen Image</a></p>
<p>let's say I have 4 screens. on the first screen, the bar will load up to 25%. the user will move to next screen by clicking on continue, the linearbar will load up to 50% and so on. the user will get back to previous screens by clicking on the back button in the appbar.</p>
<ul>
<li>I tried stepper but it doesn't serve my purpose.</li>
</ul>
| [
{
"answer_id": 74137200,
"author": "Jason Liam",
"author_id": 12002570,
"author_profile": "https://Stackoverflow.com/users/12002570",
"pm_score": 1,
"selected": false,
"text": "rnumber a = \"123\";"
},
{
"answer_id": 74137210,
"author": "Caleth",
"author_id": 2610810,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16018809/"
] |
74,137,116 | <p>We have a discriminator field <code>type</code> which we want to hide from the Swagger UI docs:</p>
<pre><code>class Foo(BDCBaseModel):
type: Literal["Foo"] = Field("Foo", exclude=True)
Name: str
class Bar(BDCBaseModel):
type: Literal["Bar"] = Field("Bar", exclude=True)
Name: str
class Demo(BDCBaseModel):
example: Union[Foo, Bar] = Field(discriminator="type")
</code></pre>
<p>The following router:</p>
<pre><code>@router.post("/demo")
async def demo(
foo: Foo,
):
demo = Demo(example=foo)
return demo
</code></pre>
<p>And this is shown in the Swagger docs:
<a href="https://i.stack.imgur.com/hrukJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hrukJ.png" alt="enter image description here" /></a></p>
<p>We don't want the user to see the type field as it is useless for him/her anyways.
We tried making the field private: <code>_type</code> which hides it from the docs but then it cannot be used as discriminator anymore:</p>
<pre><code> class Demo(BDCBaseModel):
File "pydantic\main.py", line 205, in pydantic.main.ModelMetaclass.__new__
File "pydantic\fields.py", line 491, in pydantic.fields.ModelField.infer
File "pydantic\fields.py", line 421, in pydantic.fields.ModelField.__init__
File "pydantic\fields.py", line 537, in pydantic.fields.ModelField.prepare
File "pydantic\fields.py", line 639, in pydantic.fields.ModelField._type_analysis
File "pydantic\fields.py", line 753, in pydantic.fields.ModelField.prepare_discriminated_union_sub_fields
File "pydantic\utils.py", line 739, in pydantic.utils.get_discriminator_alias_and_values
pydantic.errors.ConfigError: Model 'Foo' needs a discriminator field for key '_type'
</code></pre>
| [
{
"answer_id": 74138132,
"author": "Daniil Fajnberg",
"author_id": 19770795,
"author_profile": "https://Stackoverflow.com/users/19770795",
"pm_score": 2,
"selected": true,
"text": "type"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2606766/"
] |
74,137,120 | <p>Recently github <a href="https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/" rel="noreferrer">has announced change</a> that <code>echo "::set-output name=x::y"</code> command is deprecated and should be replaced by <code>echo "x=y" >> $GITHUB_OUTPUT</code></p>
<p>The previous command was able to process multilined value of <code>b</code> while the new approach fails with the folllowing errors</p>
<pre><code>Error: Unable to process file command 'output' successfully.
Error: Invalid format
</code></pre>
<p>In my script, I populate a variable <code>message</code> with a message text that should be sent to slack. I need output variables to pass that text to the next job step which performs the send operation.</p>
<pre><code>message="Coverage: $(cat coverage.txt). Covered: $(cat covered.txt). Uncovered: $(cat uncovered.txt). Coverage required: $(cat coverageRequires.csv)"
</code></pre>
<p>The last part of message includes context of a <code>csv</code> file which has multiple lines</p>
<p>While the <code>set-output</code> command was able to process such multilined parameters</p>
<pre><code>echo "::set-output name=text::$message"
</code></pre>
<p>the new version fails</p>
<pre><code>echo "text=$message" >> $GITHUB_OUTPUT
</code></pre>
<p>What can be done to fix or avoid this error?</p>
| [
{
"answer_id": 74137121,
"author": "Patlatus",
"author_id": 1517187,
"author_profile": "https://Stackoverflow.com/users/1517187",
"pm_score": 1,
"selected": false,
"text": "message=$(echo $message | tr '\\n' ' ')\necho \"text=$message\" >> $GITHUB_OUTPUT\n"
},
{
"answer_id": 7414... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1517187/"
] |
74,137,131 | <p>hello I'm running into a loop of errors when running a python code with all requirements installed, already try to python -m pip install python-binance and had no success</p>
<p>bellow the some of the loop errors</p>
<p>C:\Users\djino\Documents\Bot\Trading_Bot_9000 [main ≡]> python get_data.py sh run_signal.sh python tradebot.py
Execution of job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" skipped: maximum number of running instances reached (1)
Execution of job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" skipped: maximum number of running instances reached (1)
Execution of job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" skipped: maximum number of running instances reached (1)
Execution of job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" skipped: maximum number of running instances reached (1)
Execution of job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" skipped: maximum number of running instances reached (1)
Execution of job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" skipped: maximum number of running instances reached (1)
Job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" raised an exception
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\apscheduler\executors\base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "C:\Users\djino\Documents\Bot\Trading_Bot_9000\data_acquisition\get_binance_btc_0m.py", line 10, in get_binance_btc_0m_data
from binance.spot import Spot
ModuleNotFoundError: No module named 'binance.spot'
Job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" raised an exception
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\apscheduler\executors\base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "C:\Users\djino\Documents\Bot\Trading_Bot_9000\data_acquisition\get_binance_btc_0m.py", line 10, in get_binance_btc_0m_data
from binance.spot import Spot
ModuleNotFoundError: No module named 'binance.spot'
Job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" raised an exception
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\apscheduler\executors\base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "C:\Users\djino\Documents\Bot\Trading_Bot_9000\data_acquisition\get_binance_btc_0m.py", line 10, in get_binance_btc_0m_data
from binance.spot import Spot
ModuleNotFoundError: No module named 'binance.spot'
Job "get_binance_btc_0m_data (trigger: interval[0:00:00.100000], next run at: 2022-10-20 10:00:01 BST)" raised an exception
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\apscheduler\executors\base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "C:\Users\djino\Documents\Bot\Trading_Bot_9000\data_acquisition\get_binance_btc_0m.py", line 10, in get_binance_btc_0m_data
from binance.spot import Spot
ModuleNotFoundError: No module named 'binance.spot'
Job "get_binance_btc_1m_data (trigger: interval[0:00:01], next run at: 2022-10-20 10:00:02 BST)" raised an exception
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\apscheduler\executors\base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "C:\Users\djino\Documents\Bot\Trading_Bot_9000\data_acquisition\get_binance_btc_1m.py", line 6, in get_binance_btc_1m_data
from binance.spot import Spot
ModuleNotFoundError: No module named 'binance.spot'
Job "get_binance_btc_3m_data (trigger: interval[0:00:01], next run at: 2022-10-20 10:00:02 BST)" raised an exception
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\apscheduler\executors\base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "C:\Users\djino\Documents\Bot\Trading_Bot_9000\data_acquisition\get_binance_btc_3m.py", line 6, in get_binance_btc_3m_data
from binance.spot import Spot
ModuleNotFoundError: No module named 'binance.spot'</p>
| [
{
"answer_id": 74137205,
"author": "Αpostolos-Valiakos",
"author_id": 16296318,
"author_profile": "https://Stackoverflow.com/users/16296318",
"pm_score": 0,
"selected": false,
"text": "1.Uninstall, Reinstall, Upgrade.\n\npython -m pip uninstall python-binance\n\npython -m pip install pyt... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20057309/"
] |
74,137,161 | <p>Settings.py</p>
<pre><code>DEFAULT_FROM_EMAIL = 'testing.email2908@gmail.com'
SERVER_EMAIL = 'testing.email2908@gmail.com'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'testing.email2908@gmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAILL_USE_TLS = True
</code></pre>
<p>views.py</p>
<pre><code>print('Helloo')
send_mail(
'Testing',
'Hi',
'testing.email2908@gmail.com',
['xyz@gmail.com'], #my personal gmail id
fail_silently=False,
)
print('Hiiii')
</code></pre>
<p>When i run this code, only <code>Helloo</code> is getting printed, I've imported send_mail as well,tried using smtplib as well but that was giving smpt auth extension error so i'm trying send_mail method but it also doesn't seem to work, don't know what is the exact issue.</p>
| [
{
"answer_id": 74137205,
"author": "Αpostolos-Valiakos",
"author_id": 16296318,
"author_profile": "https://Stackoverflow.com/users/16296318",
"pm_score": 0,
"selected": false,
"text": "1.Uninstall, Reinstall, Upgrade.\n\npython -m pip uninstall python-binance\n\npython -m pip install pyt... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17994187/"
] |
74,137,166 | <p>It seems there is no darkmode easily accessible for catboost fitting plot.
The documentation does not seem to contain anything on the subject.</p>
<p>I am running my Jupyter Notebook into VS code and I am using these lines to get dark modes with seaborn and matplotlib:</p>
<pre class="lang-py prettyprint-override"><code>import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="darkgrid", context="talk")
plt.style.use("dark_background")
plt.rcParams.update({"grid.linewidth":0.5, "grid.alpha":0.5})
</code></pre>
<p>I have look briefly at the source code of their widget but couldn't find the attribute that defines the background color.</p>
<pre class="lang-py prettyprint-override"><code>from catboost import CatBoostRegressor, Pool
train_dataset = Pool(X_train,y_train)
test_dataset = Pool(X_test,y_test)
model = CatBoostRegressor()
model.fit(
X=train_dataset,
eval_set=test_dataset,
plot=True
)
</code></pre>
<p>What can I do to have darkplots here?</p>
| [
{
"answer_id": 74325981,
"author": "The Myth",
"author_id": 15042008,
"author_profile": "https://Stackoverflow.com/users/15042008",
"pm_score": 0,
"selected": false,
"text": "catboost"
},
{
"answer_id": 74328655,
"author": "Yohaï-Eliel Berreby",
"author_id": 2754323,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12094184/"
] |
74,137,174 | <p>I don't understand how to read the genre data.</p>
<pre><code>"data":
"genres": [
{
"id": 0,
"type": "string",
"name": "string",
"url": "string"
},
{
"id": 1,
"type": "string",
"name": "string",
"url": "string"
}
],
}
</code></pre>
<p>I want it to end up being displayed like
<code>name1, name2, name3</code>
and (if possible) I want to have each of the names have the link to their corresponding url.</p>
<p>I have tried to find that data by</p>
<pre><code>var genres = data.genres;
</code></pre>
<p>But that just returns <code>[object Object],[object Object]</code>
Im guessing that you have to read the data from those objects, but I don't know how to.</p>
| [
{
"answer_id": 74325981,
"author": "The Myth",
"author_id": 15042008,
"author_profile": "https://Stackoverflow.com/users/15042008",
"pm_score": 0,
"selected": false,
"text": "catboost"
},
{
"answer_id": 74328655,
"author": "Yohaï-Eliel Berreby",
"author_id": 2754323,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19418965/"
] |
74,137,178 | <p>Firstly I understand that there are several ways to do this and I do have some code which runs, but what I just wanted to find out was if anyone else has a recommended way to do this. Say I have a string which I already know that would have contain a specific character (a ‘,’ in this case). Now I just want to validate that this comma is used only once and not more. I know iterating through each character is an option but why go through all that work because I just want to make sure that this special character is not used more than once, I’m not exactly interested in the count per se. The best I could think was to use the split and here is some sample code that works. Just curious to find out if there is a better way to do this.
In summary,
I have a certain string in which I know has a special character (‘,’ in this case)
I want to validate that this special character has only been used once in this string</p>
<pre><code>const char characterToBeEvaluated = ',';
string myStringToBeTested = "HelloWorldLetus,code";
var countOfIdentifiedCharacter = myStringToBeTested.Split(characterToBeEvaluated).Length - 1;
if (countOfIdentifiedCharacter == 1)
{
Console.WriteLine("Used exactly once as expected");
}
else
{
Console.WriteLine("Used either less than or more than once");
}
</code></pre>
| [
{
"answer_id": 74137237,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 3,
"selected": true,
"text": "string"
},
{
"answer_id": 74137678,
"author": "YungDeiza",
"author_id": 19214431,
"autho... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19737975/"
] |
74,137,188 | <p>I am trying to apply a custom function over a group of IDs only when some conditions are met for each column of that group (data should be only numeric and their sum non-zero). Here is the reproducible example:</p>
<pre><code>dat <- as.Date("2021/08/04")
len <- 5
seq(dat, by = "day", length.out = len)
input <- data.frame(
date = c(seq(dat, by = "day", length.out = len) , seq(dat, by = "day", length.out = len)),
id = c("aa", "aa","aa","aa","aa","bb","bb","bb","bb","bb"),
var1 = c(2,3,4,6,7,8,9,3,5,6),
var2 = c(0, 0, 0, 0, 0, 1, 2, 3 ,4, 5),
var3 = c("hi", "hi", "hi", "hi", "hi", 1, 2, 3 ,4, 5)
)
</code></pre>
<p>Here is my custom Rescale function:</p>
<pre><code>rescale = function(x,max_range=100){
return(((x-min(x))/(max(x)-min(x)))*max_range)
}
</code></pre>
<p>And this is the desired output:</p>
<pre><code>output <- data.frame(
date = c(seq(dat, by = "day", length.out = len) , seq(dat, by = "day", length.out = len)),
id = c("aa", "aa","aa","aa","aa","bb","bb","bb","bb","bb"),
var1 = c(0, 20, 40, 80, 100, 83.3, 100, 0, 33.3, 50),
var2 = c(0, 0, 0, 0, 0, 0, 25, 50 ,75, 100),
var3 = c("hi", "hi", "hi", "hi", "hi", 0, 25, 50 ,75, 100)
)
</code></pre>
<p>I am using the following lines to solve this, using dplyr:</p>
<pre><code>out = input %>%
dplyr::group_by(id) %>%
dplyr::mutate_if(~is.numeric(.) && sum(.x) != 0 ,rescale) %>%
dplyr::arrange(date, .by_group = TRUE) %>%
dplyr::ungroup()
</code></pre>
<p>The problem with these lines is that conditions do not refer to the columns of each group exclusively, but to the whole column of the <code>input</code> table. Hence, the function is applied to the whole table-column although the conditions are met only for one ID. In this example function was applied for <code>aa~var2</code> (which is not desired) and wasn't applied for <code>bb~var3</code> (which is desired).</p>
<p>Could you please help me correct the code of <code>out</code> ? Thank you.</p>
| [
{
"answer_id": 74137519,
"author": "onyambu",
"author_id": 8380272,
"author_profile": "https://Stackoverflow.com/users/8380272",
"pm_score": 0,
"selected": false,
"text": " rescale = function(x,max_range=100){\n if(min(x) == max(x)) return(x)\n return(((x-min(x))/(max(x)-min(x)))*... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4035257/"
] |
74,137,189 | <p>I am Trying to implement a <code>ProgressBar</code> in WPF and figured it would be nice to show the percentage as a percentage on the bar itself.</p>
<p>I found out that the <code>ProgressBar</code> conveniently already does calculations for the display in the background. So let's say I have a <strong>max value of 12</strong> and the <strong>current value is 6</strong>, is shows a progress bar which is already <strong>half/50% full</strong>.</p>
<p><a href="https://i.stack.imgur.com/oO0dT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oO0dT.png" alt="ProgessBar that is half filled." /></a></p>
<p>Unfortunately the value of the <code>ProgressBar</code> is still 6 (because it is the sixth element of 12)</p>
<p><a href="https://i.stack.imgur.com/vosZY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vosZY.png" alt="ProgessBar that is half filled with an overlay text that says "6%"." /></a></p>
<p>Is there an easy way to get the percentage value of the progress bar, or do I have to do the calculations on my own and databind a <code>double</code> variable to the <code>TextBox</code> and <code>ProgressBar</code>?</p>
<p>This is the XAML code I have so far:</p>
<pre><code> Title="MainWindow" Height="450" Width="800">
<Grid>
<StackPanel>
<Grid Margin="20">
<ProgressBar Name="ProgrBar" Minimum="0" Maximum="12" Value="6" Height="30"/>
<TextBlock Text="{Binding ElementName=ProgrBar, Path=Value, StringFormat={}{0}% }" HorizontalAlignment="Center"></TextBlock>
</Grid>
</StackPanel>
</Grid>
</Window>
</code></pre>
| [
{
"answer_id": 74137519,
"author": "onyambu",
"author_id": 8380272,
"author_profile": "https://Stackoverflow.com/users/8380272",
"pm_score": 0,
"selected": false,
"text": " rescale = function(x,max_range=100){\n if(min(x) == max(x)) return(x)\n return(((x-min(x))/(max(x)-min(x)))*... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13224253/"
] |
74,137,199 | <p>I'm having an error updating the checkbox when I return to the view containing it; in particular it always returns me the first checked checkbox but not the values selected before the update.</p>
<p>Can anyone help me to solve this problem?</p>
<pre><code><div class="mb-3">
<div for="treatment" class="form-label">All treatments</div>
@foreach ($treatments as $treatment)
<input type="checkbox" id="{{$treatment->title}}" name="treatments[]" value="{{$treatment->id}}" {{ $treatment->id == 1 ? 'checked' : null }}>
<label for="{{$treatment->title}}"> {{$treatment->title}}</label><br>
@endforeach
</div>
</code></pre>
| [
{
"answer_id": 74137263,
"author": "Joseph Lee",
"author_id": 14606226,
"author_profile": "https://Stackoverflow.com/users/14606226",
"pm_score": 1,
"selected": false,
"text": "{{ $treatment->id == 1 ? 'checked' : null }}\n"
},
{
"answer_id": 74137691,
"author": "Sarah",
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19638773/"
] |
74,137,227 | <p>Not able to access the current value of ref inside a setState callback but able to access the current value from the ref outside setState callback.<br><br>
<strong>Reference:</strong><br />
<a href="https://codesandbox.io/s/unruffled-heyrovsky-qndt1t?file=/src/App.js" rel="nofollow noreferrer">Working Example</a></p>
<p><a href="https://codesandbox.io/s/suspicious-wildflower-efjonl?file=/src/App.js" rel="nofollow noreferrer">Not working example</a></p>
| [
{
"answer_id": 74137657,
"author": "Nick Parsons",
"author_id": 5648954,
"author_profile": "https://Stackoverflow.com/users/5648954",
"pm_score": 1,
"selected": false,
"text": "const temp = refObj.current.value; // \"x\" on the first call, `\"\"` on the second run\nrefObj.current.value =... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16197368/"
] |
74,137,247 | <p>I am using Unity AudioSource. It is easy to get and change the volume by accessing <code>AudioSource.volume</code> as explained here <a href="https://docs.unity3d.com/ScriptReference/AudioSource-volume.html" rel="nofollow noreferrer">https://docs.unity3d.com/ScriptReference/AudioSource-volume.html</a>.</p>
<p>How do I detect the volume change? Is there any callback or event that I can use?</p>
| [
{
"answer_id": 74137657,
"author": "Nick Parsons",
"author_id": 5648954,
"author_profile": "https://Stackoverflow.com/users/5648954",
"pm_score": 1,
"selected": false,
"text": "const temp = refObj.current.value; // \"x\" on the first call, `\"\"` on the second run\nrefObj.current.value =... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4524241/"
] |
74,137,272 | <p>I am trying to add manually row (one by one) from one dataframe to the another:</p>
<pre><code>path = "...csv"
data = pd.read_csv(path, na_values='NULL')
path2 = "...csv"
data2 = pd.read_csv(path2, na_values='NULL')
for row in data2.itertuples():
x = input("Do you want to add the row, please write Yes or No")
if x=='Yes':
data = data.append(row)
print(data.shape)
else:
pass
</code></pre>
<p>Shape of those dataframes are: (1674, 83) (1727, 83). When I run this code I receive this error:</p>
<blockquote>
<p>TypeError: cannot concatenate object of type '<class 'int'>'; only Series and DataFrame objs are valid</p>
</blockquote>
<p>Any ideas how to fix it? Can't find a good solution for it.</p>
<p>Thanks for your help and cheers!</p>
| [
{
"answer_id": 74137657,
"author": "Nick Parsons",
"author_id": 5648954,
"author_profile": "https://Stackoverflow.com/users/5648954",
"pm_score": 1,
"selected": false,
"text": "const temp = refObj.current.value; // \"x\" on the first call, `\"\"` on the second run\nrefObj.current.value =... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15029172/"
] |
74,137,284 | <p>I use InteractiveViewer inside the SingleChildScrollView, this is my full code:</p>
<pre><code>import 'package:flutter/material.dart';
import '../constants/images.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final List<String> images = [Images.IMG1, Images.IMG2, Images.IMG3];
MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
for (var image in images) ...[
SizedBox(width:double.infinity,child: Divider(thickness: 5,)),
Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: ClipOval(
child: CircleAvatar(
radius: 24,
child: Image.asset(Images.PROFILE_IMAGE),
),
),
),
Text('User1'),
],
),
InteractiveViewer(
child: Image.asset(
image,
fit: BoxFit.fitWidth,
)),
Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.favorite),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.comment),
),
],
)
]
],
),
),
),
);
}
}
</code></pre>
<p>The problem is when I try to zoom-in or zoom-out my InteractiveViewer, it usually not works in first try, and I need to try 5-6 times in different touch positions to work, it is very hard to use InteractiveViewer in SingleChildScrollView, but it works perfect without SingleChildScrollView, see the clip below:</p>
<p><a href="https://i.stack.imgur.com/JpC9e.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JpC9e.gif" alt="enter image description here" /></a></p>
<p>Is there any solutions?</p>
| [
{
"answer_id": 74163727,
"author": "samad karimi",
"author_id": 14083299,
"author_profile": "https://Stackoverflow.com/users/14083299",
"pm_score": 2,
"selected": true,
"text": "SingleChildScrollView"
},
{
"answer_id": 74170388,
"author": "amir_a14",
"author_id": 10281719... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10281719/"
] |
74,137,290 | <p>I have uploaded Django app on azure server web app using Zip Deploy with FTP. After deploying it gives error that "<strong>sndlibrary not found</strong>" so i need to go to ssh and install it manually by using command <code>apt update && apt-get -y install libsndfile1-dev</code>.So The problem is that whenever the app(container) gets restarted it again shows the same error and i again need to install the package from ssh.The package does not persist on restart.So is there any way to persist the package on app restart?</p>
<p>I have also tried using startup.sh script on the wwwroot path but when run it shows error that "<strong>could not locate the package</strong>".</p>
<p><strong>startup.sh :</strong>
<a href="https://i.stack.imgur.com/8jSf6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8jSf6.png" alt="Startup File" /></a></p>
<p><strong>Getting This Error :</strong>
<a href="https://i.stack.imgur.com/KhKWt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KhKWt.png" alt="Error Could not locate package" /></a></p>
| [
{
"answer_id": 74163727,
"author": "samad karimi",
"author_id": 14083299,
"author_profile": "https://Stackoverflow.com/users/14083299",
"pm_score": 2,
"selected": true,
"text": "SingleChildScrollView"
},
{
"answer_id": 74170388,
"author": "amir_a14",
"author_id": 10281719... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20289936/"
] |
74,137,304 | <p>I'm trying to sort an array into multiple arrays by their starting letter</p>
<p>this is an example</p>
<pre><code>list1 = ["apple", "banana", "carrot", "avocado"]
</code></pre>
<p>into this</p>
<pre><code>a = ["apple", "avocado"]
b = ["banana"]
c = ["carrot"]
</code></pre>
| [
{
"answer_id": 74137386,
"author": "Rabinzel",
"author_id": 15521392,
"author_profile": "https://Stackoverflow.com/users/15521392",
"pm_score": 2,
"selected": false,
"text": "dic = {}\nfor elem in list1:\n dic.setdefault(elem[0], []).append(elem)\n\nprint(dic)\n"
},
{
"answer_... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17277982/"
] |
74,137,352 | <p>I am reading about dropbox's Async. Task Framework and its architecture from dropbox tech blog: <a href="https://dropbox.tech/infrastructure/asynchronous-task-scheduling-at-dropbox" rel="nofollow noreferrer">https://dropbox.tech/infrastructure/asynchronous-task-scheduling-at-dropbox</a></p>
<p>The architecture seems to be clear to me but what I can't understand is how the callbacks (or lambda in their terminology) can be stored in the database for later execution? Because they are just normal programming language functions right? Or am I missing something here?</p>
<p>Also,</p>
<blockquote>
<p>It would need to support nearly 100 unique async task types from the start, again with room to grow.</p>
</blockquote>
<p>It seems that here they are talking about types of lambda here. But how that is even possible when the user can provide arbitrary code in the callback function?</p>
<p>Any help would be appreciated. Thanks!</p>
| [
{
"answer_id": 74137386,
"author": "Rabinzel",
"author_id": 15521392,
"author_profile": "https://Stackoverflow.com/users/15521392",
"pm_score": 2,
"selected": false,
"text": "dic = {}\nfor elem in list1:\n dic.setdefault(elem[0], []).append(elem)\n\nprint(dic)\n"
},
{
"answer_... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5353128/"
] |
74,137,354 | <p>Imagine a string like this:</p>
<p><code>#*****~~~~~~**************~~~~~~~~***************************#</code></p>
<p>I am looking for an elegant way to find the indices of the longest continues section that contains a specific character. Let's assume we are searching for the <code>*</code> character, then I expect the method to return the start and end index of the last long section of <code>*</code>.</p>
<p>I am looking for the elegant way, I know I could just bruteforce this by checking something like</p>
<pre><code>indexOf(*)
lastIndexOf(*)
//Check if in between the indices is something else if so, remember length start from new
//substring and repeat until lastIndex reached
//Return saved indices
</code></pre>
<p>This is so ugly brute-force - Any more elegant way of doing this? I thought about regular expression groups and comparing their length. But how to get the indices with that?</p>
| [
{
"answer_id": 74137522,
"author": "Abra",
"author_id": 2164365,
"author_profile": "https://Stackoverflow.com/users/2164365",
"pm_score": 2,
"selected": false,
"text": "Matcher"
},
{
"answer_id": 74138138,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
"auth... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20059818/"
] |
74,137,370 | <p>Here's the code i did:</p>
<pre class="lang-py prettyprint-override"><code>list = input("Enter the number: ")
p = print("Trailing zeroes = ")
print(p, list.count("0"))
</code></pre>
<p>Output:</p>
<pre><code>Enter the number: 10000
Trailing zeroes =
None 4
</code></pre>
<p>The output i wanted:</p>
<pre><code>Enter the number: 10000
Trailing zeroes = 4
</code></pre>
| [
{
"answer_id": 74137403,
"author": "Claudio Paladini",
"author_id": 8187191,
"author_profile": "https://Stackoverflow.com/users/8187191",
"pm_score": 0,
"selected": false,
"text": "i = input(\"Enter the number: \")\n\np = \"Trailing zeroes = \" + str(i.count(\"0\"))\n\nprint(p)\n"
},
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20290006/"
] |
74,137,405 | <p>I'm trying to reshape a data frame in a certain way.</p>
<p>This is the data frame I have,</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>col_1</th>
<th>col_2</th>
</tr>
</thead>
<tbody>
<tr>
<td>One</td>
<td><em>Roxanne</em></td>
</tr>
<tr>
<td>Two</td>
<td><em>Ghina</em></td>
</tr>
<tr>
<td><em>Roxanne</em></td>
<td><em>Leila</em></td>
</tr>
<tr>
<td><em>Ghina</em></td>
<td><em>George</em></td>
</tr>
<tr>
<td>Three</td>
<td><em>Rock</em></td>
</tr>
<tr>
<td>Four</td>
<td><em>Rock</em></td>
</tr>
</tbody>
</table>
</div>
<p>I'd like to reshape the dataframe such that it looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>col_3</th>
</tr>
</thead>
<tbody>
<tr>
<td><em>Roxanne</em></td>
</tr>
<tr>
<td><em>Ghina</em></td>
</tr>
<tr>
<td><em>Leila</em></td>
</tr>
<tr>
<td><em>George</em></td>
</tr>
<tr>
<td><em>Rock</em></td>
</tr>
<tr>
<td><em>Rock</em></td>
</tr>
<tr>
<td>One</td>
</tr>
<tr>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
</tr>
<tr>
<td>Four</td>
</tr>
</tbody>
</table>
</div>
<p>How would I go about doing this? <em>(without changing col_2 values)</em></p>
| [
{
"answer_id": 74137403,
"author": "Claudio Paladini",
"author_id": 8187191,
"author_profile": "https://Stackoverflow.com/users/8187191",
"pm_score": 0,
"selected": false,
"text": "i = input(\"Enter the number: \")\n\np = \"Trailing zeroes = \" + str(i.count(\"0\"))\n\nprint(p)\n"
},
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18641543/"
] |
74,137,427 | <p>I am getting data in this format how to fetch it and use in UI?
Currently i know to ways of fetching data by using snapshot and another one is by storing whole response object is list of array and then fetching data by its key name but there is no key-value pair format in this.So how to fetch data?</p>
<pre class="lang-json prettyprint-override"><code>[["2022-10-20","baner","03:15:00","no",3000,"Online",147,338,"Owner","Open","8993333333","12000","Adhiraj Nivas ",22019991811063,"pune","Sumitra","Vaishanvi"],["2022-10-19","baner","03:15:00","no",13000,"Online",161,327,"Owner","Open","7652222222","30000","Yashoda Recidency",22100199963254,"pune","sonali Jadhav","Satish"]]
</code></pre>
| [
{
"answer_id": 74137543,
"author": "MindStudio",
"author_id": 13406356,
"author_profile": "https://Stackoverflow.com/users/13406356",
"pm_score": -1,
"selected": false,
"text": "List<dynamic>"
},
{
"answer_id": 74138014,
"author": "GrahamD",
"author_id": 10376604,
"au... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19363047/"
] |
74,137,458 | <p>I have a form build in html (first name, name, email... and a city should be choosen).
With javascript, i want to change the css and make appears a message which says (in french) "please choose a city".
I cannot access to the parent "class = "formData" in order to apply the style build in css. So, my function cannot work for the moment.
i want to target "formData" using " const parent3 = document.getElementsByName("location").parentNode;", it returns me in the console.log "undefined 'parent'" instead of returning me "*
Nom<br>
<br></p>
<pre><code> </div>*" like for the previous field of the form.
</code></pre>
<p>Thank you for your help.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function validateRadio() {
const checkradio = document.querySelector("input[name='location']:checked");
const parent3 = document.getElementsByName("location").parentNode;
console.log(parent3, "parent")
if (checkradio == null){
city.focus();
parent.setAttribute("data-error", "Veuillez choisir une ville");
parent.setAttribute("data-error-visible", "true");
} else {
parent.setAttribute("data-error-visible", "false");
}</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.formData[data-error]::after {
content: attr(data-error);
font-size: 0.4em;
color: #e54858;
display: block;
margin-top: 7px;
margin-bottom: 7px;
text-align: right;
line-height: 0.3;
opacity: 0;
transition: 0.3s;
}
.formData[data-error-visible="true"]::after {
opacity: 1;
}
.formData[data-error-visible="true"] .text-control {
border: 2px solid #e54858;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div
class="formData">
<input
class="checkbox-input"
type="radio"
id="location1"
name="location"
value="New York"
/>
<label class="checkbox-label" for="location1">
<span class="checkbox-icon"></span>
New York</label
>
<input
class="checkbox-input"
type="radio"
id="location2"
name="location"
value="San Francisco"
/>
<label class="checkbox-label" for="location2">
<span class="checkbox-icon"></span>
San Francisco</label
>
<input
class="checkbox-input"
type="radio"
id="location3"
name="location"
value="Seattle"
/>
<label class="checkbox-label" for="location3">
<span class="checkbox-icon"></span>
Seattle</label
>
<input
class="checkbox-input"
type="radio"
id="location4"
name="location"
value="Chicago"
/>
<label class="checkbox-label" for="location4">
<span class="checkbox-icon"></span>
Chicago</label
>
<input
class="checkbox-input"
type="radio"
id="location5"
name="location"
value="Boston"
/>
<label class="checkbox-label" for="location5">
<span class="checkbox-icon"></span>
Boston</label
>
<input
class="checkbox-input"
type="radio"
id="location6"
name="location"
value="Portland"
/>
<label class="checkbox-label" for="location6">
<span class="checkbox-icon"></span>
Portland</label
>
<br><small></small>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74137543,
"author": "MindStudio",
"author_id": 13406356,
"author_profile": "https://Stackoverflow.com/users/13406356",
"pm_score": -1,
"selected": false,
"text": "List<dynamic>"
},
{
"answer_id": 74138014,
"author": "GrahamD",
"author_id": 10376604,
"au... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18373990/"
] |
74,137,484 | <p>I would like to make my window pane unscrollable. If I set my element to overflow: hidden, I can not scroll on any page, so I tried to do it in the CSS file of the component which I want unscrollable. However, the only way I managed achieve this was adding the unscrollable class name to the element of index.html.</p>
<pre><code>.unscrollable{
overflow: hidden;
}
</code></pre>
<p>However, in that case, all windows are unscrollable wherever I navigate on the page.</p>
<p>I tried to solve the problem by adding the following only to the component's CSS file:</p>
<pre><code>.unscrollable{
overflow: hidden !important;
}
</code></pre>
<p>but to no avail.</p>
<p>Does anyone have an idea on how to solve it? I am very confused by not being able to influence index.html depending on the component, especially since the tag is there.</p>
| [
{
"answer_id": 74137583,
"author": "saravana priyan",
"author_id": 4036999,
"author_profile": "https://Stackoverflow.com/users/4036999",
"pm_score": 0,
"selected": false,
"text": ".unscrollable{\n width:100vw;\n height:100vh;\n overflow:hidden;\n}\n"
},
{
"answer_id": 74137927... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282334/"
] |
74,137,504 | <p>I am having issues with using each loop for lists in cypress.</p>
<p>Website code:</p>
<pre class="lang-html prettyprint-override"><code><ul class="list" id="my-list">
<li>
<a class="btn-modal"> Text 1</a>
</li>
<li>
<a class="btn-modal">Text 2 </a>
</li>
<li>
<a class="btn-modal">Text 3 </a>
</li>
</ul>
</code></pre>
<p>My test goes like this:</p>
<pre class="lang-js prettyprint-override"><code>cy.get('[class="list"]')
.find("li")
.each((format, i = 0) => {
const formats = ["Text1", "Text2", "Text3"];
cy.wrap(format).should("contain", formats[i]);
i++;
});
</code></pre>
<p>However, it only works for the first item on the list.
I did have a workaround though:</p>
<pre class="lang-js prettyprint-override"><code>cy.get('[class="list"]')
.find("li")
.each((format, i = 0) => {
const formats = ["Text1", "Text1", "Text2", "Text3"];
cy.wrap(format).should("contain", formats[i]);
i++;
});
</code></pre>
| [
{
"answer_id": 74137583,
"author": "saravana priyan",
"author_id": 4036999,
"author_profile": "https://Stackoverflow.com/users/4036999",
"pm_score": 0,
"selected": false,
"text": ".unscrollable{\n width:100vw;\n height:100vh;\n overflow:hidden;\n}\n"
},
{
"answer_id": 74137927... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13404946/"
] |
74,137,511 | <p>I am working on a tutorial of PyTorch Lightning.</p>
<p><a href="https://pytorch-lightning.readthedocs.io/en/stable/starter/introduction.html" rel="nofollow noreferrer">https://pytorch-lightning.readthedocs.io/en/stable/starter/introduction.html</a></p>
<p>Because I wanted to try GPU training, I changed definition of <code>trainer</code> as below.</p>
<pre><code>trainer = pl.Trainer(limit_train_batches=100, max_epochs=1, gpus=1)
</code></pre>
<p>Then I got the following error.</p>
<pre><code>RuntimeError Traceback (most recent call last)
Cell In [3], line 4
1 # train the model (hint: here are some helpful Trainer arguments for rapid idea iteration)
2 # trainer = pl.Trainer(limit_train_batches=100, max_epochs=3)
3 trainer = pl.Trainer(limit_train_batches=100, max_epochs=3, accelerator='gpu', devices=1)
----> 4 trainer.fit(model=autoencoder, train_dataloaders=train_loader)
File ~/miniconda3/envs/py38-cu116/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py:696, in Trainer.fit(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
677 r"""
678 Runs the full optimization routine.
679
(...)
693 datamodule: An instance of :class:`~pytorch_lightning.core.datamodule.LightningDataModule`.
694 """
695 self.strategy.model = model
--> 696 self._call_and_handle_interrupt(
697 self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path
698 )
File ~/miniconda3/envs/py38-cu116/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py:650, in Trainer._call_and_handle_interrupt(self, trainer_fn, *args, **kwargs)
648 return self.strategy.launcher.launch(trainer_fn, *args, trainer=self, **kwargs)
649 else:
--> 650 return trainer_fn(*args, **kwargs)
651 # TODO(awaelchli): Unify both exceptions below, where `KeyboardError` doesn't re-raise
652 except KeyboardInterrupt as exception:
[...]
File ~/miniconda3/envs/py38-cu116/lib/python3.8/site-packages/pytorch_lightning/core/module.py:1450, in LightningModule.backward(self, loss, optimizer, optimizer_idx, *args, **kwargs)
1433 def backward(
1434 self, loss: Tensor, optimizer: Optional[Optimizer], optimizer_idx: Optional[int], *args, **kwargs
1435 ) -> None:
1436 """Called to perform backward on the loss returned in :meth:`training_step`. Override this hook with your
1437 own implementation if you need to.
1438
(...)
1448 loss.backward()
1449 """
-> 1450 loss.backward(*args, **kwargs)
File ~/miniconda3/envs/py38-cu116/lib/python3.8/site-packages/torch/_tensor.py:396, in Tensor.backward(self, gradient, retain_graph, create_graph, inputs)
387 if has_torch_function_unary(self):
388 return handle_torch_function(
389 Tensor.backward,
390 (self,),
(...)
394 create_graph=create_graph,
395 inputs=inputs)
--> 396 torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
File ~/miniconda3/envs/py38-cu116/lib/python3.8/site-packages/torch/autograd/__init__.py:173, in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables, inputs)
168 retain_graph = create_graph
170 # The reason we repeat same the comment below is that
171 # some Python versions print out the first line of a multi-line function
172 # calls in the traceback and some print out the last line
--> 173 Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
174 tensors, grad_tensors_, retain_graph, create_graph, inputs,
175 allow_unreachable=True, accumulate_grad=True)
RuntimeError: CUDA error: CUBLAS_STATUS_INVALID_VALUE when calling `cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)`
</code></pre>
<p>The only thing I added to the tutorial code is <code>gpus=1</code>, so I cannot figure out what is the problem. How can I fix this?</p>
<p>FYI, I tried giving <code>devices=1, accelerator='ddp'</code> instead of <code>gpus=1</code>, and got a following error.</p>
<pre><code>ValueError: You selected an invalid accelerator name: `accelerator='ddp'`. Available names are: cpu, cuda, hpu, ipu, mps, tpu.
</code></pre>
<p>My environments are:</p>
<ul>
<li>CUDA 11.6</li>
<li>Python 3.8.13</li>
<li>PyTorch 1.12.1</li>
<li>PyTorch Lightning 1.7.7</li>
</ul>
| [
{
"answer_id": 74141077,
"author": "razzberry",
"author_id": 7956710,
"author_profile": "https://Stackoverflow.com/users/7956710",
"pm_score": 2,
"selected": false,
"text": "trainer = pl.Trainer(\n accelerator=\"GPU\", \n devices=[0], \n strategy=\"ddp\"\n)\n"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12784883/"
] |
74,137,523 | <p>I have a variable that stores current time with <code>$current_time</code> and another variable with an array of time stored in <code>$time_slot</code> I am looking for a way around to unset from array variable <code>$time_slot</code> all array of time that is less than the <code>$current_time</code> I tried below code but it didn't work:</p>
<pre><code>$current_time = '4:00';
$time_slot = ['1:00','3:00','15:00','19:00'];
// removing the deleted value from array
if (($key = array_search($current_time, $time_slot)) !== false) {
if($current_time>$time_slot){
unset($time_slot[$key]);
}
}
print_r($time_slot);
</code></pre>
| [
{
"answer_id": 74137569,
"author": "DarkBee",
"author_id": 446594,
"author_profile": "https://Stackoverflow.com/users/446594",
"pm_score": 3,
"selected": true,
"text": "DateTime"
},
{
"answer_id": 74138865,
"author": "mickmackusa",
"author_id": 2943403,
"author_profil... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20230706/"
] |
74,137,537 | <p>I'm trying to figure out why the 2 rows are so far apart, since there is no additional height on the inner tables. Inspecting the height in Chrome shows that the topmost TD has 50px, while the table underneath is 24px.</p>
<p>Why is this the case?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><table width="540px" height="94px" style="background-color: #fafbfc;">
<tbody>
<tr>
<td style="padding:0 0 0 55px;vertical-align:middle;">
<table style="border-collapse:separate;">
<tbody>
<tr>
<td>
<span style="display:block;padding:0px 15px;">First field</span>
</td>
<td>
<span style="text-decoration:none;display:block;padding:0px 15px;">Second field</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="padding:0 55px 0 55px; vertical-align:middle;">
another
</td>
</tr>
</tbody>
</table></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74137735,
"author": "Waleed Iqbal",
"author_id": 4758651,
"author_profile": "https://Stackoverflow.com/users/4758651",
"pm_score": 0,
"selected": false,
"text": "cellpadding"
},
{
"answer_id": 74137859,
"author": "Harrison",
"author_id": 15291770,
"auth... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/673760/"
] |
74,137,540 | <p>I'm trying to extract data from trust advisor through lambda function and upload to s3. Some part of the function executes the append module on the data. However, that module block throws error. That specific block is</p>
<pre><code>try:
check_summary = support_client.describe_trusted_advisor_check_summaries(
checkIds=[checks['id']])['summaries'][0]
if check_summary['status'] != 'not_available':
checks_list[checks['category']].append(
[checks['name'], check_summary['status'],
str(check_summary['resourcesSummary']['resourcesProcessed']),
str(check_summary['resourcesSummary']['resourcesFlagged']),
str(check_summary['resourcesSummary']['resourcesSuppressed']),
str(check_summary['resourcesSummary']['resourcesIgnored'])
])
else:
print("unable to append checks")
except:
print('Failed to get check: ' + checks['name'])
traceback.print_exc()
</code></pre>
<p>The error logs</p>
<pre><code>unable to append checks
</code></pre>
<p>I'm new to Python. So, unsure of how to check for trackback stacks under else: statement. Also, am I doing anything wrong in the above ? Plz help</p>
| [
{
"answer_id": 74140466,
"author": "Shai Katz",
"author_id": 1609014,
"author_profile": "https://Stackoverflow.com/users/1609014",
"pm_score": 1,
"selected": false,
"text": "s3_upload"
},
{
"answer_id": 74140542,
"author": "Rishitosh Guha",
"author_id": 19951115,
"aut... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,137,578 | <p>I have two tables that I need to link together but the output needs to consider switching to the second-best alternative in instance that the best recommended product is out of stock.</p>
<p>Here's the first table, which keeps the record of the chemical stock:</p>
<p><a href="https://i.stack.imgur.com/2EVSS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2EVSS.png" alt="Chemical Stock" /></a></p>
<p>Then here's the second table which contains the trial scheme and outlined the best chemical fit, second-best, and third-best alternative for each sample:</p>
<p><a href="https://i.stack.imgur.com/g9Zd4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g9Zd4.png" alt="Trial Scheme" /></a></p>
<p>And finally, here's the desired output which will recommend product application based on availability of stock in each bottle.</p>
<p><a href="https://i.stack.imgur.com/bbMME.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bbMME.png" alt="Recommendation List" /></a></p>
<p>The record highlighted in red is just to show where the recommendation needs to switch to second-best alternative because we ran out of stock in Product A.</p>
<p>Any help or input would be appreciated. Thanks in advance.</p>
| [
{
"answer_id": 74140466,
"author": "Shai Katz",
"author_id": 1609014,
"author_profile": "https://Stackoverflow.com/users/1609014",
"pm_score": 1,
"selected": false,
"text": "s3_upload"
},
{
"answer_id": 74140542,
"author": "Rishitosh Guha",
"author_id": 19951115,
"aut... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2918455/"
] |
74,137,619 | <p>Given a dictionary</p>
<pre><code>{4: {'idx': [45, 177, 181],
'Baggage': array([ 13, 103, 87]),
'infeed_idx': array([1, 3, 3])},
7: {'idx': [62, 105, 173, 174, 186, 57, 74, 102, 115, 164],
'Baggage': array([12, 27, 50, 51, 16, 30, 15, 59, 16, 8]),
'infeed_idx': array([1, 1, 1, 1, 1, 2, 2, 2, 2, 2])},
</code></pre>
<p>I would like to create a tuple of idx and infeed_idx (45,1), (177,3).</p>
<p>Expected output</p>
<pre><code>{4: {'idx': [45, 177, 181],
'Baggage': array([ 13, 103, 87]),
'infeed_idx': array([1, 3, 3])},
'tuple_id': [(45,1),(177,3),(177,3)]
7: {'idx': [62, 105, 173, 174, 186, 57, 74, 102, 115, 164],
'Baggage': array([12, 27, 50, 51, 16, 30, 15, 59, 16, 8]),
'infeed_idx': array([1, 1, 1, 1, 1, 2, 2, 2, 2, 2])},
'tuple_id': [(62,1),(105,1),(173,1),(174,1),(186,1),(57,2),(74,2),(102,2),(115,2),(164,2)]
</code></pre>
<p>I hope you guys can help!</p>
| [
{
"answer_id": 74137703,
"author": "veekxt",
"author_id": 5417267,
"author_profile": "https://Stackoverflow.com/users/5417267",
"pm_score": 0,
"selected": false,
"text": "zip"
},
{
"answer_id": 74137728,
"author": "assume_irrational_is_rational",
"author_id": 11622508,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10571326/"
] |
74,137,621 | <p><br>How can I calculate the number of occurences of the second value e.g.:'Rv1408' ? i want to get and calculate the total number of occurrences of the 2nd element in each line.<.br></p>
<p>file.txt:</p>
<pre><code>Rv0729,Rv1408,Rv1408
Rv0162c,Rv0761,Rv1862,Rv3086
Rv2790c,Rv1408
Rv2fd90c,Rv1408
Rv1862,Rv3086
Rvsf62,Rv3086
</code></pre>
<p>i tried(doesnt work)
input:</p>
<pre><code>awk ' { tot[$0]++ } END { for (i in tot) print tot[i],i } ' m.txt | sort | cut --delimiter=',' --fields=1
</code></pre>
<p>Expected Output:</p>
<pre><code>total no of occurences:
Rv1408: 3
Rv0761:1
Rv3086: 2
</code></pre>
<p>idk why i cannot get the second element even if i type fields=2</p>
| [
{
"answer_id": 74138291,
"author": "Serve Laurijssen",
"author_id": 1866300,
"author_profile": "https://Stackoverflow.com/users/1866300",
"pm_score": 2,
"selected": true,
"text": "awk -F, '{map[$2]++} END { for (key in map) { print key, map[key] } }' file.txt\n"
},
{
"answer_id":... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20121597/"
] |
74,137,625 | <p>This sounds like a duplicate question but I've tried solutions from those questions. I'm still facing the issue. I've a boolean variable in the global space and I'm trying to set the value inside a method which is called after a POST request.</p>
<p><strong>TS</strong></p>
<pre><code>import ...;
@Component({
...
})
export class FileUploadComponent implements OnInit {
constructor(
private http: HttpClient,
...
) {}
ngOnInit(): void {}
hasError: boolean = false; // <----------- this is the variable
public dropped() {
...
this.http
.post(
'http://localhost:8090/.../file-process/upload',
formData,
{ headers: headers, responseType: 'json' }
)
.pipe(catchError(this.handleError)) // <------- control will go here
.subscribe((res: any) => {
console.log('checking', res);
});
});
} else {
...
}
}
}
private handleError(error: HttpErrorResponse) {
this.hasError = true; // <--- Error: ERROR TypeError: Cannot set properties of undefined (setting 'hasError')
}
}
</code></pre>
<p>But I'm getting this error:
<a href="https://i.stack.imgur.com/E4Hqy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E4Hqy.png" alt="enter image description here" /></a></p>
<p>After fixing this line:
<code>.pipe(catchError(this.handleError.bind(this)))</code></p>
<p>I'm getting this:
<a href="https://i.stack.imgur.com/UEAzr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UEAzr.png" alt="enter image description here" /></a></p>
<p>Please pitch in.</p>
| [
{
"answer_id": 74137867,
"author": "Garuno",
"author_id": 5625089,
"author_profile": "https://Stackoverflow.com/users/5625089",
"pm_score": 1,
"selected": false,
"text": ".pipe(catchError(err => this.handleError(err)))\n"
},
{
"answer_id": 74137979,
"author": "Vishnu Vinod",
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11163977/"
] |
74,137,637 | <p>Here is the reference code <a href="https://stackblitz.com/edit/angular-mat-table-pagination-example?file=src%2Fapp%2Fsimple-mat-table%2Fsimple-mat-table.component.html" rel="nofollow noreferrer">URL</a></p>
<p>so I have using the above code in my component.... but in my comonent table is inside ngcontainer which gets visible once some flag(e.g. visibleTabulardata) is set to true</p>
<pre><code><ng-container *ngIf='visibleTabulardata'> <!-- this gets visible after some specific condition
inside this table and mat-paginator code is used from the above URL
</ng-container>
</code></pre>
<p>Now they have used below code to initialize data across pages</p>
<pre><code> @ViewChild('paginator') paginator: MatPaginator;
@ViewChild('paginatorPageSize') paginatorPageSize: MatPaginator;
pageSizes = [3, 5, 7];
ngAfterViewInit() {
this.dataSource.paginator = this.paginator;
this.dataSourceWithPageSize.paginator = this.paginatorPageSize;
}
</code></pre>
<p>So and in my ts file one method is there which sets visibleTabulardata as true</p>
<pre><code>enableTableData(){
this.visibleTabulardata =true;
}
</code></pre>
<p>I tried calling ngAfterViewInit() nside enableTableData() but it is not working</p>
| [
{
"answer_id": 74137729,
"author": "Muhammad Ahsan",
"author_id": 11420134,
"author_profile": "https://Stackoverflow.com/users/11420134",
"pm_score": 0,
"selected": false,
"text": "initPaginator(){\n this.dataSource.paginator = this.paginator;\n this.dataSourceWithPageSize.paginator = th... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14794223/"
] |
74,137,644 | <p>Im very new to SQL and I wanted to know if I am able to place a comparison operator in the select portion</p>
<p>ex</p>
<pre><code>Select
(value> value1, "True","False") as Comparison
From Table
</code></pre>
| [
{
"answer_id": 74137708,
"author": "Saeed Esmaeelinejad",
"author_id": 6023173,
"author_profile": "https://Stackoverflow.com/users/6023173",
"pm_score": 1,
"selected": false,
"text": "IIF"
},
{
"answer_id": 74139656,
"author": "d r",
"author_id": 19023353,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20290292/"
] |
74,137,645 | <p>I want to create a pipe using enum values to show me text colors depending on the status.
this is my enum class :</p>
<pre><code>export enum Status {
Active = 'Active',
None = 'None',
Processing = 'Processing',
Expiring ='Expiring'
}
</code></pre>
<p>AndIi was doing this using ngClass, depending on the status the color of text changes, this what I have done :</p>
<pre><code><div class="font-bold" [ngClass]="{activeClass: item.license=='Active',
reviewClass: item.license=='None'}">
{{item.license}}</div></div>
</code></pre>
<p>active and review are two css classes :</p>
<pre><code>.activeClass {
color: #32CD32;
}
.reviewClass {
color: #CD7F32;
}
</code></pre>
| [
{
"answer_id": 74137991,
"author": "Jovana",
"author_id": 11365465,
"author_profile": "https://Stackoverflow.com/users/11365465",
"pm_score": 1,
"selected": true,
"text": "status = Status;\n"
},
{
"answer_id": 74138255,
"author": "MoxxiManagarm",
"author_id": 11011793,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19749902/"
] |
74,137,675 | <p>I have foreach</p>
<pre><code>@foreach (var produkt in ViewBag.OnePageOfProducts){
<button id="submitButton" value="@produkt.ProductId">Add to Cart</button>
}
</code></pre>
<p>and call method jquery ajax</p>
<pre><code> <script>
$(document).ready(function () {
var id
var quantity = 1;
$('#submitButton').click(
/*error dont work read value from button id */
var id = $('#submitButton').attr('value'); /*I dont know how to read difrent id for any product*/
function () {
$.ajax({
type: "POST",
url: '@Url.Action("AddToCart2", "Cart")',
data: { id: id, quantity: quantity },
success: function (result) {
$("#mydiv").load(location.href + " #mydiv");
},
error: function (abc) {
alert(abc.statusText);
},
});
})
})
</script>
</code></pre>
<p>I dont know how to read diffrent #submitbutton for one to product becouse read only one first element.</p>
<p><strong>var id = $('#submitButton').attr('value');</strong> is only one but I have for example 20 elelements, have i can read difrent element id for @foreach (var produkt in ViewBag.OnePageOfProducts)</p>
<p>Any idea?</p>
| [
{
"answer_id": 74137991,
"author": "Jovana",
"author_id": 11365465,
"author_profile": "https://Stackoverflow.com/users/11365465",
"pm_score": 1,
"selected": true,
"text": "status = Status;\n"
},
{
"answer_id": 74138255,
"author": "MoxxiManagarm",
"author_id": 11011793,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13780778/"
] |
74,137,681 | <p>The following code works fine on localhost. It's just that Vercel's CI/CD throws this error in compilation</p>
<pre><code>Error occurred prerendering page "/billing/CheckoutForm". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Could not find Elements context; You need to wrap the part of your app that calls useStripe() in an <Elements> provider.
</code></pre>
<p>As <a href="https://stackoverflow.com/questions/64865267/stripe-react-wrapping-root-application-with-elements-provider">this other Stack Overflow question suggests</a>, I need to wrap the whole CheckoutComponent inside the Element component, which I am already doing. Like this:</p>
<p>index.js</p>
<pre><code><Elements stripe={stripePromise} options={options}>
<CheckoutForm />
</Elements>
</code></pre>
<p>CheckoutForm.js</p>
<pre><code> const stripe = useStripe();
const elements = useElements();
</code></pre>
<p>I also tried wrapping the ancestors of CheckoutForm with the Elements component, but it doesn't solve the problem and it also messes up the behavior</p>
<p>This is how my entire CheckoutForm file looks like. Very standard to the Stripe docs</p>
<pre><code>const CheckoutForm = () => {
const stripe = useStripe();
const elements = useElements();
const [errorMessage, setErrorMessage] = useState(null);
const handleSubmit = async (event) => {
// We don't want to let default form submission happen here,
// which would refresh the page.
event.preventDefault();
const { error } = await stripe.confirmPayment({
//`Elements` instance that was used to create the Payment Element
elements,
confirmParams: {
return_url: "https://example.com/order/123/complete",
},
});
if (error) {
// This point will only be reached if there is an immediate error when
// confirming the payment. Show error to your customer (for example, payment
// details incomplete)
setErrorMessage(error.message);
}
};
return (
<form onSubmit={handleSubmit}>
<PaymentElement />
<br />
<div className="d-flex flex-items-center flex-justify-center">
<button className="btn btn-primary" id="checkout-and-portal-button" type="submit" disabled={!stripe}>
Purchase
</button>
</div>
{errorMessage && <div>{errorMessage}</div>}
</form>
);
};
export default CheckoutForm;
</code></pre>
<p>And this is how the return statement of my index.js file looks like. Perhaps the only "weird thing" I'm doing is the conditional rendering of Elements based on the retrieval of the client secret</p>
<pre><code> return (
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(350px, 1fr))",
}}
>
<div className="d-flex flex-items-center flex-justify-center flex-column">
<div
className="Box d-flex flex-items-center flex-justify-center flex-column p-4 p-6 m-6"
style={{ maxWidth: "80ch" }}
>
<h1 className="h3 mb-3 f4 text-normal">
Purchase your Watermelon subscription
</h1>
{/* render if component already mounted */}
{retrievedClientSecret && (
<Elements stripe={stripePromise} options={options}>
<CheckoutForm />
</Elements>
)}
</div>
</div>
</div>
);
</code></pre>
| [
{
"answer_id": 74137991,
"author": "Jovana",
"author_id": 11365465,
"author_profile": "https://Stackoverflow.com/users/11365465",
"pm_score": 1,
"selected": true,
"text": "status = Status;\n"
},
{
"answer_id": 74138255,
"author": "MoxxiManagarm",
"author_id": 11011793,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6818017/"
] |
74,137,684 | <p>Here is a piece of code that counts the frequency of words in a sentence.<br />
I'm wondering if the <code>HashMap</code> can be set as immutable after counting the items.</p>
<pre class="lang-rust prettyprint-override"><code>let mut map = HashMap::new();
for word in s.split_whitespace() {
*map.entry(word).or_insert(0) += 1;
}
// after the for loop make map immutable
</code></pre>
<p>I'm aware of the crate <code>Counter</code> with the <code>collect</code> API but I'd prefer to do it without crates.</p>
<p>I would also prefer a solution that doesn't use functions or closures.</p>
| [
{
"answer_id": 74137757,
"author": "Aleksander Krauze",
"author_id": 13078067,
"author_profile": "https://Stackoverflow.com/users/13078067",
"pm_score": 0,
"selected": false,
"text": "// x is mut\nlet mut x = ...;\n\n// do stuff with mut x\n\n// now x is no longer mutable\nlet x = x;\n"
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19055902/"
] |
74,137,690 | <p>I'm building a webserver in TomCat, and trying to implement a function that returns a list normally, but I want it to first check if the user has a valid session. If the user does not have a valid session I want to send back a response with http status code 403. How can I do this? I can only return an empty list. This is my current code:</p>
<pre><code>public class AlertsResource {
@Context
UriInfo uriInfo;
@Context
Request request;
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Alert> getAlerts(@HeaderParam("sessionId") String sessionId) {
if (isValid(sessionId)) {
return DatabaseAccess.getAlerts();
}
return null;
}
}
</code></pre>
| [
{
"answer_id": 74137875,
"author": "Selvam Ramasamy",
"author_id": 3639556,
"author_profile": "https://Stackoverflow.com/users/3639556",
"pm_score": 2,
"selected": true,
"text": "ResponseEntity"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17129483/"
] |
74,137,711 | <p>I am working on something with neo4j.
My database has a label called 'Request' which has one particular property, the key is 'status' and the value can be 'APPROVED', 'PENDING' or 'REJECTED'.
Now I want to count all the request nodes as totalNodes, nodes that have request.status = "APPROVED" as approvedRequests, nodes which have request.status = "PENDING" as pendingRequests, and same with request.status = "REJECTED". I had done one implementation earlier like this</p>
<pre><code>match
(shop:Shop)
-[:HAS_request]->
(request:Request)
with count(distinct request) as totalrequests,
sum(case when request.status = "APPROVED" then 1 else 0 end) as appovedrequests,
sum(case when request.status = "PENDING" then 1 else 0 end) as pendingRequests,
sum(case when request.status = "REJECTED" then 1 else 0 end) as rejectedRequests
return totalrequests, approvedRequests, pendingRequests, rejectedRequests
</code></pre>
<p>but I think it will use multiple passes for all the request nodes. I want to declare these 3 variables (approvedReq, pendingReq, rejectedReq) and start iterating the request label nodes and when request.status = 'approved' , approvedReq should increase by 1, request.status = 'pending', pendingReq should increase by 1, and the same goes for 'rejected' case. This way I don't have to iterate all the nodes 3 times. Is there any way I can do it in a single pass?</p>
| [
{
"answer_id": 74137875,
"author": "Selvam Ramasamy",
"author_id": 3639556,
"author_profile": "https://Stackoverflow.com/users/3639556",
"pm_score": 2,
"selected": true,
"text": "ResponseEntity"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17911990/"
] |
74,137,715 | <p>So, as part of a challenge I found the following piece of code on a template of an opensource site:</p>
<pre><code>@app.route("/admin", methods=['GET', 'POST'])
def admin():
username = getUsernameFromSecureStorage() or "admin"
passwd = getPasswordFromSecureStorage()
if session.get('loggedin', False):
return render_template('admin_page.html')
else:
if request.method == 'POST':
if eval("'" + request.form['pass'] + "' == passwd"):
session['loggedin'] = True
return redirect(request.headers['referer'], code=302)
else:
return render_template('admin.html', msg="Login failed")
return render_template('admin.html', msg="Welcome to the admin page")
</code></pre>
<p>I know for a fact that there is a python command injection here, as I was able to execute a sleep function using the following payload in the password field:</p>
<pre><code>'+eval(compile('for x in range(1):\n import time\n time.sleep(20)','a','single'))+'
</code></pre>
<p>But in case of trying to bypass the login or getting a reverse shell, there has been no luck yet.</p>
<p>Grateful for any suggestions.</p>
| [
{
"answer_id": 74137809,
"author": "noah",
"author_id": 19745277,
"author_profile": "https://Stackoverflow.com/users/19745277",
"pm_score": -1,
"selected": false,
"text": "\"' == '' or '\""
},
{
"answer_id": 74137832,
"author": "Sarper Makas",
"author_id": 19737398,
"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388545/"
] |
74,137,716 | <p>Does anyone know what this actually does?</p>
<p>There appears to be two different timezones, a Session timezone and a Database time zone. The former is clear, it causes timezones with timestamp to be converted from a text representation in psql to UTC.</p>
<p>But what does the Database time zone do?</p>
<p>It can be changed with
ALTER DATABASE database_name SET TIMEZONE='zone';</p>
<p>Is Database Timezone just some sort of default for the Session Timezone? Or does it affect how timestamps are stored? My understanding is that the psql session timezone defaults to the client computer timezone.</p>
<p>There is also the question of the 99.9% of usages that do not use psql. Say JDBC. When and how are offsets added. But that is not this question.</p>
<p>Timezones are tricky, and never well documented.</p>
| [
{
"answer_id": 74271294,
"author": "Bergi",
"author_id": 1048572,
"author_profile": "https://Stackoverflow.com/users/1048572",
"pm_score": 2,
"selected": false,
"text": "timestamp with time zone"
},
{
"answer_id": 74312736,
"author": "jian",
"author_id": 15603477,
"au... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2698167/"
] |
74,137,746 | <p>Is there a direct way to create <code>col_list</code>, which specifies when only fruit and clothes are not na?</p>
<pre><code>df fruit clothes trending ...
0 apple shirt no
1 np.NaN trouser yes
2 np.NaN np.NaN yes
</code></pre>
<pre><code>df fruit clothes trending ... col_list
0 apple shirt no ["fruit", "clothes"]
1 np.NaN trouser yes ["clothes"]
2 np.NaN np.NaN yes np.NaN
</code></pre>
| [
{
"answer_id": 74271294,
"author": "Bergi",
"author_id": 1048572,
"author_profile": "https://Stackoverflow.com/users/1048572",
"pm_score": 2,
"selected": false,
"text": "timestamp with time zone"
},
{
"answer_id": 74312736,
"author": "jian",
"author_id": 15603477,
"au... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12642161/"
] |
74,137,749 | <p>So i have made a website with HTML and CSS. It has different effects like the parallax effect(a very simple version of it), transparent navbar, and now I am trying to make my Navbar responsive. Everything works, but my hamburger menu is very far to the left and when I find a way to move it, it doesnt work after i moved it.</p>
<p><a href="https://i.stack.imgur.com/aai3X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aai3X.png" alt="enter image description here" /></a></p>
<p>As you can see it is very close to the top of the screne and so far to the left that it is past the logo. I want it to stay to the right even if i made the screen smaller ofr bigger, like it moves with the screen when i move it.</p>
<p>This is my css code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code> @font-face {
font-family: 'Poppins';
src: url(Fonts/Poppins-Regular.ttf
}
@font-face {
font-family: 'Comfortaa';
src: url(Fonts/Comfortaa-VariableFont_wght.ttf);
}
@font-face {
font-family: 'DancingScript';
src: url(Fonts/DancingScript-VariableFont_wght.ttf);
}
* {
padding: 0;
margin: 0;
color: #A6808C;
box-sizing: border-box;
}
body {
background-color: #565264;
font-family: Poppins;
}
html {
overflow: scroll;
overflow-y: hidden;
}
::-webkit-scrollbar {
width: 0%;
}
nav {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 80px;
padding: 10px 90px;
box-sizing: border-box;
background: rgba(0, 0, 0, 0.4);
border-bottom: 0px solid #fff;
z-index: 9999
}
nav .logo {
padding: -22px 20px;
height: 50px;
float: left;
}
nav ul {
list-style: none;
float: right;
margin: 0;
padding: 0;
display: flex;
}
nav ul li a {
line-height: 60px;
color: #fff;
padding: 12px 30px;
text-decoration: none;
font-size: 25px;
}
nav ul li a:hover {
background: rgba(0,0,0,0.1);
border-radius: 5px;
}
.text {
font-size: 2rem;
padding: 2rem;
background-color: #565264;
color: whitesmoke;
}
.title {
font-size: 7rem;
color: whitesmoke;
text-shadow: 0 0 5px black;
}
.background {
position: absolute;
height: 100%;
width: 100%;
object-fit: cover;
z-index: -1;
transform: translateZ(-10px) scale(3);
background-repeat: no-repeat;
}
header {
position: relative;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
transform-style: preserve-3d;
z-index: -1;
}
.wrapper {
height: 100vh;
overflow-y: auto;
overflow-x: hidden;
perspective: 10px;
}
.hamburger {
position: relative;
width: 30px;
height: 4px;
background: #fff;
border-radius: 10px;
cursor: pointer;
z-index: 2;
transition: 0.3s;
}
.hamburger:before, .hamburger:after {
content: "";
position: absolute;
height: 4px;
right: 0;
background: #fff;
border-radius: 10px;
transition: 0.3s;
}
.hamburger:before {
top: -10px;
width: 20px;
}
.hamburger:after {
top: 10px;
width: 20px;
}
.toggle-menu {
position: absolute;
width: 30px;
height: 100%;
z-index: 3;
cursor: pointer;
opacity: 0;
}
.hamburger, .toggle-menu {
display: none;
}
.navigation input:checked ~ .hamburger {
background: transparent;
}
.navigation input:checked ~ .hamburger::before {
top: 0;
transform: rotate(-45deg);
width: 30px;
}
.navigation input:checked ~ .hamburger::after {
top: 0;
transform: rotate(45deg);
width: 30px;
}
.navigation input:checked ~ .menu {
right: 0;
box-shadow: -20px 0 40px rgba(0,0,0,0.3);
}
@media screen and (max-width: 1062px) {
.hamburger, .toggle-menu {
display: block;
}
.header {
padding: 10px 20px;
}
nav ul {
justify-content: start;
flex-direction: column;
align-items: center;
position: fixed;
top: 0;
right: -300px;
background-color: #565264;
width: 300px;
height: 100%;
padding-top: 65px;
}
.menu li {
width: 100%;
}
.menu li a, .menu li a:hover {
padding: 30px;
font-size: 24px;
box-shadow: 0 1px 0 rgba(112,102,119,0.5) inset;
}
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <head>
<meta charset="utf-8">
<meta name="veiwport" content="width=device-width, initalscale=1.0">
<Title>Test</Title>
<link rel="stylesheet" href="Style.css">
</head>
<body>
<nav>
<div class="logo">
<a href="index.html">
<img src="Pictures\Logo DesignK whitegreen.png" alt="DesignK" height="50px" width="200px">
</a>
</div>
<div class="navigation">
<input type="checkbox" class="toggle-menu">
<div class="hamburger"></div>
<ul class="menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Feedback</a></li>
</ul>
</div>
</nav>
<div class="wrapper">
<header>
<img src="Pictures/LakeandMoutains.jpg" class="background">
<h1 class="title">Welcome!</h1>
</header>
<section class="text">
<h3>Essay on Mountains</h3>
</section>
</div>
</body></code></pre>
</div>
</div>
</p>
<p>Does anyone know how to make the hamburger menu move to the right side of the screen?</p>
| [
{
"answer_id": 74137817,
"author": "Brad",
"author_id": 13947576,
"author_profile": "https://Stackoverflow.com/users/13947576",
"pm_score": 0,
"selected": false,
"text": "nav {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n}\n\n.navigation {\n margin-left: auto;... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20229204/"
] |
74,137,776 | <p>discord.ext.commands.bot: Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "ping" is not found.
How to fix it?</p>
<p>Main class:</p>
<pre><code>import discord
from discord.ext import commands
from discord import Intents
import os
intents = Intents.all()
intents.members = True
bot = commands.Bot(command_prefix='$', intents=intents)
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f"cogs.{filename[:-3]}")
@bot.event
async def on_ready():
print('We Have logged in as {0.user}'.format(bot))
bot.run('TOKEN')
</code></pre>
<p>My cog:</p>
<pre><code>from discord.ext import commands
class MainCog:
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
async def ping(self, ctx):
await ctx.send('pong')
async def on_message(self, message):
print(message.content)
def setup(bot):
bot.add_cog(MainCog(bot))
</code></pre>
| [
{
"answer_id": 74139438,
"author": "SMC",
"author_id": 19371161,
"author_profile": "https://Stackoverflow.com/users/19371161",
"pm_score": 0,
"selected": false,
"text": "commands.Cog"
},
{
"answer_id": 74140189,
"author": "stijndcl",
"author_id": 13568999,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20290290/"
] |
74,137,808 | <p>I would like to make a dropdown menu in a plotly line graph such as the one <a href="https://stackoverflow.com/questions/59406167/plotly-how-to-filter-a-pandas-dataframe-using-a-dropdown-menu">in this post</a> but with several lines.<br />
Let's take a sample dataframe :</p>
<pre><code>import pandas as pd
df = pd.DataFrame({"Date": ["2022-10-01","2022-10-02","2022-10-03","2022-10-01","2022-10-02","2022-10-03","2022-10-01","2022-10-02","2022-10-03","2022-10-01","2022-10-02","2022-10-03"],
"Animal" :["Cat","Cat","Cat","Cat","Cat","Cat","Dog","Dog","Dog","Dog","Dog","Dog"],
"Category":["Small","Small","Small","Big","Big","Big","Small","Small","Small","Big","Big","Big"],
"Quantity":[2,4,3,5,1,2,6,5,6,4,2,1]})
df["Date"] = df["Date"].astype('datetime64')
</code></pre>
<p>I would like to make a plotly line graph with <code>Date</code> in x axis, <code>Quantity</code> in y axis, a curve for each <code>Animal</code> and a filter for each <code>Category</code>. I tried the following function but the result is not good as the lines are shaking. Would you know please where my mistake is ?</p>
<pre><code>import plotly.graph_objects as go
def plot_line_go_graph(df,col_x,col_y,col_color = None,col_filter = None,add_points = False) :
df_graph = df.copy()
if add_points :
param_mode='lines+markers'
param_name='lines+markers'
else :
param_mode='lines'
param_name='lines'
fig = go.Figure()
if col_filter is None :
if col_color is None :
fig.add_trace(go.Scatter(x=df_graph[col_x], y=df_graph[col_y],mode=param_mode,name=param_name))
else :
for c in df_graph[col_color].unique() :
fig.add_trace(go.Scatter(x=df_graph[df_graph[col_color]==c][col_x], y=df_graph[df_graph[col_color]==c][col_y],mode=param_mode,name=c))
else :
df_graph[col_filter] = df_graph[col_filter].fillna("NaN")
if col_color is None :
fig.add_trace(go.Scatter(x=df_graph[col_x], y=df_graph[col_y],mode=param_mode,name=param_name,visible = True))
else :
for c in df_graph[col_color].unique() :
fig.add_trace(go.Scatter(x=df_graph[df_graph[col_color]==c][col_x], y=df_graph[df_graph[col_color]==c][col_y],mode=param_mode,name=c,visible = True))
updatemenu = []
buttons = []
# button with one option for each dataframe
buttons.append(dict(method='restyle',
label="All",
visible=True,
args=[{'y':[df_graph[col_y]],
'x':[df_graph[col_x]],
'type':'scatter'}, [0]],
)
)
for f in df_graph[col_filter].unique():
buttons.append(dict(method='restyle',
label=f,
visible=True,
args=[{'y':[df_graph[df_graph[col_filter]==f][col_y]],
'x':[df_graph[df_graph[col_filter]==f][col_x]],
'type':'scatter'}, [0]],
)
)
# some adjustments to the updatemenus
updatemenu = []
your_menu = dict()
updatemenu.append(your_menu)
updatemenu[0]['buttons'] = buttons
updatemenu[0]['direction'] = 'down'
updatemenu[0]['showactive'] = True
# add dropdown menus to the figure
fig.update_layout(updatemenus=updatemenu)
if col_color is None :
fig.update_layout(showlegend=False)
fig.update_layout({
'plot_bgcolor': 'rgba(0,0,0,0)',
'paper_bgcolor': 'rgba(0,0,0,0)',
},
hoverlabel=dict(
#bgcolor="white",
font_size=12,
#font_family="Rockwell"
),
hovermode = "x"
)
fig.update_xaxes(showspikes=True, spikecolor = 'black', showline=True, linewidth=1,linecolor='black', ticks = "outside", tickwidth = 1, tickcolor = 'black',ticklen = 5)
fig.update_yaxes(showspikes=True, spikecolor = 'black', showline=True, linewidth=1,linecolor='black', ticks = "outside", tickwidth = 1, tickcolor = 'black',ticklen = 5)
fig.show()
</code></pre>
<pre><code>plot_line_go_graph(df,"Date","Quantity",col_color = "Animal", col_filter = "Category",add_points = False)
</code></pre>
<p><a href="https://i.stack.imgur.com/SBFxL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SBFxL.png" alt="Wrong output" /></a></p>
| [
{
"answer_id": 74160817,
"author": "Derek O",
"author_id": 5327068,
"author_profile": "https://Stackoverflow.com/users/5327068",
"pm_score": 2,
"selected": false,
"text": "\"Category\""
},
{
"answer_id": 74191439,
"author": "Ewdlam",
"author_id": 12292032,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12292032/"
] |
74,137,820 | <p>I am building an application that has auth system and a lot of post requests,</p>
<p>I want to know how to make my backend endpoints accept only requests that are coming from my application, not from anything else like Postman.</p>
<p>For example, if a user submitted a registration form, a post request is sent to my backend with user info, how can I make sure this post request is coming from my application?</p>
<p>What I was thinking of, is saving a secret on the client’s side that is to be sent with each request to the backend, so that I can make sure the request is coming from my app.
I think SSL pinning is meant for this.</p>
<p>I know that anyone can access my app source code if they extract the APK file.
I want to make sure that no one can alter or steal my source code.</p>
<p>I read that I can make my code unreadable by Obfuscating it ( I still need to figure out how I am going to do that on my EAS build ), is this enough?</p>
<p>And I have to use JailMonkey to detect if the device is rooted.</p>
<p>I am using Expo secure store to save my sensitive info on the client side.</p>
<p>Is this approach good enough, is there anything I am missing?
I have zero information about security, this is just what I learned through searching.</p>
<p>Let me know if you have better suggestions.</p>
<p>Thank you in advance.</p>
| [
{
"answer_id": 74160817,
"author": "Derek O",
"author_id": 5327068,
"author_profile": "https://Stackoverflow.com/users/5327068",
"pm_score": 2,
"selected": false,
"text": "\"Category\""
},
{
"answer_id": 74191439,
"author": "Ewdlam",
"author_id": 12292032,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16523033/"
] |
74,137,826 | <p>I'm looking to try to pick up all parquet files from an s3 bucket that have been placed into partitioned sub-folders by date.</p>
<p>In the past I've used snowpipe with a sort of 1-1 relationship, one sub-folder to one table; but I would be interested to know if it is possible to crawl over partitioned data to a single table.</p>
<p>Many thanks!</p>
| [
{
"answer_id": 74160817,
"author": "Derek O",
"author_id": 5327068,
"author_profile": "https://Stackoverflow.com/users/5327068",
"pm_score": 2,
"selected": false,
"text": "\"Category\""
},
{
"answer_id": 74191439,
"author": "Ewdlam",
"author_id": 12292032,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17546365/"
] |
74,137,829 | <p>I am having trouble getting a number instead of a string in my query. I have two tables and a pivot table.</p>
<p><strong>File</strong>:</p>
<ul>
<li>id</li>
<li>name</li>
<li>document</li>
<li>language</li>
</ul>
<p><strong>Role</strong>:</p>
<ul>
<li>id</li>
<li>name (admin, partner, dealer, associate)</li>
</ul>
<p><strong>File_role</strong>:</p>
<ul>
<li>id</li>
<li>file_id</li>
<li>role_id</li>
</ul>
<p>I want to display all the files for the 'dealer' role so i tried this:</p>
<pre><code>$file_role = File_Role::where('role_id', '=', $id)->get('file_id');
$file = File::where('id', '=', $file_role)->get();
dd($file_role);
</code></pre>
<p>However it keeps returning errors on:</p>
<pre><code>$file = File::where('id', '=', $file_role)->get();
</code></pre>
<p>The error is:</p>
<blockquote>
<p>SQLSTATE[HY093]: Invalid parameter number.</p>
</blockquote>
<p>The query below that is:</p>
<pre><code>select * from `file` where `id` = {"file_id":1}.
</code></pre>
<p>Any ideas how I can get a number instead of <code>"file_id":1</code>?</p>
| [
{
"answer_id": 74137944,
"author": "Tjardo",
"author_id": 5055613,
"author_profile": "https://Stackoverflow.com/users/5055613",
"pm_score": 2,
"selected": false,
"text": "$file_role = File_Role::where('role_id', '=', $id)->firstOrFail();\n$file = File::where('id', '=', $file_role->file_i... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19923550/"
] |
74,137,857 | <p>im having my application deployed in openshift, for file transfer we're using sftp and have configured sftp private key via secret
but on making the api call via swagger , getting the response as invalid private key
any help on how i can include this private key which is of multiple lines in the secret yaml file</p>
<p>below is the error im getting</p>
<pre><code>------stack trace-------
java.lang.IllegalStateException: failed to create SFTP Session
at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:404)
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@50ae9b59
at com.jcraft.jsch.KeyPair.load(KeyPair.java:747)
2022-10-19 13:33:43,123 - [threadPoolTaskExecutor-2] ERROR - transactionId: - Encountered an error executing step Download 0145A files in job Download Job
java.util.concurrent.CompletionException: org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is java.lang.IllegalStateException: failed to create SFTP Session
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
Caused by: org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is java.lang.IllegalStateException: failed to create SFTP Session
at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:461)
Caused by: java.lang.IllegalStateException: failed to create SFTP Session
at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:404)
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@7204aa68
</code></pre>
<p>below is the secret file that i used</p>
<pre><code>secret-test.yaml
apiVersion: xx
kind: Secret
metadata:
name: xxxxx
namespace: xxxxxxxx
type: Opaque
stringData:
key_name: >
PuTTY-User-Key-File-2: ssh-rsa\r\
Encryption: none\r\
Comment: rsa-key-20210504\r\
Public-Lines: 12\r\
AAAAB3NzaC1yc2EAAAABJQAAAgEAhi7HxCYBA3gvK0UbFenUlQTGUsDfvCXbEg/Y\r\
As3jvPl6hIjHp2xAOyOQ5P6A8zx9prjk06Q5q44lKzZXgGzJS8ZxpsMWsPA/+x1M\r\
.
.
.
4s5A+20CflMMEwK/G6Kny7ZduVRDmULzbUjaTPyw8rHYI9Do/YIIskDlwbdy3alg\r\
3/PYjrPEUq62yXZEvt7XOcSesrrVLLDMsOK3LJvQqZCrVFnRgTSoxDhGFNwb8De8\r\
jbdW1j/G+vPegA7yjI7r2QZx7gI23CX0XZkXud3LzhZn02RmdboxErrRMKrp/cgX\r\
zdWd2DM=\r\
Private-Lines: 28\r\
AAACACCjmGAk631ibFaiG1hbeOX6PhQhE9PR21droz7zz5yrYv2kuvFfhT7RTMIU\r\
.....
EwlRTPzhe070NNze7yNMp4zsTAG2I98PEXZYbl7oyUXkzJE/AmQqwgOomoWx8IEL\r\
U6E=\r\
Private-MAC: 87d58cb0e3e60ef943ee9396fe9\r
</code></pre>
<p>Things i tried:</p>
<ul>
<li>included |- , >-, only |,only ></li>
<li>tried enclosing in double quotes with backslash as escape character</li>
</ul>
<p>something like below</p>
<pre><code> "PuTTY-User-Key-File-2: ssh-rsa\
Encryption: none\
Comment: rsa-key-20210504..."
still got the same error as above
</code></pre>
| [
{
"answer_id": 74138074,
"author": "Harsh Manvar",
"author_id": 5525824,
"author_profile": "https://Stackoverflow.com/users/5525824",
"pm_score": 0,
"selected": false,
"text": "kubectl create secret generic ssh-keys --from-file=id_rsa=/path/to/.ssh/id_rsa\n"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20290173/"
] |
74,137,858 | <p>I have a cart view where I'm trying to check if the products added to the cart have even one item in the list that has <code>product.availability</code> set to False and work accordingly in Template, the problem is with accessing the product availability in cart object list, So how do I check the availability of products that people added to cart?</p>
<p>P.S I shortened the code for utils, I'll add more if needed for understanding</p>
<p>Model</p>
<pre><code>class Product(models.Model):
availability = models.BooleanField()
</code></pre>
<p>Utils</p>
<pre><code>def cookieCart(request):
try:
cart = json.loads(request.COOKIES['cart'])
except:
cart = {}
items = []
for i in cart:
try:
product = Product.objects.get(id=i)
item = {
'product':{
'id':product.id,
'name':product.name,
'final_price':product.final_price,
'image_URL':product.image_URL,
'availability':product.availability,
},
'quantity':cart[i]["quantity"],
'get_total':total,
}
items.append(item)
except:
pass
return {"items": items}
def cartData(request):
if request.user.is_authenticated:
customer = request.user.customer
order, created = Order.objects.get_or_create(customer=customer, complete=False)
items = order.orderitem_set.all()
else:
cookieData = cookieCart(request)
items = cookieData['items']
return {'items':items}
</code></pre>
<p>Views</p>
<pre><code>def cart(request):
data = cartData(request)
#products added to cart
items = data['items']
#Checking if even one product added to cart has availability set to False
available = all(x.availability for x in items)
context = {'items': items, 'available': available}
</code></pre>
<p>Template</p>
<pre><code><p>{{items.product.name}}</p>
{% if available %}
<a href="#">Checkout</a>
{% else %}
<p>Out of stock</p>
{% endif %}
</code></pre>
<p>Traceback</p>
<pre><code>Traceback (most recent call last):
File "D:\test\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "D:\test\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\test\shop\views.py", line 101, in cart
available = all(x.availability for x in items)
File "D:\test\shop\views.py", line 101, in <genexpr>
available = all(x.availability for x in items)
Exception Type: AttributeError at /shop/cart
Exception Value: 'dict' object has no attribute 'availability'
</code></pre>
| [
{
"answer_id": 74138044,
"author": "walter zeni",
"author_id": 9039472,
"author_profile": "https://Stackoverflow.com/users/9039472",
"pm_score": 0,
"selected": false,
"text": "def cookieCart(request):\n try:\n cart = json.loads(request.COOKIES['cart'])\n except:\n car... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18982716/"
] |
74,137,871 | <p>I'm still a little new to the JS environment and desperately need some help. I want to create an Outlook addin with a react-interface and have created a template via the yeoman generator. Finally I added a library called axios to the project via npm. Now there are several errors when compiling/debugging:</p>
<p>ERROR in ./node_modules/follow-redirects/index.js 3:11-26
Module not found: Error: Can't resolve 'http' in 'PathToModule\node_modules\follow-redirects'</p>
<p>What do the errors say and how can I eliminate them?</p>
<pre><code><i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:3000/
<i> [webpack-dev-server] On Your Network (IPv4): https://192.168.100.31:3000/
<i> [webpack-dev-server] Content not from webpack is served from 'C:\Users\denny\FloxAddIn\public' directory
assets by path assets/*.png 88.2 KiB 6 assets
assets by path *.js 9.93 MiB
asset vendor.js 6.21 MiB [emitted] (name: vendor) 1 related asset
asset taskpane.js 2.6 MiB [emitted] (name: taskpane) 1 related asset
asset polyfill.js 888 KiB [emitted] (name: polyfill) 1 related asset
asset commands.js 249 KiB [emitted] (name: commands) 1 related asset
assets by path *.xml 8.42 KiB
asset manifest copy.xml 4.61 KiB [emitted] [from: manifest copy.xml] [copied]
asset manifest.xml 3.81 KiB [emitted] [from: manifest.xml] [copied]
assets by path *.html 1.55 KiB
asset taskpane.html 1.12 KiB [emitted]
asset commands.html 444 bytes [emitted]
asset 8557bda7801491dd2dad.css 1.48 KiB [emitted] [immutable] [from: src/taskpane/taskpane.css]
orphan modules 25.7 KiB [orphan] 182 modules
runtime modules 110 KiB 52 modules
modules by path ./node_modules/ 4.66 MiB 1433 modules
modules by path ./src/ 45.4 KiB
modules by path ./src/taskpane/components/*.js 41.4 KiB
./src/taskpane/components/App.js 10.6 KiB [built] [code generated]
./src/taskpane/components/Header.js 5 KiB [built] [code generated]
./src/taskpane/components/HeroList.js 5.41 KiB [built] [code generated]
./src/taskpane/components/Progress.js 5.15 KiB [built] [code generated]
./src/taskpane/components/BeteiligtenListe.js 5.49 KiB [built] [code generated]
./src/taskpane/components/BeteiligterAction.js 9.84 KiB [built] [code generated]
./src/taskpane/index.js 1.89 KiB [built] [code generated]
./src/commands/commands.js 2.02 KiB [built] [code generated]
./assets/logo-filled.png 42 bytes (javascript) 38.9 KiB (asset) [built] [code generated]
ERROR in ./node_modules/follow-redirects/index.js 3:11-26
Module not found: Error: Can't resolve 'http' in 'C:\Users\denny\FloxAddIn\node_modules\follow-redirects'
Did you mean './http'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
- install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "http": false }
@ ./node_modules/axios/dist/node/axios.cjs 9:24-51
@ ./src/taskpane/components/BeteiligterAction.js 77:18-42 112:22-46
@ ./src/taskpane/components/App.js 36:0-52 203:45-62
@ ./src/taskpane/index.js 1:0-35 23:9-12 27:7-10 30:40-34:3 30:2-34:4 31:18-53
ERROR in ./node_modules/follow-redirects/index.js 4:12-28
Module not found: Error: Can't resolve 'https' in 'C:\Users\denny\FloxAddIn\node_modules\follow-redirects'
Did you mean './https'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
- install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "https": false }
@ ./node_modules/axios/dist/node/axios.cjs 9:24-51
@ ./src/taskpane/components/BeteiligterAction.js 77:18-42 112:22-46
@ ./src/taskpane/components/App.js 36:0-52 203:45-62
@ ./src/taskpane/index.js 1:0-35 23:9-12 27:7-10 30:40-34:3 30:2-34:4 31:18-53
ERROR in ./node_modules/follow-redirects/index.js 5:15-41
Module not found: Error: Can't resolve 'stream' in 'C:\Users\denny\FloxAddIn\node_modules\follow-redirects'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
@ ./node_modules/axios/dist/node/axios.cjs 9:24-51
@ ./src/taskpane/components/BeteiligterAction.js 77:18-42 112:22-46
@ ./src/taskpane/components/App.js 36:0-52 203:45-62
@ ./src/taskpane/index.js 1:0-35 23:9-12 27:7-10 30:40-34:3 30:2-34:4 31:18-53
ERROR in ./node_modules/follow-redirects/index.js 6:13-30
Module not found: Error: Can't resolve 'assert' in 'C:\Users\denny\FloxAddIn\node_modules\follow-redirects'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "assert": require.resolve("assert/") }'
- install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "assert": false }
@ ./node_modules/axios/dist/node/axios.cjs 9:24-51
@ ./src/taskpane/components/BeteiligterAction.js 77:18-42 112:22-46
@ ./src/taskpane/components/App.js 36:0-52 203:45-62
@ ./src/taskpane/index.js 1:0-35 23:9-12 27:7-10 30:40-34:3 30:2-34:4 31:18-53
ERROR in ./node_modules/axios/dist/node/axios.cjs 7:13-28
Module not found: Error: Can't resolve 'http' in 'C:\Users\denny\FloxAddIn\node_modules\axios\dist\node'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
- install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "http": false }
@ ./src/taskpane/components/BeteiligterAction.js 77:18-42 112:22-46
@ ./src/taskpane/components/App.js 36:0-52 203:45-62
@ ./src/taskpane/index.js 1:0-35 23:9-12 27:7-10 30:40-34:3 30:2-34:4 31:18-53
ERROR in ./node_modules/axios/dist/node/axios.cjs 8:14-30
Module not found: Error: Can't resolve 'https' in 'C:\Users\denny\FloxAddIn\node_modules\axios\dist\node'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
- install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "https": false }
@ ./src/taskpane/components/BeteiligterAction.js 77:18-42 112:22-46
@ ./src/taskpane/components/App.js 36:0-52 203:45-62
@ ./src/taskpane/index.js 1:0-35 23:9-12 27:7-10 30:40-34:3 30:2-34:4 31:18-53
ERROR in ./node_modules/axios/dist/node/axios.cjs 10:13-28
Module not found: Error: Can't resolve 'zlib' in 'C:\Users\denny\FloxAddIn\node_modules\axios\dist\node'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
- install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "zlib": false }
@ ./src/taskpane/components/BeteiligterAction.js 77:18-42 112:22-46
@ ./src/taskpane/components/App.js 36:0-52 203:45-62
@ ./src/taskpane/index.js 1:0-35 23:9-12 27:7-10 30:40-34:3 30:2-34:4 31:18-53
ERROR in ./node_modules/axios/dist/node/axios.cjs 11:15-32
Module not found: Error: Can't resolve 'stream' in 'C:\Users\denny\FloxAddIn\node_modules\axios\dist\node'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
@ ./src/taskpane/components/BeteiligterAction.js 77:18-42 112:22-46
@ ./src/taskpane/components/App.js 36:0-52 203:45-62
@ ./src/taskpane/index.js 1:0-35 23:9-12 27:7-10 30:40-34:3 30:2-34:4 31:18-53
8 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.53.0 compiled with 8 errors in 17315 ms
</code></pre>
| [
{
"answer_id": 74138044,
"author": "walter zeni",
"author_id": 9039472,
"author_profile": "https://Stackoverflow.com/users/9039472",
"pm_score": 0,
"selected": false,
"text": "def cookieCart(request):\n try:\n cart = json.loads(request.COOKIES['cart'])\n except:\n car... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20289549/"
] |
74,137,946 | <p>I have a login-page where I want the transition of the logo from large to small (and back) to be smoother. As it is now, it just pops between the two.</p>
<p>When the keyboard opens, I would like the logo to animate to the smaller position, instead of just instantly changing.</p>
<p>Does anyone know a way to do this?</p>
<pre><code>@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
resizeToAvoidBottomInset: true,
backgroundColor: AppColors.yellowLight,
// appBar: MainAppBar(),
body: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(vertical: 90),
child: Image(
image: ExactAssetImage('assets/icons/app_logo.png'),
height: MediaQuery.of(context).viewInsets.bottom == 0
? size.height * 0.3
: size.height * 0.15,
fit: BoxFit.fitHeight,
alignment: Alignment.center,
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 50),
child: MainTextField(
controller: emailController,
labelText: 'E-post',
hintText: 'Skriv e-post som abc@epost.no'),
),
Padding(
padding: const EdgeInsets.only(
left: 50.0, right: 50.0, top: 30, bottom: 30),
child: MainTextField(
controller: passwordController,
obscureText: true,
labelText: 'Passord',
hintText: 'Skriv inn sikkert passord',
),
),
LoginButton(
text: 'Logg inn',
isLoading: isLoading,
onPressed: _login,
),
// Text('New User? Create Account')
],
),
),
),
);
}
</code></pre>
| [
{
"answer_id": 74139357,
"author": "Omar Alshyokh",
"author_id": 11706586,
"author_profile": "https://Stackoverflow.com/users/11706586",
"pm_score": 1,
"selected": false,
"text": " AnimatedContainer(\n height: MediaQuery.of(context).viewInsets.bottom != 0 ? 100.0 : 200.0,\n ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20118511/"
] |
74,137,951 | <p>I'm building a student-tutor app using swift + firebase (auth and firestore).</p>
<p>I have a wrapper widget that checks if a user is logged in. If they're not, I direct them to an authentication screen (login/registration). If they are logged in, I then want to check if they are a student or a tutor.</p>
<p>In other words, in my wrapper, I need a way to retrieve user data from firestore and check their role and then direct them to the appropriate screen. I can't figure out how to do it. Please help. This is my wrapper class</p>
<pre><code>let UID = Auth.auth().currentUser?.uid
let db = Firestore.firestore()
db.collection("Users").document(UID!).getDocument { snapshot, error in
if error == nil {
let viewController = self.storyboard?.instantiateViewController(withIdentifier: "SignUpViewControllerID")
GetWindow()?.rootViewController = viewController
GetWindow()?.makeKeyAndVisible()
}else{
if let viewController = self.storyboard?.instantiateViewController(withIdentifier: "MainTabBarController") {
GetWindow()?.rootViewController = viewController
GetWindow()?.makeKeyAndVisible()
}
</code></pre>
| [
{
"answer_id": 74139357,
"author": "Omar Alshyokh",
"author_id": 11706586,
"author_profile": "https://Stackoverflow.com/users/11706586",
"pm_score": 1,
"selected": false,
"text": " AnimatedContainer(\n height: MediaQuery.of(context).viewInsets.bottom != 0 ? 100.0 : 200.0,\n ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19445286/"
] |
74,137,966 | <p>I'm trying to webscrape the news from the following URL:
<a href="https://www.google.com/search?num=250&q=Apple+innovation%20performance&oq=Apple+innovation%20performance%3D1600&source=lnt&tbs=cdr:1,cd_min:1/1/2018,cd_max:12/31/2018&tbm=nws&hl=en-US" rel="nofollow noreferrer">https://www.google.com/search?num=250&q=Apple+innovation%20performance&oq=Apple+innovation%20performance%3D1600&source=lnt&tbs=cdr:1,cd_min:1/1/2018,cd_max:12/31/2018&tbm=nws&hl=en-US</a></p>
<p>However I can see that Google is changing the name of their news's div classes every time I do a request, so I was wondering if it was possible to iterate through the list of each news section by specifying BeautifulSoup to go a certain level of div.</p>
<p>Please see below a screenshot showing a bit more what I'm trying to explain (I'd like to iterate through the "SoaBEf xuvV6b" sections, however the name changes on every request):</p>
<p><a href="https://i.stack.imgur.com/3AMMk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3AMMk.png" alt="screenshot of the page structure" /></a></p>
| [
{
"answer_id": 74150032,
"author": "Driftr95",
"author_id": 6146136,
"author_profile": "https://Stackoverflow.com/users/6146136",
"pm_score": 1,
"selected": false,
"text": "select"
},
{
"answer_id": 74150448,
"author": "HedgeHog",
"author_id": 14460824,
"author_profil... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10824073/"
] |
74,137,969 | <p>I am trying to build a route with node and typescript where I can add products to a cart, however it is complaining about the interface.</p>
<p>Here is the interface in <strong>interfaces.ts</strong>:</p>
<pre><code>import { Document } from "mongoose";
export interface IUser extends Document {
firstName: string;
lastName: string;
email: string;
password: string;
cart: ICart;
orders: IOrders[];
}
export interface ICart {
total: number;
count: number;
}
</code></pre>
<p>My model in <strong>UserModel.ts</strong>:</p>
<pre><code>const UserSchema = new Schema({
firstName: {
type: String,
required: true,
},
lastName: {
type: String,
required: true,
},
email: {
type: String,
required: true,
unique: true,
validate: {
validator: function (str: string) {
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/g.test(str);
},
message: (props: { value: string }) =>
`${props.value} is not a valid email`,
},
},
password: {
type: String,
required: true,
},
cart: {
type: Object,
default: {
total: 0,
count: 0,
},
},
orders: [{ type: mongoose.Schema.Types.ObjectId, ref: "Order" }],
});
const UserModel = mongoose.model<IUser>("User", UserSchema);
export default UserModel;
</code></pre>
<p>And lastly, the route in <strong>productRoutes.ts</strong>:</p>
<pre><code>productRoutes.post('/add-to-cart', async(req, res)=> {
const {userId, productId, price} = req.body;
try {
const user = await UserModel.findById(userId);
const userCart = user.cart;
if(user.cart[productId]){
userCart[productId] += 1;
} else {
userCart[productId] = 1;
}
userCart.count += 1;
userCart.total = Number(userCart.total) + Number(price);
if (user) {
user.cart = userCart;
user.markModified('cart');
await user.save();
}
res.status(200).json(user);
} catch (e) {
res.status(400).send(e);
}
})
</code></pre>
<p>The error I am getting is in productRoutes.ts, in my try catch, specifically in these two parts:</p>
<pre><code>const userCart = user.cart; // Object is possibly 'null'
</code></pre>
<pre><code> if(user.cart[productId]){ // Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'ICart'.
userCart[productId] += 1; // Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'ICart'.
} else {
userCart[productId] = 1; // Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'ICart'.
}
</code></pre>
<p>What am I doing wrong, where do I type it and how do I index type "ICart"?</p>
| [
{
"answer_id": 74150032,
"author": "Driftr95",
"author_id": 6146136,
"author_profile": "https://Stackoverflow.com/users/6146136",
"pm_score": 1,
"selected": false,
"text": "select"
},
{
"answer_id": 74150448,
"author": "HedgeHog",
"author_id": 14460824,
"author_profil... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18893725/"
] |
74,137,988 | <pre><code>library(tidyverse)
library(waffle)
df_2 <- structure(list(group = c(2, 2, 2, 1, 1, 1),
parts = c("A", "B", "C", "A", "B", "C"),
values = c(1, 39, 60, 14, 15, 71)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))
df_2 %>% ggplot(aes(label = parts)) +
geom_pictogram(
n_rows = 10, aes(color = parts, values = values),
family = "fontawesome-webfont",
flip = TRUE
) +
scale_label_pictogram(
name = "Case",
values = c("male"),
breaks = c("A", "B", "C"),
labels = c("A", "B", "C")
) +
scale_color_manual(
name = "Case",
values = c("A" = "red", "B" = "green", "C" = "grey85"),
breaks = c("A", "B", "C"),
labels = c("A", "B", "C")
) +
facet_grid(~group)
</code></pre>
<p>With the above code, I got the legend what I expected:
<a href="https://i.stack.imgur.com/RubH6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RubH6.png" alt="enter image description here" /></a></p>
<p>However, when I replaced <code>df_2</code> with the following <code>df_1</code> dataframe, I was unable to combine two legends.</p>
<pre><code>df_1 <- structure(list(group = c(2, 2, 2, 1, 1, 1),
parts = c("A", "B", "C", "A", "B", "C"),
values = c(0, 0, 100, 0, 0, 100)),
row.names = c(NA,-6L), class = c("tbl_df", "tbl", "data.frame"))
</code></pre>
<p>I kind of know the cause of the problem (0 values) but I would like to keep the legend the same as the graph above. Any suggestions would be appreciated.</p>
<p><a href="https://i.stack.imgur.com/7LEsL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7LEsL.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74138180,
"author": "Quinten",
"author_id": 14282714,
"author_profile": "https://Stackoverflow.com/users/14282714",
"pm_score": 1,
"selected": false,
"text": "ggplot_build"
},
{
"answer_id": 74138184,
"author": "Allan Cameron",
"author_id": 12500315,
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74137988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11741943/"
] |
74,138,015 | <p>Below is the code</p>
<pre><code>const fs = require('fs');
const xml2js = require('xml2js');
const log = console.log;
const path = require( "path" );
const folderPath = 'Data';
const folder = folderPath;
let counter = 0;
fs.readdirSync(folder).forEach(file => {
const extname = path.extname(file);
const filename = path.basename(file, extname);
const absolutePath = path.resolve(folder, file);
const parser = new xml2js.Parser({
mergeAttrs: true,
explicitArray: false
});
counter++;
fs.readFile(absolutePath, (err, data) => {
parser.parseString(data, (err, result) => {
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";
MongoClient.connect(url, function (err, db) {
if (err) throw err;
var dbo = db.db("mydb");
dbo.collection("customers").insertOne(result, function (err, res) {
if (err) throw err;
console.log("XML Uploaded Succesfully : " + absolutePath);
db.close();
});
});
});
});
});
console.log("Number of XML inserted: " + counter);
</code></pre>
<p>=============================================================</p>
<p>Above code works Perfectly it reads all the files that are present in Data folder
i want to limit this
i.e Suppose i have 10 files in Data folder but want to read only first 5 files and after reading the first 5 files i want it to move in another folder say it "Done Reading"</p>
| [
{
"answer_id": 74138180,
"author": "Quinten",
"author_id": 14282714,
"author_profile": "https://Stackoverflow.com/users/14282714",
"pm_score": 1,
"selected": false,
"text": "ggplot_build"
},
{
"answer_id": 74138184,
"author": "Allan Cameron",
"author_id": 12500315,
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74138015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10298898/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.