qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,453,477 | <p>I am writing an app that runs on both iOS and macOS, using Mac Catalyst with Swift.</p>
<p>I want to set a property that is <em>only</em> available on macOS but I cannot find a way using <code>#available</code> or <code>@available</code> to prevent the compiler from including this line of code in the iOS builds:</p>
<p>This syntax does not work because the <em>mandatory</em> trailing <code>*</code> includes all iOS versions.</p>
<pre><code>if #available(macCatalyst 13.0, *) {
view.showsZoomControls = true
}
</code></pre>
<p>I tried adding a nonsense version of iOS using <code>iOS 999</code> but that didn't work either, because the property is marked strictly unavailable in iOS.</p>
<p>Using <code>@available</code> there's a longhand syntax using <code>introduced:</code> that allows per-OS versions to be specified and requires a separate <code>@available</code> entry per OS but I can't see any way to use that. It seems you can't use <code>@available</code> on a block of code.</p>
<p>Is there really no sane way to do this?</p>
<p>For reference, the definition of this specific property is:</p>
<pre><code>@property (nonatomic) BOOL showsZoomControls
API_AVAILABLE(macos(10.9), macCatalyst(13.0))
API_UNAVAILABLE(ios, watchos, tvos);
</code></pre>
| [
{
"answer_id": 74454361,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 0,
"selected": false,
"text": "chull()"
},
{
"answer_id": 74454455,
"author": "Dan Adams",
"author_id": 13210554,
"author_profile": "https://Stackoverflow.com/users/13210554",
"pm_score": 1,
"selected": false,
"text": "geom_polygon()"
}
] | 2022/11/15 | [
"https://Stackoverflow.com/questions/74453477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6782/"
] |
74,453,519 | <p>I am currently working on a dropdown filter that lets the user choose between a period of time in where he can select either daily, weekly, monthly and yearly. I manage to create the daily filter but on the weekly, monthly and yearly bases I am having issues with the start and end date that I need to consider each for each loop.</p>
<p>As a sample, let say that I have this object.</p>
<pre><code> let objArr = [
'2022-10-17 00:00:00',
'2022-10-24 00:00:00',
'2022-11-07 00:00:00',
'2022-11-14 00:00:00'
]
</code></pre>
<p>So after going through each date, I want to create a range that includes the start date and an end date before the next element. Here is an example of what I am trying to get.</p>
<pre><code> let objArr = [
'2022-10-17 00:00:00'-'2022-10-23 00:00:00',
'2022-10-24 00:00:00'-'2022-11-06 00:00:00',
'2022-11-07 00:00:00'-'2022-11-13 00:00:00',
'2022-11-14 00:00:00'-'2022-11-20 00:00:00'
]
</code></pre>
<p>In summary, I want to create a date range for each date element in an object that has gaps in between. I will be using the created date range of each loop to fetch the data from the db that is inside the date range. Thank you in advance</p>
<p>I have no idea what to do here.</p>
| [
{
"answer_id": 74454361,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 0,
"selected": false,
"text": "chull()"
},
{
"answer_id": 74454455,
"author": "Dan Adams",
"author_id": 13210554,
"author_profile": "https://Stackoverflow.com/users/13210554",
"pm_score": 1,
"selected": false,
"text": "geom_polygon()"
}
] | 2022/11/15 | [
"https://Stackoverflow.com/questions/74453519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13594821/"
] |
74,453,533 | <p>Is it possible to have MySQL return the number of rows looked at?</p>
<pre><code>SELECT * FROM `table` WHERE location like '%New York%' LIMIT 10
</code></pre>
<p>So in the example above, MySQL might loop through 30 rows in order to return these 10 results, this would indicate that the term "New York" is found approximately 1/3 of the time (assuming that the term is spread randomly). You could then tell the user that he can expect approx. X results before making him wait for the exact number. If there are ten million rows in the database then you could also assume that a count would take 1 million times longer than the above search and use that as the basis for a simple loading bar.</p>
| [
{
"answer_id": 74453620,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 1,
"selected": false,
"text": "mysql> flush status;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show session status like 'handler_read%next';\n+-----------------------+-------+\n| Variable_name | Value |\n+-----------------------+-------+\n| Handler_read_next | 0 |\n| Handler_read_rnd_next | 0 |\n+-----------------------+-------+\n2 rows in set (0.01 sec)\n\nmysql> select * from mytable where location like '%New York%' limit 10;\n+----+----------+\n| id | location |\n+----+----------+\n| 1 | New York |\n| 3 | New York |\n| 4 | New York |\n| 6 | New York |\n| 8 | New York |\n| 9 | New York |\n| 13 | New York |\n| 14 | New York |\n| 17 | New York |\n| 28 | New York |\n+----+----------+\n10 rows in set (0.00 sec)\n\nmysql> show session status like 'handler_read%next';\n+-----------------------+-------+\n| Variable_name | Value |\n+-----------------------+-------+\n| Handler_read_next | 0 |\n| Handler_read_rnd_next | 17 |\n+-----------------------+-------+\n"
}
] | 2022/11/15 | [
"https://Stackoverflow.com/questions/74453533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4688190/"
] |
74,453,534 | <p>I was trying to make a script that gets a .txt from a websites, pastes the code into a python executable temp file but its not working. Here is the code:</p>
<pre><code>from urllib.request import urlopen as urlopen
import os
import subprocess
import os
import tempfile
filename = urlopen("https://randomsiteeeee.000webhostapp.com/script.txt")
temp = open(filename)
temp.close()
# Clean up the temporary file yourself
os.remove(filename)
temp = tempfile.TemporaryFile()
temp.close()
</code></pre>
<p>If you know a fix to this please let me know. The error is :</p>
<pre><code> File "test.py", line 9, in <module>
temp = open(filename)
TypeError: expected str, bytes or os.PathLike object, not HTTPResponse
</code></pre>
<p>I tried everything such as a request to the url and pasting it but didnt work as well. I tried the code that i pasted here and didnt work as well.</p>
<p>And as i said, i was expecting it getting the code from the .txt from the website, and making it a temp executable python script</p>
| [
{
"answer_id": 74453558,
"author": "Lorenz Hetterich",
"author_id": 20473701,
"author_profile": "https://Stackoverflow.com/users/20473701",
"pm_score": 3,
"selected": true,
"text": "from urllib.request import urlopen as urlopen\nimport os\nimport subprocess\nimport os\nimport tempfile\n\nfilename = urlopen(\"https://randomsiteeeee.000webhostapp.com/script.txt\").read() # <-- here\ntemp = open(filename)\ntemp.close()\n # Clean up the temporary file yourself\nos.remove(filename)\n\ntemp = tempfile.TemporaryFile()\ntemp.close()\n"
},
{
"answer_id": 74453571,
"author": "Noscere",
"author_id": 10728583,
"author_profile": "https://Stackoverflow.com/users/10728583",
"pm_score": 0,
"selected": false,
"text": "filename = \"path/to/my/output/file.txt\"\nhttpresponse = urlopen(\"https://randomsiteeeee.000webhostapp.com/script.txt\").read()\ntemp = open(filename)\ntemp.write(httpresponse)\ntemp.close()\n"
}
] | 2022/11/15 | [
"https://Stackoverflow.com/questions/74453534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20514964/"
] |
74,453,563 | <p>I'm new to python. I have this code. I need to get a result as a json from postoffices, but it only tells that I don't have problems in my code like "Process finished with exit code 0". When I'm trying to <code>print(get_settlement_postoffices())</code>, it gives me the same answer.</p>
<pre><code>from __future__ import annotations
from datetime import datetime
import json
from typing import TYPE_CHECKING, List, Optional, Union
from pochta.enums import PostofficeWorkType
from pochta.utils import HTTPMethod
class Services:
def get_settlement_postoffices(self, settlement: str,
region: Optional[str] = None,
district: Optional[str] = None) -> List[str]:
url = '/postoffice/1.0/settlement.offices.codes'
params = {
'settlement': settlement,
'region': region,
'district': district,
}
res = self._client.request(HTTPMethod.GET, url, params=params)
return res.json()
</code></pre>
<p>I want to get an array with postal codes of a city I've chosen in a settlement param.</p>
| [
{
"answer_id": 74453558,
"author": "Lorenz Hetterich",
"author_id": 20473701,
"author_profile": "https://Stackoverflow.com/users/20473701",
"pm_score": 3,
"selected": true,
"text": "from urllib.request import urlopen as urlopen\nimport os\nimport subprocess\nimport os\nimport tempfile\n\nfilename = urlopen(\"https://randomsiteeeee.000webhostapp.com/script.txt\").read() # <-- here\ntemp = open(filename)\ntemp.close()\n # Clean up the temporary file yourself\nos.remove(filename)\n\ntemp = tempfile.TemporaryFile()\ntemp.close()\n"
},
{
"answer_id": 74453571,
"author": "Noscere",
"author_id": 10728583,
"author_profile": "https://Stackoverflow.com/users/10728583",
"pm_score": 0,
"selected": false,
"text": "filename = \"path/to/my/output/file.txt\"\nhttpresponse = urlopen(\"https://randomsiteeeee.000webhostapp.com/script.txt\").read()\ntemp = open(filename)\ntemp.write(httpresponse)\ntemp.close()\n"
}
] | 2022/11/15 | [
"https://Stackoverflow.com/questions/74453563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20514949/"
] |
74,453,574 | <p>I am plotting random points on a graph. I want to find the Eucildean distance from every point to another in a list.</p>
<p>Previous result/attempt can be viewed <a href="https://stackoverflow.com/questions/74216230/how-to-find-distance-between-lists-of-random-points-in-python">here</a></p>
<p>I generate 4 random numbers between 0 and 10 for the x and y coordinates, and then pair them using np.array. I need use distance formula and a nested loop to calculate the distance between two points in the list. This generates 8 values, which I assume is the distances. As there is 4 points, there should be 6 distances between the points.</p>
<p>Am I programming in the distance forumla incorrectly? Or am I defining the points incorrectly?</p>
<p>Code below</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
import random
import math
dist = []
x = [random.uniform(1, 10) for n in range(4)]
y = [random.uniform(1, 10) for n in range(4)]
plt.scatter(x, y)
plt.show()
pairs = np.array([x, y])
def distance(x, y):
return math.sqrt((x[0]-x[1])**2 + (y[0]-y[1])**2)
for x in pairs:
for y in pairs:
d = distance(x, y)
dist.append(d)
print(pairs)
</code></pre>
| [
{
"answer_id": 74453558,
"author": "Lorenz Hetterich",
"author_id": 20473701,
"author_profile": "https://Stackoverflow.com/users/20473701",
"pm_score": 3,
"selected": true,
"text": "from urllib.request import urlopen as urlopen\nimport os\nimport subprocess\nimport os\nimport tempfile\n\nfilename = urlopen(\"https://randomsiteeeee.000webhostapp.com/script.txt\").read() # <-- here\ntemp = open(filename)\ntemp.close()\n # Clean up the temporary file yourself\nos.remove(filename)\n\ntemp = tempfile.TemporaryFile()\ntemp.close()\n"
},
{
"answer_id": 74453571,
"author": "Noscere",
"author_id": 10728583,
"author_profile": "https://Stackoverflow.com/users/10728583",
"pm_score": 0,
"selected": false,
"text": "filename = \"path/to/my/output/file.txt\"\nhttpresponse = urlopen(\"https://randomsiteeeee.000webhostapp.com/script.txt\").read()\ntemp = open(filename)\ntemp.write(httpresponse)\ntemp.close()\n"
}
] | 2022/11/15 | [
"https://Stackoverflow.com/questions/74453574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20246634/"
] |
74,453,587 | <p>I've noticed a problem with splitting responsibilities in React components based on the fetched data using RTK Query.</p>
<p>Basically, I have two components like <code>HomePage</code> and <code>NavigationComponent</code>.
On <code>HomePage</code> I'd like to fetch the information about the user so that I can modify <code>NavigationComponent</code> accordingly.</p>
<p>What I do inside <code>HomePage</code>:</p>
<pre class="lang-js prettyprint-override"><code>import { setNavigationMode } from "features/nav/navSlice";
export default function HomePage() {
const {data: user} = useGetUserDataQuery();
const dispatch = useAppDispatch();
const navMode = user ? "all-options" : "none";
dispatch(setNavigationMode(navMode)); // here I change the default Navigation mode
return <MainLayout>
<Navigation/>
<Content/>
<Footer/>
</MainLayout>;
}
</code></pre>
<p>The <code>HomePage</code> is a special Page when the <code>NavigationComponent</code> shouldn't display any options for the not logged in user.
Other pages presents additional <code>Logo</code> and <code>Title</code> on <code>Nav</code>.</p>
<p>React communicates:</p>
<blockquote>
<p>Warning: Cannot update a component (<code>NavComponent</code>) while rendering a different component (<code>HomePage</code>). To locate the bad setState() call inside <code>HomePage</code>, follow the stack trace as described in <a href="https://reactjs.org/link/setstate-in-render" rel="nofollow noreferrer">https://reactjs.org/link/setstate-in-render</a></p>
</blockquote>
<p>Not sure what is the right way to follow.
Whether the state should be changed in GetUser query after it is loaded - that doesn't seem to be legit.</p>
| [
{
"answer_id": 74453558,
"author": "Lorenz Hetterich",
"author_id": 20473701,
"author_profile": "https://Stackoverflow.com/users/20473701",
"pm_score": 3,
"selected": true,
"text": "from urllib.request import urlopen as urlopen\nimport os\nimport subprocess\nimport os\nimport tempfile\n\nfilename = urlopen(\"https://randomsiteeeee.000webhostapp.com/script.txt\").read() # <-- here\ntemp = open(filename)\ntemp.close()\n # Clean up the temporary file yourself\nos.remove(filename)\n\ntemp = tempfile.TemporaryFile()\ntemp.close()\n"
},
{
"answer_id": 74453571,
"author": "Noscere",
"author_id": 10728583,
"author_profile": "https://Stackoverflow.com/users/10728583",
"pm_score": 0,
"selected": false,
"text": "filename = \"path/to/my/output/file.txt\"\nhttpresponse = urlopen(\"https://randomsiteeeee.000webhostapp.com/script.txt\").read()\ntemp = open(filename)\ntemp.write(httpresponse)\ntemp.close()\n"
}
] | 2022/11/15 | [
"https://Stackoverflow.com/questions/74453587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6656818/"
] |
74,453,607 | <p>I create a div containing some text with some simple css:</p>
<pre><code>.textBox {
display: inline-block;
font-size: 50px;
}
</code></pre>
<p>The container is simply:</p>
<pre><code><div class="textBox"> Test </div>
</code></pre>
<p>Nevertheless, the text isn't perfectly vertically centered within the div. There are 13px above and 11px below. Hence I would like the height of the div to be exactly as the height of the text.</p>
<p><a href="https://i.stack.imgur.com/cGOuB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cGOuB.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74453789,
"author": "HannibalTN",
"author_id": 13563196,
"author_profile": "https://Stackoverflow.com/users/13563196",
"pm_score": -1,
"selected": false,
"text": "height: fit-content;\n"
},
{
"answer_id": 74454362,
"author": "T-S",
"author_id": 17907084,
"author_profile": "https://Stackoverflow.com/users/17907084",
"pm_score": 2,
"selected": true,
"text": "line-height"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14181831/"
] |
74,453,614 | <p>I'm following Princeton's introductory computer science course (I'm not a student, just teaching myself). I working on this <a href="https://docs.google.com/document/d/1ysLYdL7pMSNk0nGsG7YFzj1IhwAhGu28edgt1Uma4s0/edit" rel="nofollow noreferrer">assignment</a>.</p>
<p>Main is calling two methods: amplify and reverse, both of which return an array. Amplify multiplies all values in the array by a constant alpha. Reverse returns an array that lists the original array values in reverse order, ex. {1,2,3} -> {3,2,1}.</p>
<p>Amplify works fine, but nothing happens when I call reverse and I get a bug that states: <a href="https://i.stack.imgur.com/RhHAz.png" rel="nofollow noreferrer">The Value Assigned Is Never Used</a></p>
<pre><code>public class audiocollage {
// Returns a new array that rescales a[] by a factor of alpha.
public static double[] amplify(double[] a, double alpha) {
for (int i = 0; i < a.length; i++) {
a[i] = a[i] * alpha;
}
return a;
}
// Returns a new array that is the reverse of a[].
public static double[] reverse(double[] a) {
double[] b = new double[a.length];
for (int i = a.length - 1, j = 0; i >= 0; i--, j++) {
b[j] = a[i];
}
return b;
}
// Creates an audio collage and plays it on standard audio.
public static void main(String[] args) {
double[] samples = StdAudio.read("cow.wav");
double alpha = 2.0;
samples = amplify(samples, alpha);
samples = reverse(samples);
}
}
</code></pre>
| [
{
"answer_id": 74453640,
"author": "Java Bird",
"author_id": 16612137,
"author_profile": "https://Stackoverflow.com/users/16612137",
"pm_score": -1,
"selected": false,
"text": "samples"
},
{
"answer_id": 74453725,
"author": "N B",
"author_id": 20515143,
"author_profile": "https://Stackoverflow.com/users/20515143",
"pm_score": 0,
"selected": false,
"text": "reverse(samples)"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16175917/"
] |
74,453,616 | <p>My connection config:</p>
<pre class="lang-java prettyprint-override"><code>@Configuration
@EnableR2dbcRepositories
public class DatabaseConfiguration extends AbstractR2dbcConfiguration {
@Bean
public PostgresqlConnectionFactory connectionFactory() {
return new PostgresqlConnectionFactory(PostgresqlConnectionConfiguration.builder()
.host("r2dbc:postgresql://mydb.alfa")
.port(5432)
.username("admin")
.database("postgres")
.password(password)
.build()
);
}
}
</code></pre>
<p>My repository:</p>
<pre class="lang-java prettyprint-override"><code>public interface ReactiveOdometerRepository extends ReactiveCrudRepository<OdometerEntity, String> {
Flux<OdometerEntity> findTop1By(String name);
}
</code></pre>
<p>My entity:</p>
<pre class="lang-java prettyprint-override"><code>@Setter
public class OdometerEntity {
@Getter
@Id
private String name;
@Getter
private int value;
}
</code></pre>
<p>When I try querying the DB, it fails:</p>
<pre class="lang-java prettyprint-override"><code>@PostMapping(value = "/query", produces = MediaType.APPLICATION_JSON_VALUE)
public int get(@RequestBody RequestObject request) {
return odometerRepository.findTop1ByName(request.getName()).getValue();
</code></pre>
<p>Error:</p>
<pre><code>io.r2dbc.postgresql.PostgresqlConnectionFactory$PostgresConnectionException:
Cannot connect to r2dbc:postgresql://mydb.alfa/<unresolved>:5432
</code></pre>
<p>Not sure what the <code>unresolved</code> is doing in there.</p>
<p>How do I fix this error? thanks</p>
| [
{
"answer_id": 74469354,
"author": "Hantsy",
"author_id": 893898,
"author_profile": "https://Stackoverflow.com/users/893898",
"pm_score": 1,
"selected": false,
"text": "\n PostgresqlConnectionFactory(\n PostgresqlConnectionConfiguration.builder()\n .host(\"localhost\")\n .database(\"blogdb\")\n .username(\"user\")\n .password(\"password\")\n .codecRegistrar(\n EnumCodec\n .builder()\n .withEnum(\"post_status\", Post.Status.class)\n .build()\n )\n .build()\n)\n"
},
{
"answer_id": 74471275,
"author": "M. Deinum",
"author_id": 2696260,
"author_profile": "https://Stackoverflow.com/users/2696260",
"pm_score": 1,
"selected": true,
"text": "host"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1218317/"
] |
74,453,619 | <p>I am trying to write an encryption - decryption programm, which uses gost89 to encrypt and decrypt data. Everything works fine, but when I try to cast QString to unsigned char and use it as a key, the programm fails to decrypt.</p>
<p>The code:</p>
<pre><code>#include <cstdio>
#include <iostream>
#include <openssl/conf.h>
#include <openssl/err.h>
#include <openssl/engine.h>
#include <openssl/evp.h>
#include <fstream>
#include <QString>
#include <QDebug>
#include <QFile>
using std::cerr;
using std::endl;
void encryptdata(QString pass, QString data){
OPENSSL_add_all_algorithms_conf();
ENGINE *engine_gost = ENGINE_by_id("gost");
const EVP_CIPHER * cipher_gost = EVP_get_cipherbyname("gost89");
unsigned char *key = (unsigned char * )"password";
qDebug() << (char*)key;
unsigned char * iv = (unsigned char * ) "12345678";
unsigned char *text = (unsigned char*)"Hello World";
int text_len = 11;
unsigned char ciph[512];
int ciph_len = 0;
EVP_CIPHER_CTX * ctx = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(ctx);
int init = EVP_EncryptInit_ex(ctx, cipher_gost, engine_gost, key, iv);
int enc = EVP_EncryptUpdate(ctx, ciph, &ciph_len, text, text_len);
std::ofstream myfile;
myfile.open ("example.bin");
for (int i = 0; i < text_len; i++){
myfile << ciph[i];
}
myfile.close();
EVP_CIPHER_CTX_free(ctx);
}
void decryptdata(){
OPENSSL_add_all_algorithms_conf();
ENGINE *engine_gost1 = ENGINE_by_id("gost");
const EVP_CIPHER * cipher_gost1 = EVP_get_cipherbyname("gost89");
unsigned char * key1 = (unsigned char * ) "password";
qDebug() << (char*)key1;
unsigned char * iv1 = (unsigned char * ) "12345678";
unsigned char text1[512];
int text_len1 = 11;
unsigned char ciph1[512];
int ciph_len1 = 0;
std::ifstream yourfile;
yourfile.open ("example.bin");
yourfile >> text1;
yourfile.close();
qDebug() << text1;
EVP_CIPHER_CTX * ctx1 = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(ctx1);
int init = EVP_DecryptInit_ex(ctx1, cipher_gost1, engine_gost1, key1, iv1);
int enc = EVP_DecryptUpdate(ctx1, ciph1, &ciph_len1, text1, text_len1);
//int enc1 = EVP_DecryptFinal(ctx, ciph, &ciph_len);
for (int i = 0; i < text_len1; i++){
std::cout << ciph1[i];
}
std::cout << std::endl;
EVP_CIPHER_CTX_free(ctx1);
}
int main(){
//unsigned char t[512] = {'p', 'a', 's', 's', 'w', 'o', 'r', 'd'};
QString pss = "password";
QString dat = "Hello World";
encryptdata(pss, dat);
decryptdata();
}
</code></pre>
<p>I've tried lots of different casting methods, but they did not help</p>
| [
{
"answer_id": 74469354,
"author": "Hantsy",
"author_id": 893898,
"author_profile": "https://Stackoverflow.com/users/893898",
"pm_score": 1,
"selected": false,
"text": "\n PostgresqlConnectionFactory(\n PostgresqlConnectionConfiguration.builder()\n .host(\"localhost\")\n .database(\"blogdb\")\n .username(\"user\")\n .password(\"password\")\n .codecRegistrar(\n EnumCodec\n .builder()\n .withEnum(\"post_status\", Post.Status.class)\n .build()\n )\n .build()\n)\n"
},
{
"answer_id": 74471275,
"author": "M. Deinum",
"author_id": 2696260,
"author_profile": "https://Stackoverflow.com/users/2696260",
"pm_score": 1,
"selected": true,
"text": "host"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429204/"
] |
74,453,637 | <p>Run into sql code with a lot of <code>when</code>:</p>
<pre><code>case
when callDuration > 0 and callDuration < 30 then 1.4
when callDuration >= 30 and callDuration < 60 then 2.3
when callDuration >= 60 and callDuration < 120 then 3.7
when callDuration >= 120 and callDuration < 180 then 4.5
when callDuration >= 180 and callDuration < 240 then 5.2
when callDuration >= 240 and callDuration < 300 then 6.1
when callDuration >= 300 and callDuration < 360 then 7.3
when callDuration >= 360 and callDuration < 420 then 8.4
when callDuration >= 420 and callDuration < 480 then 9.2
when callDuration >= 480 and callDuration < 540 then 10.1
when callDuration >= 540 and callDuration < 600 then 11.9
when callDuration >= 600 then 12.3
end as duration
</code></pre>
<p>If there are 100 lines of this kinds of when and then, how to simplify it and more elegant, I can think use Jinjia Template or with a lookup table. Any better approach, not restrict by specific variant?</p>
| [
{
"answer_id": 74453752,
"author": "Menelaos",
"author_id": 1688441,
"author_profile": "https://Stackoverflow.com/users/1688441",
"pm_score": 2,
"selected": false,
"text": "create table lookupTable(\nstartCallDuration int,\nendCallDuration int,\nreturnValue float);\n\ninsert into lookupTable values (0,30,1.4);\ninsert into lookupTable values (30,60,2.3);\ninsert into lookupTable values (60,120,3.7);\ninsert into lookupTable values (120,999999999,4.5);\n\ncreate table callDuration(\ncallDuration int );\n\ninsert into callDuration values (30);\ninsert into callDuration values (60);\n"
},
{
"answer_id": 74454501,
"author": "Mikhail Berlyant",
"author_id": 5221944,
"author_profile": "https://Stackoverflow.com/users/5221944",
"pm_score": 1,
"selected": false,
"text": "with lookup_table as (\n select \n [0, 30, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600] ranges,\n [1.4, 2.3, 3.7, 4.5, 5.2, 6.1, 7.3, 8.4, 9.2, 10.1, 11.9, 12.3] choice\n)\nselect callDuration, choice[safe_offset(range_bucket(callDuration, ranges) - 1)] as duration\nfrom your_table, lookup_table \n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/306237/"
] |
74,453,774 | <p>I am trying to add and change extended properties of devices registered in AzureAD using C#.
But I am getting the following error, I don't know why...</p>
<p>Below is the part about the Graph API call. I used the document provided by MS Docs as it is, and it works normally in Graph API Explorer.</p>
<p><strong>[C# Code]</strong></p>
<pre><code>var device = await graphclient.Devices
.Request()
.Filter(ftr)
.Select("Id")
.GetAsync();
string objectId = device.CurrentPage.First().Id.ToString().Trim();
var extattr = new Device
{
AdditionalData = new Dictionary<string, object>(){
{"extensionAttributes", "{\"extensionAttribute1\":\"BYOD-Device2\"}"}
}
};
await graphclient.Devices[objectId]
.Request()
.UpdateAsync(extattr);
</code></pre>
<p><strong>[ErrorCode]</strong></p>
<pre><code>Status Code: BadRequest
Microsoft.Graph.ServiceException: Code: Request_BadRequest
Message: A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'extensionAttributes'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.
</code></pre>
<p>The current situation is that extensionAttribute1 has the value 'BYOD-Device'.</p>
<p>Is there anyone out there who can help me solve this error?</p>
| [
{
"answer_id": 74453752,
"author": "Menelaos",
"author_id": 1688441,
"author_profile": "https://Stackoverflow.com/users/1688441",
"pm_score": 2,
"selected": false,
"text": "create table lookupTable(\nstartCallDuration int,\nendCallDuration int,\nreturnValue float);\n\ninsert into lookupTable values (0,30,1.4);\ninsert into lookupTable values (30,60,2.3);\ninsert into lookupTable values (60,120,3.7);\ninsert into lookupTable values (120,999999999,4.5);\n\ncreate table callDuration(\ncallDuration int );\n\ninsert into callDuration values (30);\ninsert into callDuration values (60);\n"
},
{
"answer_id": 74454501,
"author": "Mikhail Berlyant",
"author_id": 5221944,
"author_profile": "https://Stackoverflow.com/users/5221944",
"pm_score": 1,
"selected": false,
"text": "with lookup_table as (\n select \n [0, 30, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600] ranges,\n [1.4, 2.3, 3.7, 4.5, 5.2, 6.1, 7.3, 8.4, 9.2, 10.1, 11.9, 12.3] choice\n)\nselect callDuration, choice[safe_offset(range_bucket(callDuration, ranges) - 1)] as duration\nfrom your_table, lookup_table \n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515096/"
] |
74,453,783 | <p>I am submitting the report "FAGL_ACCOUNT_ITEMS_GL" from a custom report on alv_user_command. From my report, I am unable to pass the FAGLL03 free selections.</p>
<pre><code>trange_line-tablename = 'ACDOCA_FS'.
trange_frange_t_line-fieldname = 'RMVCT'.
trange_frange_t_selopt_t_line-sign = 'I'.
trange_frange_t_selopt_t_line-option = 'EQ'.
trange_frange_t_selopt_t_line-low = 'Z20'.
APPEND trange_frange_t_selopt_t_line
TO trange_frange_t_line-selopt_t.
APPEND trange_frange_t_line TO trange_line-frange_t.
APPEND trange_line TO trange.
CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_EX'
EXPORTING
field_ranges = trange
IMPORTING
expressions = lt_texpr.
SUBMIT fagl_account_items_gl
VIA SELECTION-SCREEN
WITH SELECTION-TABLE lt_rspar
WITH x_opsel EQ abap_false
WITH x_aisel EQ abap_true
WITH FREE SELECTIONS lt_texpr
AND RETURN.
</code></pre>
<p>Let me know if i am missing something.</p>
| [
{
"answer_id": 74485924,
"author": "phil soady",
"author_id": 1347784,
"author_profile": "https://Stackoverflow.com/users/1347784",
"pm_score": 0,
"selected": false,
"text": "with selection-table"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11902049/"
] |
74,453,801 | <p>First of all I'm still new to Power bi and Dax so please bear with me on this. Thank you</p>
<p>I want to add a new calculated column called Product Type and this will be based on per location.</p>
<p>On the sample table that I have below</p>
<p>product code aaa123 has 3 records with 3 different movement dates and 3 different locations.</p>
<p>I want to get the most recent movement date for product aaa123, then if the location is NSW then product A, if WA then product B</p>
<p>any suggestions?</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Product Code</th>
<th>Movement Date</th>
<th>To Location</th>
</tr>
</thead>
<tbody>
<tr>
<td>aaa123</td>
<td>12 Nov 2022</td>
<td>NSW</td>
</tr>
<tr>
<td>aaa123</td>
<td>31 Oct 2022</td>
<td>ACT</td>
</tr>
<tr>
<td>aaa123</td>
<td>15 Nov 2022</td>
<td>WA</td>
</tr>
<tr>
<td>bbb123</td>
<td>10 Nov 2022</td>
<td>NSW</td>
</tr>
<tr>
<td>bbb123</td>
<td>14 Nov 2022</td>
<td>NSW</td>
</tr>
<tr>
<td>bbb123</td>
<td>01 Nov 2022</td>
<td>WA</td>
</tr>
<tr>
<td>ccc123</td>
<td>31 Oct 2022</td>
<td>WA</td>
</tr>
<tr>
<td>ccc123</td>
<td>01 Nov 2022</td>
<td>VIC</td>
</tr>
<tr>
<td>ccc123</td>
<td>02 Nov 2022</td>
<td>QLD</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<p>I was thinking of using the LASTDATE and IF DAX functions but I don't know how to proceed. Any suggestions?</p>
| [
{
"answer_id": 74455187,
"author": "AmilaMGunawardana",
"author_id": 10583434,
"author_profile": "https://Stackoverflow.com/users/10583434",
"pm_score": 0,
"selected": false,
"text": "Product = \nIF (\n 'sample data'[Is Latest] = 1,\n IF (\n 'sample data'[To Location] = \"NSW\",\n \"Product A\",\n IF ( 'sample data'[To Location] = \"WA\", \"Product B\", BLANK () )\n ),\n BLANK ()\n)\n"
},
{
"answer_id": 74455655,
"author": "Jos Woolley",
"author_id": 17007704,
"author_profile": "https://Stackoverflow.com/users/17007704",
"pm_score": 2,
"selected": true,
"text": "=\nVAR ThisProductCode = Table1[Product Code]\nVAR LatestDate =\n CALCULATE(\n MAX( Table1[Movement Date] ),\n FILTER(\n Table1,\n Table1[Product Code] = ThisProductCode\n )\n )\nVAR LatestLocation =\n CALCULATE(\n MAX( Table1[To Location] ),\n FILTER(\n Table1,\n Table1[Product Code] = ThisProductCode\n && Table1[Movement Date] = LatestDate\n )\n )\nRETURN\n SWITCH(\n LatestLocation,\n \"NSW\", \"Product A\",\n \"WA\", \"Product B\"\n )\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10247544/"
] |
74,453,820 | <p>I have a Google Sheets spreadsheet and I am hoping to write a formula that finds the location of a given phrase <em>anywhere</em> in the spreadsheet and then returns the value of the cell a certain number of cells below the searched-for cell. For example, if I am searching for the value "11/15/2022", and that cell is C4, I would want to return the value of cell C6. I have tried using <code>HLOOKUP()</code>, but that limits my search range to a single row, and I need to be able to search anywhere in the spreadsheet (and the data has dimensions that are both greater than one).</p>
<p>Is there a function (either Excel or Google Sheets) that will perform this? Any help is much appreciated!</p>
| [
{
"answer_id": 74454016,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 3,
"selected": true,
"text": "=INDEX(TEXTJOIN(, 1, IF(B1:F10=A1, B3:F12, )))\n"
},
{
"answer_id": 74454603,
"author": "Ping",
"author_id": 20288037,
"author_profile": "https://Stackoverflow.com/users/20288037",
"pm_score": 0,
"selected": false,
"text": "=LAMBDA(LOOKUPVALUE,ROWOFFSET,COLOFFSET,DATA,\n LAMBDA(ROWA,COLA,\n LAMBDA(COLLEN,ROWLEN,\n UNIQUE(FLATTEN(MAKEARRAY(ROWLEN,COLLEN,LAMBDA(ROW,COL,\n LAMBDA(CELLVALUE,\n IF(CELLVALUE=LOOKUPVALUE,INDEX(DATA,ROW+ROWOFFSET,COL+COLOFFSET),\"\")\n )(INDEX(DATA,ROW,COL))\n ))),FALSE,TRUE)\n )(COUNTBLANK(ROWA)+COUNTA(ROWA),COUNTBLANK(COLA)+COUNTA(COLA))\n )(INDEX(DATA,1),INDEX(DATA,,1))\n)($H$1,$H$2,$H$3,$A$1:$F)\n"
},
{
"answer_id": 74455591,
"author": "David Leal",
"author_id": 6237093,
"author_profile": "https://Stackoverflow.com/users/6237093",
"pm_score": 1,
"selected": false,
"text": "H2"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12905119/"
] |
74,453,866 | <p>I'm building a simple review app with react and redux toolkit. <br></p>
<p>Reviews are added via a form in <code>AddReview.js</code>, and I'm wanting to display these reviews in <code>Venue.js</code>. <br></p>
<p>When I submit a review in <code>AddReview.js</code>, the new review is added to state, as indicated in redux dev tools:</p>
<p><a href="https://i.stack.imgur.com/5B7qG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5B7qG.png" alt="enter image description here" /></a></p>
<p>However when I try to pull that state from the store in <code>Venue.js</code>, I only get the initial state (the first two reviews), and not the state I've added via the submit form:</p>
<p><a href="https://i.stack.imgur.com/FKoY2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FKoY2.png" alt="enter image description here" /></a></p>
<p>Can anyone suggest what's going wrong here?</p>
<p>Here's how I've set up my store:</p>
<p><code>store.js</code></p>
<pre><code>import { configureStore } from "@reduxjs/toolkit";
import reviewReducer from '../features/venues/venueSlice'
export const store = configureStore({
reducer:{
reviews: reviewReducer
}
})
</code></pre>
<p>Here's the slice managing venues/reviews:</p>
<p><code>venueSlice.js</code></p>
<pre><code>import { createSlice } from "@reduxjs/toolkit";
const initialState = [
{id:1, title: 'title 1',blurb: 'blurb 1'},
{id:2, title: 'title 2',blurb: 'blurb 2'}
]
const venueSlice = createSlice({
name: 'reviews',
initialState,
reducers: {
ADD_REVIEW: (state,action) => {
state.push(action.payload)
}
}
})
export const { ADD_REVIEW } = venueSlice.actions
export default venueSlice.reducer
</code></pre>
<p>And here's the <code>Venue.js</code> component where I want to render reviews:</p>
<pre><code>import { useParams } from "react-router-dom";
import { useSelector } from "react-redux";
const Venue = () => {
const { id } = useParams()
const reviews = useSelector((state) => state.reviews)
console.log(reviews)
return (
<div>
{reviews.map(item => (
<h1>{item.title}</h1>
))}
</div>
)
}
export default Venue;
</code></pre>
<p>Form component <code> AddReview.js</code></p>
<pre><code>import { useState } from "react"
import { useDispatch } from "react-redux"
import { ADD_REVIEW } from "./venueSlice"
import { nanoid } from "@reduxjs/toolkit"
const AddReview = () => {
const [ {title,blurb}, setFormDetails ] = useState({title:'', blurb: ''})
const dispatch = useDispatch()
const handleChange = (e) => {
const { name, value } = e.target
setFormDetails(prevState => ({
...prevState,
[name]: value
}))
}
const handleSubmit = (e) => {
console.log('it got here')
e.preventDefault()
if(title && blurb){
dispatch(ADD_REVIEW({
id: nanoid(),
title,
blurb
}))
// setFormDetails({title: '', blurb: ''})
}
}
return(
<div>
<form onSubmit={handleSubmit}>
<input
type = 'text'
name = 'title'
onChange={handleChange}
/>
<input
type = 'text'
name = 'blurb'
onChange={handleChange}
/>
<button type = "submit">Submit</button>
</form>
</div>
)
}
export default AddReview;
</code></pre>
| [
{
"answer_id": 74456837,
"author": "Manish Kumar",
"author_id": 3442619,
"author_profile": "https://Stackoverflow.com/users/3442619",
"pm_score": 0,
"selected": false,
"text": "react-redux"
},
{
"answer_id": 74461441,
"author": "electroid",
"author_id": 1078641,
"author_profile": "https://Stackoverflow.com/users/1078641",
"pm_score": 1,
"selected": false,
"text": "import { createSlice } from \"@reduxjs/toolkit\";\n\nconst initialState = [\n reviews: [{id:1, title: 'title 1',blurb: 'blurb 1'},\n {id:2, title: 'title 2',blurb: 'blurb 2'}]\n]\n\nconst venueSlice = createSlice({\n name: 'reviews',\n initialState,\n reducers: {\n ADD_REVIEW: (state,action) => {\n state.reviews = state.reviews.concat(action.payload);\n }\n }\n})\n\nexport const { ADD_REVIEW } = venueSlice.actions\n\nexport default venueSlice.reducer\n"
},
{
"answer_id": 74545158,
"author": "Berci",
"author_id": 6429674,
"author_profile": "https://Stackoverflow.com/users/6429674",
"pm_score": 0,
"selected": false,
"text": " ADD_REVIEW: (state,action) => {\n state = [...state, action.payload];\n }\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13611429/"
] |
74,453,893 | <p>I have two APIs referencing the POJO class below.</p>
<pre><code>class Data{
private String name;
private String age;
private String address;
private String phone_number;
}
</code></pre>
<p>I need to annotate the fields in this POJO as below.</p>
<pre><code>class Data
{
@JsonProperty(required = true)
private String name; // required field
@JsonProperty(required = true)
private String age; // required field
@JsonInclude( Include.Non_Null)
private String address; // optional field
@JsonIgnore
private String phone_number; // ignore field
}
</code></pre>
<p>The annotations need to be applied to only one of API.The other API should not be impacted by this change.</p>
<p>One way of achieving this is to create two separate POJOs, one for each API. But is it possible to achieve the results using the same POJO classes? Is there a way to configure the annotations based on which API is being invoked?</p>
| [
{
"answer_id": 74456837,
"author": "Manish Kumar",
"author_id": 3442619,
"author_profile": "https://Stackoverflow.com/users/3442619",
"pm_score": 0,
"selected": false,
"text": "react-redux"
},
{
"answer_id": 74461441,
"author": "electroid",
"author_id": 1078641,
"author_profile": "https://Stackoverflow.com/users/1078641",
"pm_score": 1,
"selected": false,
"text": "import { createSlice } from \"@reduxjs/toolkit\";\n\nconst initialState = [\n reviews: [{id:1, title: 'title 1',blurb: 'blurb 1'},\n {id:2, title: 'title 2',blurb: 'blurb 2'}]\n]\n\nconst venueSlice = createSlice({\n name: 'reviews',\n initialState,\n reducers: {\n ADD_REVIEW: (state,action) => {\n state.reviews = state.reviews.concat(action.payload);\n }\n }\n})\n\nexport const { ADD_REVIEW } = venueSlice.actions\n\nexport default venueSlice.reducer\n"
},
{
"answer_id": 74545158,
"author": "Berci",
"author_id": 6429674,
"author_profile": "https://Stackoverflow.com/users/6429674",
"pm_score": 0,
"selected": false,
"text": " ADD_REVIEW: (state,action) => {\n state = [...state, action.payload];\n }\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13809107/"
] |
74,453,897 | <p>I can't seem to activate Cache-Control <code>max-age</code> in an Azure storage blob in Python via the following code:</p>
<pre><code> contentSettings = ContentSettings(cache_control="max-age=86400")
containerClient.upload_blob(blobname, theBytes, length=byteCount,
overwrite=True, content_settings=contentSettings)
</code></pre>
<p>In the web based Azure storage browser, it appears <code>max-age</code> is correctly set:
<a href="https://i.stack.imgur.com/6egmx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6egmx.png" alt="Azure storage browser" /></a></p>
<p>However, <code>max-age</code> doesn't seem to be propagated to a browser client when the blob is downloaded. The file is downloaded correctly but is never cached in the client. If it matters, I'm using to axios to retrieve the file:</p>
<pre><code>axios.get(url, { responseType: "arraybuffer" })...
</code></pre>
<p>Here's the chrome developer network view of the file. Notice <code>max-age</code> is missing:</p>
<p><a href="https://i.stack.imgur.com/Aqh8m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Aqh8m.png" alt="Chrome" /></a></p>
<p>One other oddity: The Azure doc for <code>ContentSettings</code> contains the phrase:
<em>If the cache_control has previously been set for the blob, that value is stored.</em> Which means what exactly?</p>
<p>What am I doing wrong?</p>
| [
{
"answer_id": 74456837,
"author": "Manish Kumar",
"author_id": 3442619,
"author_profile": "https://Stackoverflow.com/users/3442619",
"pm_score": 0,
"selected": false,
"text": "react-redux"
},
{
"answer_id": 74461441,
"author": "electroid",
"author_id": 1078641,
"author_profile": "https://Stackoverflow.com/users/1078641",
"pm_score": 1,
"selected": false,
"text": "import { createSlice } from \"@reduxjs/toolkit\";\n\nconst initialState = [\n reviews: [{id:1, title: 'title 1',blurb: 'blurb 1'},\n {id:2, title: 'title 2',blurb: 'blurb 2'}]\n]\n\nconst venueSlice = createSlice({\n name: 'reviews',\n initialState,\n reducers: {\n ADD_REVIEW: (state,action) => {\n state.reviews = state.reviews.concat(action.payload);\n }\n }\n})\n\nexport const { ADD_REVIEW } = venueSlice.actions\n\nexport default venueSlice.reducer\n"
},
{
"answer_id": 74545158,
"author": "Berci",
"author_id": 6429674,
"author_profile": "https://Stackoverflow.com/users/6429674",
"pm_score": 0,
"selected": false,
"text": " ADD_REVIEW: (state,action) => {\n state = [...state, action.payload];\n }\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/177449/"
] |
74,453,902 | <p>So I wrote some code to turn a list of strings into date times:</p>
<pre><code>s = pd.Series(["14 Nov 2020", "14/11/2020", "2020/11/14",
"Hello World", "Nov 14th, 2020"])
s_dates = pd.to_datetime(s, errors='coerce', exact=False)
print(s_dates)
</code></pre>
<p>It produced the following output:</p>
<pre><code>0 2020-11-14
1 2020-11-14
2 2020-11-14
3 NaT
4 2020-11-14
dtype: datetime64[ns]
</code></pre>
<p>How would I obtain just the year from this?</p>
| [
{
"answer_id": 74453918,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 0,
"selected": false,
"text": "str.extract"
},
{
"answer_id": 74453944,
"author": "anas laaroussi",
"author_id": 12469248,
"author_profile": "https://Stackoverflow.com/users/12469248",
"pm_score": 2,
"selected": false,
"text": "s_dates"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20362623/"
] |
74,453,905 | <p>it is a dummy question, but I need to understand it more deeply</p>
| [
{
"answer_id": 74453946,
"author": "Noscere",
"author_id": 10728583,
"author_profile": "https://Stackoverflow.com/users/10728583",
"pm_score": -1,
"selected": false,
"text": " 1110"
},
{
"answer_id": 74454157,
"author": "Silvio Mayolo",
"author_id": 2288659,
"author_profile": "https://Stackoverflow.com/users/2288659",
"pm_score": 2,
"selected": true,
"text": "00001110"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6630011/"
] |
74,453,958 | <p><a href="https://www.youtube.com/watch?v=hEx5DNLWGgA" rel="nofollow noreferrer">CppCon 2015: Herb Sutter "Writing Good C++14... By Default" Slide 50</a></p>
<p><a href="https://coliru.stacked-crooked.com/a/8e52369a476b30c0" rel="nofollow noreferrer">Live on Coliru</a></p>
<p>I have seen the following guideline through above talk. However, I have hard time to understand the critical issues both solutions try to solve in the first place. All comments on the right side of the code are copied from original talk. Yes, I don't understand the comments on the slide either.</p>
<pre><code>void f(int*);
void g(shared_ptr<int>&, int*);
shared_ptr<int> gsp = make_shared<int>();
int main()
{
// Issue 1>
f(gsp.get()); // ERROR, arg points to gsp', and gsp is modifiable by f
// Solution 1>
auto sp = gsp;
f(sp.get()); // ok. arg points to sp', and sp is not modifiable by f
// Issue 2>
g(sp, sp.get()); // ERROR, arg2 points to sp', and sp is modifiable by f
// Solution 2>
g(gsp, sp.get()); // ok, arg2 points to sp', and sp is not modifiable by f
}
</code></pre>
<p>Can someone please give me some advices what the problems are if we write code shown in Issue 1 and Issue 2 and why the solutions fix the problems?</p>
| [
{
"answer_id": 74454045,
"author": "Nicol Bolas",
"author_id": 734069,
"author_profile": "https://Stackoverflow.com/users/734069",
"pm_score": 4,
"selected": true,
"text": "f"
},
{
"answer_id": 74454065,
"author": "Silvio Mayolo",
"author_id": 2288659,
"author_profile": "https://Stackoverflow.com/users/2288659",
"pm_score": 3,
"selected": false,
"text": "T*"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391104/"
] |
74,453,973 | <p>I'm having trouble with React Navigation on React Native Expo.</p>
<p>I have a bottom tab navigator, a separate screen (ProfileScreen), and a modal (ProfileLoginModal). The modal has a button that should redirect ProfileScreen. I put <code>navigation.navigate("ProfileScreen")</code> in the modal, but it's not doing anything, it's not even giving me an error.</p>
<p>But if I change it to one of the screens in the bottom tab nav, for example <code>navigation.navigate("Root", {screen: "HomeScreen})</code>, it works just fine. It just doesn't work with screens outside the bottom tab nav.</p>
<p>Can anyone please help me understand what I'm doing wrong?</p>
<p>Navigation structure:</p>
<pre><code>- BottomTabNavigator (Root)
- HomeScreen
- MenuScreen
- ProfileScreen
- ProfileLoginModal
</code></pre>
<p>Here is my navigation:</p>
<pre><code>const Stack = createNativeStackNavigator<RootStackParamList>();
<NavigationContainer linking={LinkingConfiguration}>
<Stack.Navigator>
<Stack.Screen
name="Root"
component={BottomTabNavigator}
/>
<Stack.Screen
name="ProfileScreen" // ProfileScreen (destination)
component={ProfileScreen}
/>
<Stack.Group screenOptions={{ presentation: 'modal' }}>
<Stack.Screen
name="ProfileLoginModal" // Go to ProfileScreen from this modal
component={ProfileLoginModal}
/>
</Stack.Group>
</Stack.Navigator>
</NavigationContainer>
const BottomTab = createBottomTabNavigator<RootTabParamList>();
function BottomTabNavigator() {
return (
<BottomTab.Navigator
initialRouteName="HomeScreen"
screenOptions={...}
>
<BottomTab.Screen
name="HomeScreen"
component={HomeScreen}
options={...}
/>
<BottomTab.Screen
name="Menu"
component={MenuScreen}
options={...}
/>
</BottomTab.Navigator>
);
}
</code></pre>
<p>Typings:</p>
<pre><code>export type RootStackParamList = {
Root: NavigatorScreenParams<RootTabParamList> | undefined;
ProfileScreen: undefined;
ProfileLoginModal: undefined;
};
export type RootStackScreenProps<Screen extends keyof RootStackParamList> =
NativeStackScreenProps<RootStackParamList, Screen>;
export type RootTabParamList = {
HomeScreen: undefined;
MenuScreen: undefined;
};
export type RootTabScreenProps<Screen extends keyof RootTabParamList> =
CompositeScreenProps<
BottomTabScreenProps<RootTabParamList, Screen>,
NativeStackScreenProps<RootStackParamList>
>;
</code></pre>
<p>Extra detail: I'd like ProfileScreen to have the bottom tab navigator visible, but with no corresponding tab icon.</p>
<p>I tried to make a nested navigator containing HomeScreen and ProfileScreen, like this</p>
<pre><code>- BottomTabNavigator (Root)
- NestedHome
- HomeScreen
- ProfileScreen
- MenuScreen
- ProfileLoginModal
</code></pre>
<p>But I had a lot of issues as I didn't know how to access double nested screens, if even possible (<code>navigation.navigate('Root', screen: {'NestedHome', screen: {'ProfileScreen'}})</code> is clearly incorrect). I couldn't find much info about it.</p>
<p>Thanks for your help.</p>
| [
{
"answer_id": 74454045,
"author": "Nicol Bolas",
"author_id": 734069,
"author_profile": "https://Stackoverflow.com/users/734069",
"pm_score": 4,
"selected": true,
"text": "f"
},
{
"answer_id": 74454065,
"author": "Silvio Mayolo",
"author_id": 2288659,
"author_profile": "https://Stackoverflow.com/users/2288659",
"pm_score": 3,
"selected": false,
"text": "T*"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19530838/"
] |
74,453,988 | <p>I am hoping somebody can help me with what I'm trying to do.</p>
<p>So I'm fetching an API endpoint that returns sets of data which is fine, but what
What I like to do is to use all campaignid parameter values and make an api call one-by-one to retrieve each campaignid value's results so it would use each id from the campaignid and makes an api call, obviously the end point for the other call would be different. Just wondering how do I do that dynamically</p>
<pre><code>import { useState, useEffect } from "react";
const url = "https://6271dd6bc455a64564b8b6b6.mockapi.io/AP1/REST/Numberofsubmissons";
export default function App() {
const [data, setData] = useState([]);
console.log(data);
useEffect(() => {
fetch(url)
.then((response) => response.json())
.then((data) => setData(data))
}, []);
return (
<>
<code>{JSON.stringify(data)}</code>
</>
);
}
</code></pre>
| [
{
"answer_id": 74454186,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 2,
"selected": false,
"text": "campaignid"
},
{
"answer_id": 74454192,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 2,
"selected": true,
"text": "useEffect"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74453988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/622639/"
] |
74,454,005 | <pre><code>#This is my string known as "greeting".
greeting = "hello how are you, what?"
#This prints the greeting the normal way.
print(greeting.title())
#This prints the greeting backwards and excluding the chosen letter "h" on the outside.
print (greeting.title()[:greeting.find("h"):-1] + greeting[greeting.rfind("h")-1:5])
</code></pre>
<p>How do I make this print out the greeting, excluding the outside letter "h", but leaving the inside letter "h" where it is.</p>
<p>I need the output to be:</p>
<pre><code>"Hello How Are You, What?"
"W ,uoY erA woH olle"
</code></pre>
<p>With my current code output is:</p>
<pre><code>"Hello How Are You, What?"
"?tahW ,uoY erA woH olle"
</code></pre>
<p>I just need the '?tah" to be gone.</p>
| [
{
"answer_id": 74454186,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 2,
"selected": false,
"text": "campaignid"
},
{
"answer_id": 74454192,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 2,
"selected": true,
"text": "useEffect"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20354594/"
] |
74,454,026 | <p>I have a <code>.txt</code> file that was saved with python. It has the form:</p>
<p><a href="https://i.stack.imgur.com/e3piQ.png" rel="nofollow noreferrer">file_inputs</a></p>
<p>Where the first line is just a title that helps me remember the order of each element that was saved and the second line is a sequence of a string ('eos') and other elements inside. How can I call the elements so that <code>inputs[0]</code> returns a string ('eos') and <code>inputs[1]</code> returns the number "5", for example?</p>
| [
{
"answer_id": 74454186,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 2,
"selected": false,
"text": "campaignid"
},
{
"answer_id": 74454192,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 2,
"selected": true,
"text": "useEffect"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17275343/"
] |
74,454,034 | <p>I'm trying to make a webpage and I want to condense some of the HTML and respective code into a react components, but I can't seem to do this without creating an entire react app, which is undesired for this project. I have followed the steps in the react documentation to add a JSX preprocessor and then render the react component into the page using script tag, but nothing shows up.</p>
<p>In the console in the page, it just says <code>Uncaught ReferenceError: require is not defined</code>. I tried using browserify to compile all of the react libraries to one file, but it said <code>Error: Can't walk dependency graph: Cannot find module 'reactjs' from '/home/user/code/website/src/slideshow.js'</code>. If I try and npm install reactjs it installs react, and neither give any definitions or descriptions for the react classes when editing the code.</p>
<p>I'm kind of lost, and completely willing to look like an idiot. My HTML and JS is below.</p>
<pre><code>const { React, ReactDOM } = require('react');
const root = ReactDOM.createRoot(document.getElementById("slideshowContainer"));
class Slideshow extends React.Component {
constructor(props) {
super(props);
this.state = {
slide: 1,
}
this.slides = {
1: {
src: './assets/coding.jpeg',
caption: "this is slide 1."
},
2: {
src: './assets/coding2.jpeg',
caption: "this is slide 2."
},
3: {
src: './assets/templimg.jpg',
caption: "this is slide 3."
}
}
}
slideTransitionPrev() {
let ok = Object.keys(this.slides);
if (this.state.slide === 1) {
this.setState({ slide: ok });
} else {
this.setState({ slide: this.state.slide - 1 });
}
}
slideTransitionNext() {
let ok = Object.keys(this.slides);
if (this.state.slide === ok) {
this.setState({ slide: 1 });
} else {
this.setState({ slide: this.state.slide + 1 });
}
}
render() {
return (
<div class="slides fade">
<span class="slidePosition">{this.state.slide} / {Object.keys(this.slides)}</span>
<img style="width: 100%" src={this.slides[this.state.slide].src} />
<button class="prev" onClick={() => this.slideTransitionPrev()}>&#10094;</button>
<button class="next" onClick={() => this.slideTransitionNext()}>&#10095;</button>
<span class="caption">{this.slides[this.state.slide].caption}</span>
</div>
)
}
}
root.render(<Slideshow />);
</code></pre>
<pre><code>(boring necessary html stuff)
<body>
<div id="slideshowContainer"></div>
<script src="./src/slideshow.js"></script>
</body>
</code></pre>
| [
{
"answer_id": 74454186,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 2,
"selected": false,
"text": "campaignid"
},
{
"answer_id": 74454192,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 2,
"selected": true,
"text": "useEffect"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20501327/"
] |
74,454,047 | <p>I need to run over 600 regressions, each on a different MECE group of the data (group takes values {1,2,...,623}). From each regression, I need to store coefficient estimates for all independent variables. I was able to do this by looping through regressions (see below); but, I'm finding this quite slow and I believe there is a better way:</p>
<pre><code># loop prep
formula <- "dv ~ iv_1 + iv_2 + iv_3 | fe"
ols_stored_coef <- matrix(0, 623, 3)
ols_stored_coef <- as.data.frame(ols_stored_coef )
# loop
for(i in 1:623) {
#run regression:
ols <- feols(as.formula(formula), subset(df, group==i))
# generate coefficients:
ols_coef <- summary(ols)$coefficients
ols_coef <- data.frame(as.list(ols_coef))
# store coefficients:
ols_stored_coef[i,1] = ols_coef[1,1]
ols_stored_coef[i,2] = ols_coef[1,2]
ols_stored_coef[i,3] = ols_coef[1,3]
}
</code></pre>
<p>This works, but it takes about 10 minutes to run (there are around 6 million observations and 623 MECE groups). However, I know that the following command estimates all 623 regressions in about 1 minute:</p>
<pre><code>ols_split <- feols(as.formula(formula), df, split=~group)
</code></pre>
<p>Regression data is stored all together in a single "List of 623." I am able to extract coefficients per group via the following, where X is the group value.</p>
<pre><code>ols_split $`sample.var: store; sample: X`$coefficients
</code></pre>
<p>In an ideal world, I could run this split feols(), and then store the coefficients via looping:</p>
<pre><code>for(i in 1:623) {
ols_coef <- ols_split $`sample.var: store; sample: i`$coefficients
ols_coef <- data.frame(as.list(ols_coef))
# store coefficients:
ols_stored_coef[i,1] = ols_coef[1,1]
ols_stored_coef[i,2] = ols_coef[1,2]
ols_stored_coef[i,3] = ols_coef[1,3]
}
</code></pre>
<p>However, because i is in quotations `` I believe it is being read as text and thus not working.</p>
<p>Is there any way I can use the ols_split List of 623 regression results to extract coefficients?</p>
| [
{
"answer_id": 74454186,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 2,
"selected": false,
"text": "campaignid"
},
{
"answer_id": 74454192,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 2,
"selected": true,
"text": "useEffect"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17706204/"
] |
74,454,064 | <p>If I have a class that inherits from a base class, can I use that base class as a variable type in c++?</p>
<pre class="lang-cpp prettyprint-override"><code>class Component {
// Code here
};
class TransformComponent : public Component {
// Code here
};
class Entity {
// Code here
Component *getComponent(Component *searchComponent) {
// Code Here
}
};
</code></pre>
<p>as you can see here, I am using the base class "Component" as a return type and a variable type. The problem is that the user may input a "TransformComponent". The only reason I am asking this is because the "TransformComponent" class inherits from the "Component" class and there might be a way to do this?</p>
<pre><code><Entity>.getComponent(Component &TransformComponent());
</code></pre>
<p>The answer I'm looking for is one that works both for the return type, and the variable type.</p>
| [
{
"answer_id": 74454186,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 2,
"selected": false,
"text": "campaignid"
},
{
"answer_id": 74454192,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 2,
"selected": true,
"text": "useEffect"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18131236/"
] |
74,454,076 | <p>I'm having a problem with my website.
When I open <a href="https://www.b3lieve.com.mx/precios.html" rel="nofollow noreferrer">https://www.b3lieve.com.mx/precios.html</a> the card-prices section works correctly (if it's in computer).
But if I visualize the same section but in a mobile or using the responsive design tool, it doesn’t work or have design. What should I do?
<a href="https://i.stack.imgur.com/pRXDS.jpg" rel="nofollow noreferrer">visualized from responsive design tool</a>
<a href="https://i.stack.imgur.com/DelzT.jpg" rel="nofollow noreferrer">visualized from computer</a></p>
<p>I tried it from localhost and it works correctly either computer or responsive design. Could be a problem with my hosting service?</p>
<p>Here's the code...</p>
<p>`</p>
<pre><code><div class="packs" style="padding-top:80px;">
<h2 style="text-align:center;">Booth 360°</h2>
<div class="pricing-table" id="360">
<div class="pricing-card">
<h3 class="pricing-card-header">B&aacute;sico</h3>
<div class="price"><sup>$</sup>5,300 MXN</div>
<ul>
<li><strong>1</strong> Booth 360°.</li>
<li><strong>2</strong> horas de servicio.</li>
<li><strong>2</strong> personas de Staff.</li>
<li>Videos y fotos<strong> ilimitados</strong> durante todo el servicio.</li>
<li><strong>2</strong> templates diferentes y props.</li>
<li>Transportación dentro de la <strong>Ciudad de México</strong>.</li>
</ul>
<a href="/contact.html" class="order-btn">Seleccionar</a>
</div>
</div>
<div class="pricing-table">
<div class="pricing-card">
<h3 class="pricing-card-header">Cl&aacute;sico</h3>
<div class="price"><sup>$</sup>6,800 MXN</div>
<ul>
<li><strong>1</strong> Booth 360°.</li>
<li><strong>3</strong> horas de servicio.</li>
<li><strong>2</strong> personas de Staff.</li>
<li>Videos y fotos<strong> ilimitados</strong> durante todo el servicio.</li>
<li><strong>4</strong> templates diferentes y props.</li>
<li>Transportación dentro de la <strong>Ciudad de México</strong>.</li>
</ul>
<a href="/contact.html" class="order-btn">Seleccionar</a>
</div>
</div>
<div class="pricing-table">
<div class="pricing-card">
<h3 class="pricing-card-header">Pr&eacute;mium</h3>
<div class="price"><sup>$</sup>8,300 MXN</div>
<ul>
<li><strong>1</strong> Booth 360°.</li>
<li><strong>5</strong> horas de servicio.</li>
<li><strong>2</strong> personas de Staff.</li>
<li>Videos y fotos<strong> ilimitados</strong> durante todo el servicio.</li>
<li><strong>6</strong> templates diferentes y props.</li>
<li>Transportación dentro de la <strong>Ciudad de México</strong>.</li>
</ul>
<a href="/contact.html" class="order-btn">Seleccionar</a>
</div>
</div>
<div class="pricing-table">
<div class="pricing-card">
<h3 class="pricing-card-header">Personalizado</h3>
<div class="price">Cont&aacute;ctanos</div>
<ul>
<li><strong>1</strong> Booth 360°.</li>
<li><strong>?</strong> horas de servicio.</li>
<li><strong>2</strong> personas de Staff.</li>
<li>Videos y fotos<strong> ilimitados</strong> durante todo el servicio.</li>
<li><strong>?</strong> templates diferentes y props.</li>
<li>Transportación dentro de la <strong>Ciudad de México</strong>.</li>
</ul>
<a href="/contact.html" class="order-btn">Seleccionar</a>
</div>
</div> <!-- CABINA 360 -->
<br>
<br>
<br>
<h2 style="text-align:center;">Magic Mirror Booth</h2>
<div class="pricing-table">
<div class="pricing-card" id="mirror">
<h3 class="pricing-card-header">B&aacute;sico</h3>
<div class="price"><sup>$</sup>5,900 MXN</div>
<ul>
<li><strong>1</strong> Booth Magic Mirror.</li>
<li><strong>2</strong> horas de servicio.</li>
<li><strong>2</strong> personas de Staff.</li>
<li>Fotos<strong> ilimitadas</strong> durante todo el servicio.</li>
<li><strong>2</strong> templates diferentes y props.</li>
<li>Transportación dentro de la <strong>Ciudad de México</strong>.</li>
</ul>
<a href="/contact.html" class="order-btn">Seleccionar</a>
</div>
</div>
<div class="pricing-table">
<div class="pricing-card">
<h3 class="pricing-card-header">Cl&aacute;sico</h3>
<div class="price"><sup>$</sup>7,400 MXN</div>
<ul>
<li><strong>1</strong> Booth Magic Mirror.</li>
<li><strong>3</strong> horas de servicio.</li>
<li><strong>2</strong> personas de Staff.</li>
<li>Fotos<strong> ilimitadas</strong> durante todo el servicio.</li>
<li><strong>4</strong> templates diferentes y props.</li>
<li>Transportación dentro de la <strong>Ciudad de México</strong>.</li>
</ul>
<a href="/contact.html" class="order-btn">Seleccionar</a>
</div>
</div>
<div class="pricing-table">
<div class="pricing-card">
<h3 class="pricing-card-header">Pr&eacute;mium</h3>
<div class="price"><sup>$</sup>9,900 MXN</div>
<ul>
<li><strong>1</strong> Booth Magic Mirror.</li>
<li><strong>5</strong> horas de servicio.</li>
<li><strong>2</strong> personas de Staff.</li>
<li>Fotos<strong> ilimitadas</strong> durante todo el servicio.</li>
<li><strong>6</strong> templates diferentes y props.</li>
<li>Transportación dentro de la <strong>Ciudad de México</strong>.</li>
</ul>
<a href="/contact.html" class="order-btn">Seleccionar</a>
</div>
</div>
<div class="pricing-table">
<div class="pricing-card">
<h3 class="pricing-card-header">Personalizado</h3>
<div class="price">Cont&aacute;ctanos</div>
<ul>
<li><strong>1</strong> Booth Magic Mirror.</li>
<li><strong>?</strong> horas de servicio.</li>
<li><strong>2</strong> personas de Staff.</li>
<li>Fotos<strong> ilimitados</strong> durante todo el servicio.</li>
<li><strong>?</strong> templates diferentes y props.</li>
<li>Transportación dentro de la <strong>Ciudad de México</strong>.</li>
</ul>
<a href="/contact.html" class="order-btn">Seleccionar</a>
</div>
</div>
</div>
</code></pre>
<p>`</p>
<p>`</p>
<pre><code>.pricing-table{
display: flex;
flex-wrap: wrap;
justify-content: space-around;
width: min(1600px, 100%);
}
.pricing-card{
flex: 1;
max-width: 360px;
background-color: #17173d;
margin: 20px 10px;
text-align: center;
cursor: pointer;
overflow: hidden;
color: #f9f9f9;
transition: .3s linear;
border-radius: 20px;
}
.pricing-card-header{
background-color: var(--majorelle-blue);
display: inline-block;
color: #fff;
padding: 12px 30px;
border-radius: 0 0 20px 20px;
font-size: 16px;
text-transform: uppercase;
font-weight: 600;
transition: .4s linear;
}
.pricing-card:hover .pricing-card-header{
box-shadow: 0 0 0 26em var(--majorelle-blue);
}
.price{
font-size: 35px;
color: var(--majorelle-blue);
margin: 40px 0;
transition: .2s linear;
}
.price sup{
font-size: 22px;
font-weight: 700;
}
.pricing-card:hover ,.pricing-card:hover .price{
color: #fff;
}
.pricing-card li{
font-size: 16px;
padding: 10px 0;
text-transform: uppercase;
}
.order-btn{
display: inline-block;
margin-bottom: 40px;
margin-top: 80px;
border: 2px solid var(--majorelle-blue);
color: var(--majorelle-blue);
padding: 18px 40px;
border-radius: 8px;
text-transform: uppercase;
font-weight: 500;
transition: .3s linear;
}
.order-btn:hover{
background-color: var(--majorelle-blue);
color: #fff;
}
@media screen and (max-width:1100px) {
.pricing-card{
flex: 50%;
}
}
</code></pre>
<p>`</p>
| [
{
"answer_id": 74454281,
"author": "AtomicUs5000",
"author_id": 17934914,
"author_profile": "https://Stackoverflow.com/users/17934914",
"pm_score": 0,
"selected": false,
"text": "@media (min-width: 450px) {\n\n /**\n * HERO\n */\n\n .hero-form { position: relative; }\n\n .email-field {\n margin-bottom: 0;\n padding-right: 155px;\n }\n\n .hero-ctc .btn-primary {\n position: absolute;\n top: 5px;\n right: 5px;\n padding-block: 12.5px;\n }\n\n\n /**\n * ABOUT\n */\n\n .about-card .card-text {\n max-width: 300px;\n margin-inline: auto;\n }\n\n}\n"
},
{
"answer_id": 74454949,
"author": "Mad7Dragon",
"author_id": 6467902,
"author_profile": "https://Stackoverflow.com/users/6467902",
"pm_score": 1,
"selected": false,
"text": " @media (min-width: 450px) {\n \n /**\n * HERO\n */\n \n .hero-form { position: relative; }\n \n \n .email-field {\n margin-bottom: 0;\n padding-right: 155px;\n }\n \n .hero .btn-primary {\n position: absolute;\n top: 5px;\n right: 5px;\n padding-block: 12.5px;\n }\n .hero-ctc .btn-primary {\n position: absolute;\n top: 5px;\n right: 5px;\n padding-block: 12.5px;\n }\n } /* this wasn't closed */\n \n @media (min-width: 450px) {\n \n /**\n * HERO\n */\n \n .hero-form { position: relative; }\n \n .email-field {\n margin-bottom: 0;\n padding-right: 155px;\n }\n \n .hero .btn-primary {\n position: absolute;\n top: 5px;\n right: 5px;\n padding-block: 12.5px;\n }\n .hero-ctc .btn-primary {\n position: absolute;\n top: 5px;\n right: 5px;\n padding-block: 12.5px;\n }\n} /* this wasn't closed */\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515342/"
] |
74,454,085 | <p>I have a list of the RecyclerView. And I made a swipe removal. Then I made a Snackbar in MainActivity to undo the removal:</p>
<pre><code>val onSwipe = object : OnSwipe(this) {
override fun onSwiped(viewHolder: ViewHolder, direction: Int) {
when (direction) {
ItemTouchHelper.RIGHT -> {
adapter.removeItem(
viewHolder.absoluteAdapterPosition
)
Snackbar.make(binding.rv, "Deleted", Snackbar.LENGTH_SHORT)
.apply {
setAction("Undo") {
adapter.restoreItem(
viewHolder.absoluteAdapterPosition)
}
show()
}
}
}
}
}
</code></pre>
<p>Code in adapter:</p>
<pre><code>fun removeItem(pos: Int) {
listArray.removeAt(pos)
notifyItemRemoved(pos)
}
fun restoreItem(pos: Int) {
listArray.add(pos, listArray[pos])
notifyItemInserted(pos)
}
</code></pre>
<p>And when I make the undo operation, my app stops, and I see this in a Logcat:</p>
<pre><code>java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
at java.util.ArrayList.get(ArrayList.java:439)
at com.example.databaselesson.recyclerView.ExpensesAdapter.restoreItem(ExpensesAdapter.kt:79)
at com.example.databaselesson.MainActivity2$onSwipe$1.onSwiped$lambda-1$lambda-0(MainActivity2.kt:391)
at com.example.databaselesson.MainActivity2$onSwipe$1.$r8$lambda$AhJR3pu-3ynwFvPp66LdaLyFdB0(Unknown Source:0)
at com.example.databaselesson.MainActivity2$onSwipe$1$$ExternalSyntheticLambda0.onClick(Unknown Source:4)
</code></pre>
<p>Please, help</p>
<p>If you need more code, please, write, and I will send you it</p>
| [
{
"answer_id": 74454274,
"author": "Android Newbie A",
"author_id": 20125791,
"author_profile": "https://Stackoverflow.com/users/20125791",
"pm_score": 2,
"selected": true,
"text": "viewHolder.absoluteAdapterPosition"
},
{
"answer_id": 74454323,
"author": "cactustictacs",
"author_id": 13598222,
"author_profile": "https://Stackoverflow.com/users/13598222",
"pm_score": 2,
"selected": false,
"text": "notifyItemRemoved"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515224/"
] |
74,454,097 | <p>I have</p>
<pre><code>x = collect(1:9)
y = repeat([1],9)
</code></pre>
<p>producing</p>
<pre><code>9-element Vector{Int64}:
1
2
3
4
5
6
7
8
9
9-element Vector{Int64}:
1
1
1
1
1
1
1
1
1
</code></pre>
<p>And want to glue the two vectors together vertically, whereas some of the matrix columns are <code>x</code>, others <code>y</code>. I found that I can do that equivalently by running either one of those commands:</p>
<pre><code>c0 = [x y x x x]
c1 = cat(x,y,x,x,x,dims=2)
</code></pre>
<p>producing</p>
<pre><code>9×5 Matrix{Int64}:
1 1 1 1 1
2 1 2 2 2
3 1 3 3 3
4 1 4 4 4
5 1 5 5 5
6 1 6 6 6
7 1 7 7 7
8 1 8 8 8
9 1 9 9 9
</code></pre>
<p>Now, I would like to dynamically put together a matrix with <code>x</code> and <code>y</code> columns based on a control vector, <code>V</code>, that can differ in length. I tried to do it in the following way, however, I will get a different data structure:</p>
<pre><code>V = [false true false false false]
[v ? x : y for v in V]
</code></pre>
<p>producing:</p>
<pre><code>1×5 Matrix{Vector{Int64}}:
[1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 1, 1, 1, 1, 1, 1, 1, 1]
</code></pre>
<p>How can I solve this? I strictly need this structure, and I have a strong interest/preference in using the beautiful Julia fast vector/array code style, avoiding any multi-line for loops.</p>
| [
{
"answer_id": 74454438,
"author": "Giovanni",
"author_id": 16204281,
"author_profile": "https://Stackoverflow.com/users/16204281",
"pm_score": 2,
"selected": true,
"text": "V = [true, false, true, true, true]\nreduce(hcat, [v ? x : y for v in V])\n"
},
{
"answer_id": 74460349,
"author": "joffdd",
"author_id": 1444971,
"author_profile": "https://Stackoverflow.com/users/1444971",
"pm_score": 0,
"selected": false,
"text": "V"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1444971/"
] |
74,454,101 | <p>I am writing Python, and I want to count the times of an item appears in a list(which is made up by multiple sublist)</p>
<pre><code>a = [[3,2,5,6],[2,5,1,20],[7,3,16,5]]
</code></pre>
<p>The result: 3->2 times ; 1->1 time; 5->3 times</p>
<p><strong>Heres the things, I do not want to use loop.!!</strong></p>
<p>Is there any other way? Thank you for helping. :)</p>
| [
{
"answer_id": 74454438,
"author": "Giovanni",
"author_id": 16204281,
"author_profile": "https://Stackoverflow.com/users/16204281",
"pm_score": 2,
"selected": true,
"text": "V = [true, false, true, true, true]\nreduce(hcat, [v ? x : y for v in V])\n"
},
{
"answer_id": 74460349,
"author": "joffdd",
"author_id": 1444971,
"author_profile": "https://Stackoverflow.com/users/1444971",
"pm_score": 0,
"selected": false,
"text": "V"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16469595/"
] |
74,454,109 | <p>I was wondering if there might be a way to convert each set of similarly named columns (<code>ratio_...</code>, <code>EL_...</code>, <code>Teacher_...</code>) to long format in R?</p>
<p>I have tried the following solution (using <code>tidyr::pivot_longer()</code>) but I get several <code>NA</code>s in my output.</p>
<p>My suspicion is that these <code>NA</code>s have to do with <code>names_sep = "_"</code>. But I simply want to have one column as the <em>key</em> (to be called <em>year</em>) populated with numeric years like 2019, 2020, 2021.</p>
<pre><code>library(tidyverse)
data <- read.csv("https://raw.githubusercontent.com/ilzl/i/master/prac.csv") %>%
pivot_longer(cols = -id, names_to = c(".value", "year"), names_sep = "_")
</code></pre>
| [
{
"answer_id": 74454191,
"author": "langtang",
"author_id": 4447540,
"author_profile": "https://Stackoverflow.com/users/4447540",
"pm_score": 2,
"selected": false,
"text": "_"
},
{
"answer_id": 74454288,
"author": "Ritchie Sacramento",
"author_id": 2835261,
"author_profile": "https://Stackoverflow.com/users/2835261",
"pm_score": 2,
"selected": true,
"text": "_"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16760971/"
] |
74,454,140 | <p>Let's say I have:</p>
<pre><code>let it = [1, 2, 3].into_iter();
let jt = [4, 5, 6].into_iter();
let kt = [7, 8, 9].into_iter();
</code></pre>
<p>Then I have boolean conditions <code>i</code>, <code>j</code> and <code>k</code>. I want to generate an iterator that conditionally chains <code>it</code>, <code>jt</code> and <code>kt</code> together based on the values of <code>i</code>, <code>j</code> and <code>k</code>. Can I do this with just the built-in Rust <code>Iterator</code> functionality?</p>
| [
{
"answer_id": 74454189,
"author": "cameron1024",
"author_id": 9186783,
"author_profile": "https://Stackoverflow.com/users/9186783",
"pm_score": 2,
"selected": false,
"text": "let iter = [1, 2, 3].into_iter();\nlet iter = if some_condition {\n iter.chain([4, 5, 6])\n} else {\n iter\n}\n"
},
{
"answer_id": 74454267,
"author": "Peng Guanwen",
"author_id": 5875980,
"author_profile": "https://Stackoverflow.com/users/5875980",
"pm_score": 3,
"selected": true,
"text": "Option"
},
{
"answer_id": 74454375,
"author": "Anders Evensen",
"author_id": 10798363,
"author_profile": "https://Stackoverflow.com/users/10798363",
"pm_score": 1,
"selected": false,
"text": "either"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002430/"
] |
74,454,147 | <p>I'm working with Bootstrap in React, and I'm trying to implement a password, where there is an icon to click on to toggle between text and password types inside of the input field. I've implemented all of the logic, but the icon/input field has a border so that it look like a button to the right of the input, like so:</p>
<p><a href="https://i.stack.imgur.com/okAgd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/okAgd.png" alt="enter image description here" /></a></p>
<p>I was wondering how I could get rid of that border separating the two so that it would look like it was inside of the input box to be like this example:</p>
<p><a href="https://i.stack.imgur.com/6h45f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6h45f.png" alt="enter image description here" /></a></p>
<p>This is the code I have written with the react hooks replaced</p>
<pre><code>import { Icon } from "react-icons-kit";
import { eyeOff } from "react-icons-kit/feather/eyeOff";
import { eye } from "react-icons-kit/feather/eye";
<label>Password</label>
<div className="mb-3 input-group">
<input
type="password"
name="password"
className="form-control"
placeholder="Enter password"
required
/>
<span className="input-group-append bg-white">
<span className="input-group-text bg-transparent">
<Icon icon={eyeOff} size={15}/>
</span>
</span>
</div>
</code></pre>
<p>I've tried to add "border border-right-0" to the input-group div class which seems to do nothing, and also "border border-left-0" to the input-group-append span class, but this seems to create another border around the border that already exists.</p>
| [
{
"answer_id": 74454189,
"author": "cameron1024",
"author_id": 9186783,
"author_profile": "https://Stackoverflow.com/users/9186783",
"pm_score": 2,
"selected": false,
"text": "let iter = [1, 2, 3].into_iter();\nlet iter = if some_condition {\n iter.chain([4, 5, 6])\n} else {\n iter\n}\n"
},
{
"answer_id": 74454267,
"author": "Peng Guanwen",
"author_id": 5875980,
"author_profile": "https://Stackoverflow.com/users/5875980",
"pm_score": 3,
"selected": true,
"text": "Option"
},
{
"answer_id": 74454375,
"author": "Anders Evensen",
"author_id": 10798363,
"author_profile": "https://Stackoverflow.com/users/10798363",
"pm_score": 1,
"selected": false,
"text": "either"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14980233/"
] |
74,454,148 | <p>This is my code
it gives you points if you answered well a question, i want to know how to show all the scoreboard at the end with all the user got points I don't want to save that data anywhere, bc is not necessary, i just want to at the end of each command it tells you how many points you had in that game, but taking into account the other players, and all that within a single command, if I start another, the scores would be 0,
some people told me I could use a dictionary but I don't know how
examples</p>
<p>results</p>
<p>david 6 points</p>
<p>maria 3 points</p>
<p>dharma 2 points</p>
<p>mikey 1 point</p>
<pre><code>def check(msg=discord.Message) -> True:
return msg.content.lower() in answer and msg.channel == ctx.message.channel
try:
guess = await bot.wait_for('mesage', timeout=6, check=check)
if guess.content.lower() in answer:
score += 1
await ctx.send(f"{guess.author.mention} has {score} pts")
except asyncio.TimeoutError:
await ctx.send("time over")
</code></pre>
| [
{
"answer_id": 74454189,
"author": "cameron1024",
"author_id": 9186783,
"author_profile": "https://Stackoverflow.com/users/9186783",
"pm_score": 2,
"selected": false,
"text": "let iter = [1, 2, 3].into_iter();\nlet iter = if some_condition {\n iter.chain([4, 5, 6])\n} else {\n iter\n}\n"
},
{
"answer_id": 74454267,
"author": "Peng Guanwen",
"author_id": 5875980,
"author_profile": "https://Stackoverflow.com/users/5875980",
"pm_score": 3,
"selected": true,
"text": "Option"
},
{
"answer_id": 74454375,
"author": "Anders Evensen",
"author_id": 10798363,
"author_profile": "https://Stackoverflow.com/users/10798363",
"pm_score": 1,
"selected": false,
"text": "either"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20353157/"
] |
74,454,185 | <p>So I have a function inside my main model viewer, with the following code:</p>
<pre><code>class MainViewModel: ObservableObject {
func getUserUsername() {
if let u = User.current {
username = u.username ?? ""
} else {
username = ""
}
log.info("\n : (MainViewModel: 193) - Set the 'Username' as: \(self.username.isEmpty ? "N/A" : self.username).")
print("")
}
}
</code></pre>
<p>Then inside a View, I have the following code:</p>
<pre><code>struct ProfileView: View {
var body: some View {
@ObservedObject var model: MainViewModel
Text("User: " + model.getUserUsername())
}
}
</code></pre>
<p>The issue is that it's throwing a <code>Type '()' cannot conform to 'AttributedStringProtocol'</code> error - I want to be able to just output the username for debugging purposes.</p>
| [
{
"answer_id": 74456023,
"author": "Qazi Ammar",
"author_id": 6026338,
"author_profile": "https://Stackoverflow.com/users/6026338",
"pm_score": 1,
"selected": false,
"text": "class MainViewModel: ObservableObject {\n func getUserUsername() -> String {\n if let u = User.current {\n username = u.username ?? \"\"\n } else {\n username = \"\"\n }\n log.info(\"\\n : (MainViewModel: 193) - Set the 'Username' as: \\(self.username.isEmpty ? \"N/A\" : self.username).\")\n print(\"\")\n return username\n\n }\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19566858/"
] |
74,454,221 | <p>I have two structs that depend on each other. In C++ I would do this with pointers, I'm trying to figure out how to do this in Rust. I've tried using Box and Rc so far, I would think since Rc is a reference counter it should be able to handle this, but it's giving me an error.</p>
<p>Here is a simple code example:</p>
<pre><code>struct A {
b : Rc<B>
}
struct B {
a : Option<Rc<A>>
}
fn main() {
let mut b = B {
a : None
};
let a = A {
b: Rc::new(b)
};
b.a = Some(Rc::new(a));
}
</code></pre>
<p>Here is the error I get from it:</p>
<pre><code>20 | let mut b = B {
| ----- move occurs because `b` has type `B`, which does not implement the `Copy` trait
...
25 | b: Rc::new(b)
| - value moved here
...
28 | b.a = Some(Rc::new(a));
| ^^^ value partially assigned here after move
</code></pre>
<p>What is the correct way to do this type of relationship in Rust?</p>
| [
{
"answer_id": 74454444,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 0,
"selected": false,
"text": "use std::cell::RefCell;\nuse std::rc::Rc;\n\n// make a cycle: struct A owning struct B and struct B owning struct A\nstruct A {\n b : Rc<RefCell<B>>\n}\n\nstruct B {\n a : Option<Rc<RefCell<A>>>\n}\n\nfn main() {\n\n // init b with None\n let b = Rc::new(RefCell::new(B { a: None }));\n\n // init a with b\n let a = Rc::new(RefCell::new(A { b: Rc::clone(&b) }));\n\n // set b.a to a\n b.borrow_mut().a = Some(Rc::clone(&a));\n}\n"
},
{
"answer_id": 74454544,
"author": "Peng Guanwen",
"author_id": 5875980,
"author_profile": "https://Stackoverflow.com/users/5875980",
"pm_score": 3,
"selected": false,
"text": "Rc::new"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428916/"
] |
74,454,226 | <p>I have a list and another list which consists of dictionaries.</p>
<pre><code>list1 = ['d', 'a', 'c', 'b', 'e', 'g']
list2 = [{'key1':'a', 'key2': 'asdf'}, {'key1': 'f', 'key2': 'dd'}, {'key1': 'b', 'key2': 'afd'}, {'key1': 'c', 'key2': 'ff'}, {'key1': 'd', 'key2': 'aa'}, {'key1': 'e', 'key2': 'aab'}]
</code></pre>
<p>Neither list1 nor list2 is sorted.</p>
<p>I want to sort list2 so that the order of 'key1' in list2 is the same as it appears in list1.</p>
<p>Some of the elements in list1 may not be contained in key1 of list2.
Similarly, some elements of the list2 may not be in list1.</p>
<p>The desired result is</p>
<pre><code> [{'key1': 'd', 'key2': 'aa'}, {'key1':'a', 'key2': 'asdf'}, {'key1': 'c', 'key2': 'ff'}, {'key1': 'b', 'key2': 'afd'}, , , {'key1': 'e', 'key2': 'aab'}]
</code></pre>
<p>The common elements of the list1 and key1's of the list2 are 'd', 'a', 'c', 'b', and 'e' as it appears in the list1.
So I picked the elements of list2 which the key1 is the above element in the same order it appears in the list1.</p>
| [
{
"answer_id": 74454444,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 0,
"selected": false,
"text": "use std::cell::RefCell;\nuse std::rc::Rc;\n\n// make a cycle: struct A owning struct B and struct B owning struct A\nstruct A {\n b : Rc<RefCell<B>>\n}\n\nstruct B {\n a : Option<Rc<RefCell<A>>>\n}\n\nfn main() {\n\n // init b with None\n let b = Rc::new(RefCell::new(B { a: None }));\n\n // init a with b\n let a = Rc::new(RefCell::new(A { b: Rc::clone(&b) }));\n\n // set b.a to a\n b.borrow_mut().a = Some(Rc::clone(&a));\n}\n"
},
{
"answer_id": 74454544,
"author": "Peng Guanwen",
"author_id": 5875980,
"author_profile": "https://Stackoverflow.com/users/5875980",
"pm_score": 3,
"selected": false,
"text": "Rc::new"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2091585/"
] |
74,454,228 | <p>I am replicating a paper. I have a basic Keras CNN model for MNIST classification. Now for sample <code>z</code> in the training, I want to calculate the hessian matrix of the model parameters with respect to the loss of that sample. I want to average out this hessian over the training data (<code>n</code> is number of training data).</p>
<p><a href="https://i.stack.imgur.com/zMsQF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zMsQF.png" alt="enter image description here" /></a></p>
<p>My final goal is to calculate this value (the influence score):</p>
<p><a href="https://i.stack.imgur.com/O5PqC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O5PqC.png" alt="enter image description here" /></a></p>
<p>I can calculate the left term and the right term and want to compute the Hessian term. I don't know how to calculate hessian for the model weights for a batch of examples (vectorization). I was able to calculate it only for a sample at a time which is too slow.</p>
<pre><code>x=tf.convert_to_tensor(x_train[0:13])
with tf.GradientTape() as t2:
with tf.GradientTape() as t1:
y=model(x)
mce = tf.keras.losses.CategoricalCrossentropy()
y_expanded=y_train[train_idx]
loss=mce(y_expanded,y)
g = t1.gradient(loss, model.weights[4])
h = t2.jacobian(g, model.weights[4])
print(h.shape)
</code></pre>
<p>For clarification, if a model layer is of dimension <code>20*30</code>, I want to feed a batch of <code>13</code> samples to it and get a Hessian of dimension <code>(13,20,30,20,30)</code>. Now I can only get Hessian of dimension <code>(20,30,20,30)</code> which thwarts the vectorization (the code above).</p>
<p>This <a href="https://stackoverflow.com/questions/62261134/whats-the-best-way-to-access-single-gradients-in-a-batch-in-tensorflow">thread</a> has the same problem, except that I want the second-order derivative rather than the first-order.</p>
<p>I also tried the below script which returns a <code>(13,20,30,20,30)</code> matrix that satisfies the dimension, but when I manually checked the sum of this matrix with the sum of <code>13</code> single hessian calculations with a for loop from <code>0</code> to <code>12</code>, they lead to different numbers so it does not work either since I expected equal values.</p>
<pre><code>x=tf.convert_to_tensor(x_train[0:13])
mce = tf.keras.losses.CategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)
with tf.GradientTape() as t2:
with tf.GradientTape() as t1:
t1.watch(model.weights[4])
y_expanded=y_train[0:13]
y=model(x)
loss=mce(y_expanded,y)
j1=t1.jacobian(loss, model.weights[4])
j3 = t2.jacobian(j1, model.weights[4])
print(j3.shape)
</code></pre>
| [
{
"answer_id": 74454444,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 0,
"selected": false,
"text": "use std::cell::RefCell;\nuse std::rc::Rc;\n\n// make a cycle: struct A owning struct B and struct B owning struct A\nstruct A {\n b : Rc<RefCell<B>>\n}\n\nstruct B {\n a : Option<Rc<RefCell<A>>>\n}\n\nfn main() {\n\n // init b with None\n let b = Rc::new(RefCell::new(B { a: None }));\n\n // init a with b\n let a = Rc::new(RefCell::new(A { b: Rc::clone(&b) }));\n\n // set b.a to a\n b.borrow_mut().a = Some(Rc::clone(&a));\n}\n"
},
{
"answer_id": 74454544,
"author": "Peng Guanwen",
"author_id": 5875980,
"author_profile": "https://Stackoverflow.com/users/5875980",
"pm_score": 3,
"selected": false,
"text": "Rc::new"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12461032/"
] |
74,454,230 | <p>I was working with list in python and I need to remove non-true values.</p>
<p>Can someone explain why here I get index out of range error:</p>
<pre><code> for n in range(len(lst)-1): #index outside the range
if not bool(lst[n]):
lst.pop(n)
return lst
</code></pre>
<p>It is kind of work with while loop</p>
<pre><code>def compact(lst):
while n < len(lst):
if not bool(lst[n]):
lst.pop(n)
n+=1
print(n)
return lst
</code></pre>
<p>But in this case loop will skip some items.</p>
<p>function is called like:
<code>compact([0, 1, 2, '', [], False, (), None, 'All done'])</code></p>
| [
{
"answer_id": 74454264,
"author": "Amadan",
"author_id": 240443,
"author_profile": "https://Stackoverflow.com/users/240443",
"pm_score": 3,
"selected": true,
"text": "n+1"
},
{
"answer_id": 74454409,
"author": "Shriya Jain",
"author_id": 12264136,
"author_profile": "https://Stackoverflow.com/users/12264136",
"pm_score": 0,
"selected": false,
"text": "lst.pop(n)"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10002278/"
] |
74,454,284 | <p>I have two column 'book_name' & 'writer' in 'books' table. When new data insert i want to check the same book and writer not will be added. But i dont understand how to do this. here is my code.</p>
<pre><code>public function rules()
{
return [
'book_name' => 'required|unique:books,book_name,' . $this->id,
'writer' => 'required|unique:books,writer,' . $this->id,
];
}
</code></pre>
| [
{
"answer_id": 74454264,
"author": "Amadan",
"author_id": 240443,
"author_profile": "https://Stackoverflow.com/users/240443",
"pm_score": 3,
"selected": true,
"text": "n+1"
},
{
"answer_id": 74454409,
"author": "Shriya Jain",
"author_id": 12264136,
"author_profile": "https://Stackoverflow.com/users/12264136",
"pm_score": 0,
"selected": false,
"text": "lst.pop(n)"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3302732/"
] |
74,454,296 | <p>I would like to do the following without changing the file for a large log file in Windows format</p>
<ol>
<li>Remove all CRLF characters</li>
<li>Insert a blank line between the "CLG..." "TRC..." in the last line of the log file</li>
<li>After reading the results in paragraph mode, print the paragraph if a particular string exists</li>
</ol>
<p>code below does not work.</p>
<pre><code>use strict;
use warnings;
my $ID = "D5CCA1AE-686D11E2-A881ED01-8DFA6D70@10.218.16.2";
my $SDP;
open (LOG, "file.log") || die $!;
my $line;
while(<LOG>) {
$line .= $_;
$line =~s/\r//g;
}
local $/ = '';
while (<>) {
if ( /Call-ID:\s+(.+)/ and $ID ) {
$SDP = 1;
print;
next;
}
print if $SDP && /\brtpmap\b/;
$SDP = 0;
}
close(LOG);
</code></pre>
<hr />
<pre><code>Jan 28 11:39:37.525 CET: //1393628/D5CC0586A87B/SIP/Msg/ccsipDisplayMsg:^M
Received:^M
SIP/2.0 200 OK^M
Via: SIP/2.0/UDP 10.218.16.2:5060;branch=z9hG4bKB22001ED5^M
From: "Frankeerapparaat Secretariaat" <sip:089653717@10.210.2.49>;tag=E7E0EF64-192F^M
To: <sip:022046187@10.210.2.49>;tag=25079324~19cc0abf-61d9-407f-a138-96eaffee1467-27521338^M
Date: Mon, 28 Jan 2013 10:39:32 GMT^M
Call-ID: D5CCA1AE-686D11E2-A881ED01-8DFA6D70@10.218.16.2^M
CSeq: 102 INVITE^M
Allow: INVITE, OPTIONS, INFO, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY^M
Allow-Events: presence^M
Supported: replaces^M
Supported: X-cisco-srtp-fallback^M
Supported: Geolocation^M
Session-Expires: 1800;refresher=uas^M
Require: timer^M
P-Preferred-Identity: <sip:022046187@10.210.2.49>^M
Remote-Party-ID: <sip:022046187@10.210.2.49>;party=called;screen=no;privacy=off^M
Contact: <sip:022046187@10.210.2.49:5060>^M
Content-Type: application/sdp^M
Content-Length: 209^M
^M
v=0^M
o=CiscoSystemsCCM-SIP 2000 1 IN IP4 10.210.2.49^M
s=SIP Call^M
c=IN IP4 10.210.2.1^M
t=0 0^M
m=audio 16844 RTP/AVP 8 101^M
a=rtpmap:8 PCMA/8000^M
a=ptime:20^M
a=rtpmap:101 telephone-event/8000^M
a=fmtp:101 0-15^M
^M
Jan 28 11:39:37.529 CET: //1393628/D5CC0586A87B/SIP/Msg/ccsipDisplayMsg:^M
Sent:^M
ACK sip:022046187@10.210.2.49:5060 SIP/2.0^M
Via: SIP/2.0/UDP 10.218.16.2:5060;branch=z9hG4bKB2247150A^M
From: "Frankeerapparaat Secretariaat" <sip:089653717@10.210.2.49>;tag=E7E0EF64-192F^M
To: <sip:022046187@10.210.2.49>;tag=25079324~19cc0abf-61d9-407f-a138-96eaffee1467-27521338^M
Date: Mon, 28 Jan 2013 10:39:36 GMT^M
Call-ID: D5CCA1AE-686D11E2-A881ED01-8DFA6D70@10.218.16.2^M
Max-Forwards: 70^M
CSeq: 102 ACK^M
Authorization: Digest username="Genk_AC_1",realm="infraxnet.be",uri="sip:022046187@10.210.2.49:5060",response="9546733290a96d1470cfe29a7500c488",nonce="5V/Jt8FHd5I8uaoahshiaUud8O6UujJJ",algorithm=MD5^M
Allow-Events: telephone-event^M
Content-Length: 0^M
^M
^M
Jan 28 11:39:37.529 CET: //1393627/D5CC0586A87B/SIP/Msg/ccsipDisplayMsg:^M
Sent:^M
SIP/2.0 200 OK^M
Via: SIP/2.0/UDP 192.168.8.11:5060;branch=z9hG4bK24ecaaaa6dbd3^M
From: "Frankeerapparaat Secretariaat" <sip:3717@192.168.8.11>;tag=e206cc93-1791-457a-aaac-1541296cf17c-29093746^M
To: <sip:022046187@192.168.8.28>;tag=E7E0F8A4-EA3^M
Date: Mon, 28 Jan 2013 10:39:32 GMT^M
Call-ID: fedc8f80-10615564-45df0-b08a8c0@192.168.8.11^M
CSeq: 101 INVITE^M
Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY, INFO, REGISTER^M
Allow-Events: telephone-event^M
Remote-Party-ID: <sip:022046187@192.168.8.28>;party=called;screen=no;privacy=off^M
Contact: <sip:022046187@192.168.8.28:5060>^M
Supported: replaces^M
Supported: sdp-anat^M
Server: Cisco-SIPGateway/IOS-15.3.1.T^M
Session-Expires: 1800;refresher=uas^M
Require: timer^M
Supported: timer^M
Content-Type: application/sdp^M
Content-Disposition: session;handling=required^M
Content-Length: 247^M
^M
v=0^M
o=CiscoSystemsSIP-GW-UserAgent 7276 9141 IN IP4 192.168.8.28^M
s=SIP Call^M
c=IN IP4 192.168.8.28^M
t=0 0^M
m=audio 30134 RTP/AVP 8 101^M
c=IN IP4 192.168.8.28^M
a=rtpmap:8 PCMA/8000^M
a=rtpmap:101 telephone-event/8000^M
a=fmtp:101 0-15^M
a=ptime:20^M
^M
CLG(2022-11-07 00:09:06.444)| Call(Terminate) | 302A330B040C73070A021806021C0200 | ^M
TRC(2022-11-15 00:00:38.012)| SIP( OUT : Response ) Trying( 100 INVITE ) | 2 | | 0 | 332C30050A0F750A00011A06021C0200 | SIP/2.0 100 Trying^M
</code></pre>
| [
{
"answer_id": 74465482,
"author": "user20284150",
"author_id": 20284150,
"author_profile": "https://Stackoverflow.com/users/20284150",
"pm_score": 2,
"selected": true,
"text": ":crlf"
},
{
"answer_id": 74466235,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 2,
"selected": false,
"text": "@"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3880407/"
] |
74,454,315 | <p>My chart looks like so::</p>
<p><a href="https://i.stack.imgur.com/g8XIy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g8XIy.png" alt="Plot line chart" /></a></p>
<p>and here is my code:</p>
<pre><code>linePlot = Plot.plot({
marginLeft: 60, // space to the left of the chart
y: {
type: "log", // set the type
},
marks: [
Plot.line(data, {x: "timestamp", y: "views", z:"artist", title: d=>`${d.artist}`,})
]
})
</code></pre>
<p>I want to highlight or change color of each line when the mouse is over it.</p>
| [
{
"answer_id": 74465482,
"author": "user20284150",
"author_id": 20284150,
"author_profile": "https://Stackoverflow.com/users/20284150",
"pm_score": 2,
"selected": true,
"text": ":crlf"
},
{
"answer_id": 74466235,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 2,
"selected": false,
"text": "@"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19999422/"
] |
74,454,322 | <p>I am new to data analysis and I'm wondering if I can get pointers for what I am facing at the moment.</p>
<p>I have an ICS calendar that I am trying to export into a spreadsheet. However, the data I recieve is organised as follows:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Data</th>
</tr>
</thead>
<tbody>
<tr>
<td>Event: NAME XXX</td>
</tr>
<tr>
<td>Date: xx xx xx</td>
</tr>
<tr>
<td>Location: NOWHERE</td>
</tr>
<tr>
<td>URL: <a href="http://www.hi.com" rel="nofollow noreferrer">www.hi.com</a></td>
</tr>
<tr>
<td>Event: NAME YYY</td>
</tr>
<tr>
<td>Date: yy yy yy</td>
</tr>
<tr>
<td>Location: SOMEHWERE</td>
</tr>
<tr>
<td>URL: <a href="http://www.hello.com" rel="nofollow noreferrer">www.hello.com</a></td>
</tr>
</tbody>
</table>
</div>
<p>... and so on</p>
<p>I need to be able promote the text before the : delimiter on every four rows as headers. so that my data looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Event</th>
<th>Date</th>
<th>Location</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<tr>
<td>NAME X</td>
<td>xx xx xx</td>
<td>SOMEHWERE</td>
<td>hello.com</td>
</tr>
<tr>
<td>NAME Y</td>
<td>xx xx xx</td>
<td>NOWHERE</td>
<td>bye.com</td>
</tr>
</tbody>
</table>
</div>
<p>I can use SQL or Python or data visualisation software such as PowerBI, alternatively, good ol' Excel works fine.</p>
<p>I tried other tools and workarounds such as uploading the ICS calendar into my Outlook calendar and then exporting the calendar. This worked fine but it is a work around.</p>
<p>I would like to be able to load the information via the ICS link directly into a CSV/Excel because I am using the information to populate a PowerBI Dashboard.</p>
| [
{
"answer_id": 74465482,
"author": "user20284150",
"author_id": 20284150,
"author_profile": "https://Stackoverflow.com/users/20284150",
"pm_score": 2,
"selected": true,
"text": ":crlf"
},
{
"answer_id": 74466235,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 2,
"selected": false,
"text": "@"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515564/"
] |
74,454,324 | <p>I am implementing a co-occurrence matrix for an image to be able to detect the edges of an image through the change in brightness. So I made a 256x256 numpy matrix to store the co-occurrences, and then I wrote a function that turns all of the values of occurrences in the matrix to 0 if the change between them is less than a certain value like 30, ie the difference between the i and j of the matrix is less than 30 then the value inside that cell is turned into 0.</p>
<p>Here is the function, it takes the co-occurrence matrix and turn the values into 0.</p>
<pre><code>def nullify(matrix):
for i in range (0,matrix.shape[0]):
for j in range(0,matrix.shape[1]):
if(abs(i-j)<30):
matrix[i,j]=0
return matrix
</code></pre>
<p>But for some reason it turn the entire matrix into 0's, the function work perfectly when I'm using a smaller matrix like a 3x3.</p>
<p>This is the function that I use to calculate the Cooccurrence</p>
<pre><code>def calculateCooccurrence(im):
Horizontal = np.zeros((256, 256))
for i in range (0,im.size[0]):
for j in range (0,im.size[1]-1):
pixelRGB = im.getpixel((i,j))
R,G,B = pixelRGB
brightness = int(sum([R,G,B])/3)
pixelRGB1 = im.getpixel((i,j+1))
R1,G1,B1 = pixelRGB
brightness1 = int(sum([R1,G1,B1])/3)
Horizontal[brightness,brightness1]+=1
Vertical = np.zeros((256, 256))
for i in range (0,im.size[0]-1):
for j in range (0,im.size[1]):
pixelRGB = im.getpixel((i,j))
R,G,B = pixelRGB
brightness = int(sum([R,G,B])/3)
pixelRGB1 = im.getpixel((i+1,j))
R1,G1,B1 = pixelRGB
brightness1 = int(sum([R1,G1,B1])/3)
Vertical[brightness,brightness1]+=1
return Horizontal,Vertical
</code></pre>
<p>And this is what I do exactly</p>
<pre><code>horiz,vertic=calculateCooccurrence(im2)
horizon=nullify(horiz)
</code></pre>
| [
{
"answer_id": 74465482,
"author": "user20284150",
"author_id": 20284150,
"author_profile": "https://Stackoverflow.com/users/20284150",
"pm_score": 2,
"selected": true,
"text": ":crlf"
},
{
"answer_id": 74466235,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 2,
"selected": false,
"text": "@"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515534/"
] |
74,454,329 | <p>I have 2 Pages with almost identical code behind (.xaml.cs file). They have different layout though (.xaml files are different). In Code-behind file, the only difference is the type of the variable. All other procedures/functions are exactly the same.</p>
<p>For example:</p>
<p>Page1:</p>
<pre class="lang-cs prettyprint-override"><code>public sealed partial class Page1 : Page
{
public List<CarVersion1> cars = new List<CarVersion1>();
public CarVersion1 currentCar;
...
private UpdatePrice(int p) {
currentCar.Price = p;
}
}
</code></pre>
<p>Page2:</p>
<pre class="lang-cs prettyprint-override"><code>public sealed partial class Page2 : Page
{
public List<CarVersion2> cars = new List<CarVersion2>();
public CarVersion2 currentCar;
...
private UpdatePrice(int p) {
currentCar.Price = p;
}
}
</code></pre>
<p>Is there anyway to use just 1 code-behind file instead of duplicating it?</p>
| [
{
"answer_id": 74465482,
"author": "user20284150",
"author_id": 20284150,
"author_profile": "https://Stackoverflow.com/users/20284150",
"pm_score": 2,
"selected": true,
"text": ":crlf"
},
{
"answer_id": 74466235,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 2,
"selected": false,
"text": "@"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16598341/"
] |
74,454,333 | <p>I'm trying to make a query in which the records that have the priority column > 0 can be sorted by ASC priority, and the records that the priority column is 0, sorted by id DESC.</p>
<p>The way I did it works, but the DESC id ordering is being listed first than the priority order. Thus, the records with priority 0 are first. How to make the records with priority first?</p>
<p>see the code</p>
<p><code>select * from registros ORDER BY CASE WHEN prioridade > 0 THEN prioridade END ASC, id DESC</code></p>
| [
{
"answer_id": 74465482,
"author": "user20284150",
"author_id": 20284150,
"author_profile": "https://Stackoverflow.com/users/20284150",
"pm_score": 2,
"selected": true,
"text": ":crlf"
},
{
"answer_id": 74466235,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 2,
"selected": false,
"text": "@"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6826654/"
] |
74,454,370 | <p>The props on the 'GameState' component do not update correctly after changing their state from, they are always one iteration behind what the actual value of the state is as shown in the GIF and the sate is always one iteration behind when I try console.logging it too</p>
<p><a href="https://i.stack.imgur.com/siUDF.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/siUDF.gif" alt="enter image description here" /></a></p>
<pre><code>import GameInfo from './components/GameInfo';
import GameState from './components/GameState';
import InputField from './components/InputField';
import StartButton from './components/StartButton';
import TheWord from './components/TheWord';
import WordsBox from './components/WordsBox';
function App() {
const [currentDifficulty, setCurrentDifficulty] = useState({
time: 7,
wordCount: 15,
});
const changeDifficultyHandler = (difficulty) => {
setCurrentDifficulty(difficulty);
};
return (
<div>
<header>
Type Master
</header>
<main>
<GameInfo onChangeDifficulty={changeDifficultyHandler} />
<TheWord />
<InputField />
<StartButton />
<WordsBox />
<GameState difficulty={currentDifficulty} />
</main>
</div>
);
}
export default App;
</code></pre>
<pre><code>import React from 'react';
const GameState = (props) => {
return (
<div>
<div>Time Left: {props.difficulty.time} Seconds</div>
<div>Score: 0 From {props.difficulty.wordCount}</div>
</div>
);
};
export default GameState;
</code></pre>
<p>expected values:</p>
<pre><code> const levels = {
Easy: {
time: 7,
wordCount: 15,
},
Normal: {
time: 5,
wordCount: 25,
},
Hard: {
time: 3,
wordCount: 30,
},
};
</code></pre>
<p>Code at the GameInfo component:</p>
<pre><code>import { useState } from 'react';
const GameInfo = (props) => {
const levels = {
Easy: {
time: 7,
wordCount: 15,
},
Normal: {
time: 5,
wordCount: 25,
},
Hard: {
time: 3,
wordCount: 30,
},
};
const [difficulty, setDifficulty] = useState(levels.Easy);
const changeDifficultyHandler = (event) => {
setDifficulty(levels[event.target.value]);
props.onChangeDifficulty(difficulty);
};
return (
<div>
You Are Playing On The{' '}
<span>
[
<select onChange={changeDifficultyHandler}>
<option value='Easy'>Easy</option>
<option value='Normal'>Normal</option>
<option value='Hard'>Hard</option>
</select>
]
</span>{' '}
Difficulity & You Have{' '}
<span className='text-main font-poppins font-bold'>
[ {difficulty.time} ]
</span>{' '}
Seconds To Type The Word.
</div>
);
};
export default GameInfo;
</code></pre>
| [
{
"answer_id": 74465482,
"author": "user20284150",
"author_id": 20284150,
"author_profile": "https://Stackoverflow.com/users/20284150",
"pm_score": 2,
"selected": true,
"text": ":crlf"
},
{
"answer_id": 74466235,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 2,
"selected": false,
"text": "@"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19326001/"
] |
74,454,374 | <p>I would like to ask is it possible to update/edit RTL languages with placeholders?</p>
<p>Other languages will correctly display the <strong>%1$s</strong> placeholder but in RTL languages is <strong>s$1%</strong>. Hence, it will crash if the placeholder will be replaced using</p>
<pre><code>getString(R.string.sample, "mystring");
</code></pre>
<p>Is there any other way?</p>
| [
{
"answer_id": 74454435,
"author": "hmn727",
"author_id": 15834499,
"author_profile": "https://Stackoverflow.com/users/15834499",
"pm_score": 1,
"selected": false,
"text": "TextView.setText(<the result of concatenation>)"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6559277/"
] |
74,454,377 | <p>I am running <code>npm install</code> commands and it is failing with error:</p>
<pre><code>npm ERR! code 1
npm ERR! path /Users/alex/Documents/serviceName/node_modules/platform-tracer/node_modules/ls-trace
npm ERR! command failed
npm ERR! command sh -c node scripts/post_install.js
npm ERR! Extracting prebuilt binaries.
npm ERR! Extraction of prebuilt binaries failed.
npm ERR! node:internal/process/promises:289
npm ERR! triggerUncaughtException(err, true /* fromPromise */);
npm ERR! ^
npm ERR!
npm ERR! [Error: ENOENT: no such file or directory, stat 'prebuilds.tgz'] {
npm ERR! errno: -2,
npm ERR! code: 'ENOENT',
npm ERR! syscall: 'stat',
npm ERR! path: 'prebuilds.tgz'
npm ERR! }
npm ERR!
npm ERR! Node.js v19.0.1
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/alex/.npm/_logs/2022-11-16T02_01_25_429Z-debug-0.log
</code></pre>
<p>I tried many things like uninstall the node and npm packages and then again reinstall them. And also tried <code>npm cache verify</code>.</p>
<p>I just want to install npm packages.</p>
<p>Node Version: 19.0.1
NPM version: 9.1.1</p>
<p>I tried on previous versions also but it doesn't work so updated to the latest but results are same.</p>
| [
{
"answer_id": 74454435,
"author": "hmn727",
"author_id": 15834499,
"author_profile": "https://Stackoverflow.com/users/15834499",
"pm_score": 1,
"selected": false,
"text": "TextView.setText(<the result of concatenation>)"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19548661/"
] |
74,454,393 | <p>I'm trying to convert <code>mp4</code> video file to <code>m4a</code> audio format by <code>AVAssetExportSession</code> on my <strong>iOS app</strong>.</p>
<p>This is the conversion code:</p>
<pre class="lang-swift prettyprint-override"><code>let outputUrl = URL(fileURLWithPath: NSTemporaryDirectory() + "out.m4a")
if FileManager.default.fileExists(atPath: outputUrl.path) {
try? FileManager.default.removeItem(atPath: outputUrl.path)
}
let asset = AVURLAsset(url: inputUrl)
// tried the `AVAssetExportPresetAppleM4A` preset name but the same result
let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetPassthrough)!
exportSession.outputFileType = AVFileType.m4a
exportSession.outputURL = outputUrl
await exportSession.export()
switch exportSession.status {
case .completed:
return outputUrl
default:
// This becomes `4` which is `.failed`
print("Status: \(exportSession.status)")
throw exportSession.error!
}
</code></pre>
<p>Currently, it seems to work on iPhone simulators (confirmed on iOS 16.1/15.5) but it doesn't on my iPhone 7 (iOS 15.7.1) real device. It doesn't seem to work as well on my colleague's iOS 16.1 real device, so it shouldn't be a matter of the iOS version.</p>
<p>The mp4 file is located in the iOS Files app and the <code>inputUrl</code> in the above code becomes something like this (I get this URL via <code>UIDocumentPickerViewController</code>):</p>
<ul>
<li><code>file:///private/var/mobile/Library/Mobile%20Documents/com~apple~CloudDocs/Downloads/%E3%81%8A%E3%81%97%E3%82%83%E3%81%B8%E3%82%99%E3%82%8A%E3%81%B2%E3%82%8D%E3%82%86%E3%81%8D.mp4</code></li>
</ul>
<p>and the error is:</p>
<ul>
<li><code>Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x2808f30c0 {Error Domain=NSOSStatusErrorDomain Code=-16979 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16979), NSLocalizedRecoverySuggestion=XXXXDEFAULTVALUEXXXX, NSURL=file:///private/var/mobile/Library/Mobile%20Documents/com~apple~CloudDocs/Downloads/%E3%81%8A%E3%81%97%E3%82%83%E3%81%B8%E3%82%99%E3%82%8A%E3%81%B2%E3%82%8D%E3%82%86%E3%81%8D.mp4, NSLocalizedDescription=The operation could not be completed}</code></li>
</ul>
| [
{
"answer_id": 74455724,
"author": "Toru",
"author_id": 4834226,
"author_profile": "https://Stackoverflow.com/users/4834226",
"pm_score": 1,
"selected": true,
"text": "startAccessingSecurityScopedResource()"
},
{
"answer_id": 74458350,
"author": "keyur kathrotiya",
"author_id": 10363229,
"author_profile": "https://Stackoverflow.com/users/10363229",
"pm_score": 1,
"selected": false,
"text": " \n\nfunc extractAudioFromVideo(videoUrl:URL) {\n \n let mixComposition: AVMutableComposition = AVMutableComposition()\n var mutableCompositionAudioVideoTrack: [AVMutableCompositionTrack] = []\n let videoAsset: AVAsset = AVAsset(url: videoUrl)\n \n if let audioVideoTrack = mixComposition.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid){\n \n mutableCompositionAudioVideoTrack.append(audioVideoTrack)\n \n if let audioVideoAssetTrack: AVAssetTrack = videoAsset.tracks(withMediaType: .audio).first {\n do {\n try mutableCompositionAudioVideoTrack.first?.insertTimeRange(CMTimeRangeMake(start: CMTime.zero, duration: videoAsset.duration), of: audioVideoAssetTrack, at: CMTime.zero)\n } catch {\n print(error)\n }\n }\n \n }\n \n if let documentsPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first {\n let outputURL = URL(fileURLWithPath: documentsPath).appendingPathComponent(\".m4a\")\n do {\n if FileManager.default.fileExists(atPath: outputURL.path) {\n try FileManager.default.removeItem(at: outputURL)\n }\n } catch { }\n \n \n if let exportSession = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetAppleM4A) {\n exportSession.outputURL = outputURL\n exportSession.outputFileType = AVFileType.m4a\n exportSession.shouldOptimizeForNetworkUse = true\n exportSession.exportAsynchronously(completionHandler: {\n \n switch exportSession.status {\n \n case . completed:\n \n DispatchQueue.main.async {\n print(\"audio url :---- \\(outputURL)\")\n // -------- play output audio URL in player ------\n }\n \n case .failed:\n if let _error = exportSession.error {\n print(_error.localizedDescription)\n }\n \n case .cancelled:\n if let _error = exportSession.error {\n print(_error.localizedDescription)\n }\n \n default:\n print(\"\")\n }\n })\n }\n \n }\n \n }\n\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4834226/"
] |
74,454,482 | <p>In my flutter app, I have a home_screen.dart where there is a Scaffold and ListView inside it is children with the container. I have created a bottom bar in a separate file and I wanted to add it to the home_screen page and to be fixed it there, but I am getting the below error:</p>
<pre><code>I/flutter (25157): RenderRepaintBoundary object was given an infinite size during layout.
I/flutter (25157): This probably means that it is a render object that tries to be as big as possible, but it was put inside another render object that allows its children to pick their own size.
I/flutter (25157): The nearest ancestor providing an unbounded height constraint is: RenderIndexedSemantics#cb38f relayoutBoundary=up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
I/flutter (25157): creator: IndexedSemantics ← _SelectionKeepAlive ← NotificationListener<KeepAliveNotification> ← KeepAlive ← AutomaticKeepAlive ← KeyedSubtree ← SliverList ← MediaQuery ← SliverPadding ← Viewport ← IgnorePointer-[GlobalKey#2f499] ← Semantics ← ⋯
I/flutter (25157): parentData: index=2; layoutOffset=None (can use size)
I/flutter (25157): constraints: BoxConstraints(w=411.4, 0.0<=h<=Infinity)
I/flutter (25157): size: MISSING
I/flutter (25157): index: 2
I/flutter (25157): The constraints that applied to the RenderRepaintBoundary were:
I/flutter (25157): BoxConstraints(w=411.4, 0.0<=h<=Infinity)
I/flutter (25157): The exact size it was given was:
I/flutter (25157): Size(411.4, Infinity)
</code></pre>
<p>Here is the home_screen</p>
<pre><code>@Override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Styles.bgColor,
body: ListView(
children: [
Container(
padding: const EdgeInsets.symmetric (horizontal: 20),
child: Column(
children: [
const Gap (40),
Row (...), // Row
const Gap (20),
Container (...), // Container
const Gap (20),
Container(...), // Container
const Gap (20),
Container (...) // Container
],
), // Column
), // Container
const Gap (25),
const BottomBar(), <---------------------- Error is from here its placement
],
), // ListView
); // Scaffold
}
</code></pre>
<p>Here is the bottombar:</p>
<pre><code>class BottomBar extends StatefulWidget {
const BottomBar({Key? key}) : super(key: key);
@override
State<BottomBar> createState() => _BottomBarState();}
class _BottomBarState extends State<BottomBar> {
int _selectedIndex = 0;
static final List<Widget> _widgetOptions = <Widget>[
HomeScreen(),
const Text("1"),
const Text("2"),
const Text("3") ];
..........................
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: _widgetOptions[_selectedIndex],
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _selectedIndex,
onTap: _onItemTapped,
..........................
elevation: 10,
items: const [
BottomNavigationBarItem(),
BottomNavigationBarItem(),
BottomNavigationBarItem(),
BottomNavigationBarItem()
], ), ); }}
</code></pre>
<p>How to fix this error to keep the bottom bar showing on the home screen</p>
| [
{
"answer_id": 74455724,
"author": "Toru",
"author_id": 4834226,
"author_profile": "https://Stackoverflow.com/users/4834226",
"pm_score": 1,
"selected": true,
"text": "startAccessingSecurityScopedResource()"
},
{
"answer_id": 74458350,
"author": "keyur kathrotiya",
"author_id": 10363229,
"author_profile": "https://Stackoverflow.com/users/10363229",
"pm_score": 1,
"selected": false,
"text": " \n\nfunc extractAudioFromVideo(videoUrl:URL) {\n \n let mixComposition: AVMutableComposition = AVMutableComposition()\n var mutableCompositionAudioVideoTrack: [AVMutableCompositionTrack] = []\n let videoAsset: AVAsset = AVAsset(url: videoUrl)\n \n if let audioVideoTrack = mixComposition.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid){\n \n mutableCompositionAudioVideoTrack.append(audioVideoTrack)\n \n if let audioVideoAssetTrack: AVAssetTrack = videoAsset.tracks(withMediaType: .audio).first {\n do {\n try mutableCompositionAudioVideoTrack.first?.insertTimeRange(CMTimeRangeMake(start: CMTime.zero, duration: videoAsset.duration), of: audioVideoAssetTrack, at: CMTime.zero)\n } catch {\n print(error)\n }\n }\n \n }\n \n if let documentsPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first {\n let outputURL = URL(fileURLWithPath: documentsPath).appendingPathComponent(\".m4a\")\n do {\n if FileManager.default.fileExists(atPath: outputURL.path) {\n try FileManager.default.removeItem(at: outputURL)\n }\n } catch { }\n \n \n if let exportSession = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetAppleM4A) {\n exportSession.outputURL = outputURL\n exportSession.outputFileType = AVFileType.m4a\n exportSession.shouldOptimizeForNetworkUse = true\n exportSession.exportAsynchronously(completionHandler: {\n \n switch exportSession.status {\n \n case . completed:\n \n DispatchQueue.main.async {\n print(\"audio url :---- \\(outputURL)\")\n // -------- play output audio URL in player ------\n }\n \n case .failed:\n if let _error = exportSession.error {\n print(_error.localizedDescription)\n }\n \n case .cancelled:\n if let _error = exportSession.error {\n print(_error.localizedDescription)\n }\n \n default:\n print(\"\")\n }\n })\n }\n \n }\n \n }\n\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13176726/"
] |
74,454,510 | <p>Here is my sample data frame. The actual data frame has a lot more groups and 9 conditions in each group.</p>
<pre><code>df <- data.frame(
Group = c('A','A','B','B','B','C','C','C','D','D','D','D'),
Condition = c('cond2', 'cond3','cond1','cond2','cond3','cond1','cond2','cond3', 'cond1','cond2','cond3','cond4'),
Value = c(0,0,0,1,0,0,0,1,0,1,0,0)
)
</code></pre>
<pre><code>> df
Group Condition Value
1 A cond2 0
2 A cond3 0
3 B cond1 0
4 B cond2 1
5 B cond3 0
6 C cond1 0
7 C cond2 0
8 C cond3 1
9 D cond1 0
10 D cond2 1
11 D cond3 0
12 D cond4 0
</code></pre>
<h1>Question I: groups match the conditions</h1>
<p>Get the groups that exactly have <code>cond1 == 0</code>, <code>cond2 == 1</code>, and <code>cond3 == 0</code> (in this case, group <code>B</code> meets the criteria).</p>
<p>The desired output:</p>
<pre><code> Group Condition Value
1 B cond1 0
2 B cond2 1
3 B cond3 0
</code></pre>
<h1>Question II: groups contain the condtions</h1>
<p>Get the groups that contain <code>cond1 == 0</code> and <code>cond2 == 1</code>, other <code>cond</code>s could be <code>1</code> or <code>0</code> (in this case, group <code>B</code> and group <code>D</code> should be selected. Please note that group <code>C</code> doesn't meet the criterion because it has <code>cond2 == 0</code>).</p>
<pre><code> Group Condition Value
1 B cond1 0
2 B cond2 1
3 B cond3 0
4 D cond1 0
5 D cond2 1
6 D cond3 0
7 D cond4 0
</code></pre>
| [
{
"answer_id": 74454718,
"author": "onyambu",
"author_id": 8380272,
"author_profile": "https://Stackoverflow.com/users/8380272",
"pm_score": 1,
"selected": false,
"text": "v <- c('cond1==0', 'cond2==1','cond3==0')\n\nsubset(df, ave(paste(Condition, Value, sep = '==')%in% v, Group, FUN = all))\n\n Group Condition Value\n3 B cond1 0\n4 B cond2 1\n5 B cond3 0\n"
},
{
"answer_id": 74457360,
"author": "Shawn Hemelstrand",
"author_id": 16631565,
"author_profile": "https://Stackoverflow.com/users/16631565",
"pm_score": 0,
"selected": false,
"text": "#### Load Library ####\nlibrary(dplyr)\n\n#### Filter ####\ndf %>% \n filter(Group == \"B\")\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7816373/"
] |
74,454,557 | <p>I can capture the output of a julia script in the shell with the > operator, for example:</p>
<p><code>$ julia script.jl > output.txt</code></p>
<p>However, it seems that the file is only written to after the julia script finished. For example, if <code>script.jl</code> contains the following code:</p>
<pre><code>println("Hello world!)
sleep(10)
</code></pre>
<p>then <code>output.txt</code> is created immediately, but the <code>Hello world!</code> appears in the file only after 10 seconds.</p>
<p>Is there a way to immediately write the Julia output to the file as soon as each command is executed and not wait for the script to finish?</p>
| [
{
"answer_id": 74454602,
"author": "August",
"author_id": 2498956,
"author_profile": "https://Stackoverflow.com/users/2498956",
"pm_score": 3,
"selected": true,
"text": "println(\"Hello world!\")\nflush(stdout)\nsleep(10)\n"
},
{
"answer_id": 74457320,
"author": "user1934428",
"author_id": 1934428,
"author_profile": "https://Stackoverflow.com/users/1934428",
"pm_score": 0,
"selected": false,
"text": "stdbuf -o0 julia script.jl > output.txt\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5538808/"
] |
74,454,586 | <p>Transform table from rows to columns</p>
<p><strong>Existing table A</strong></p>
<p><a href="https://i.stack.imgur.com/Stot2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Stot2.png" alt="enter image description here" /></a></p>
<p>How do i transform from the first table to the second table below?</p>
<p><strong>Expected results</strong></p>
<p><a href="https://i.stack.imgur.com/0Xr1X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Xr1X.png" alt="enter image description here" /></a></p>
<p>If i do something like the following sql statement, i only get them in separate rows instead of the related ones in a single row</p>
<pre><code>SELECT
CASE WHEN LENGTH(CODE) = 2 THEN NAME
ELSE NULL
END AS CODE1,
CASE WHEN LENGTH(CODE) = 4 THEN NAME
ELSE NULL
END AS CODE2,
CASE WHEN LENGTH(CODE) = 6 THEN NAME
ELSE NULL
END AS CODE3,
CASE WHEN LENGTH(CODE) = 8 THEN NAME
ELSE NULL
END AS CODE4
FROM TABLEA;
</code></pre>
<p><a href="https://i.stack.imgur.com/Pg7lF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pg7lF.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74454602,
"author": "August",
"author_id": 2498956,
"author_profile": "https://Stackoverflow.com/users/2498956",
"pm_score": 3,
"selected": true,
"text": "println(\"Hello world!\")\nflush(stdout)\nsleep(10)\n"
},
{
"answer_id": 74457320,
"author": "user1934428",
"author_id": 1934428,
"author_profile": "https://Stackoverflow.com/users/1934428",
"pm_score": 0,
"selected": false,
"text": "stdbuf -o0 julia script.jl > output.txt\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16186987/"
] |
74,454,620 | <p>I can define a struct type that uses a generic type parameter with a trait bound:</p>
<pre class="lang-rust prettyprint-override"><code>struct MyStruct<T: Clone> {
field: T,
}
</code></pre>
<p>This prevents me me from instantiating <code>MyStruct</code> with a generic type which does not meet the trait bound:</p>
<pre class="lang-rust prettyprint-override"><code>// Note: does not implement Clone
struct UnitStruct;
fn main() {
// ERROR: Unsatisfied trait bound: UnitStruct: Clone
let s = MyStruct { field: UnitStruct };
}
</code></pre>
<p>But why would I want to define my struct this way? What are the use cases of imposing such limitations on the instantiation of <code>MyStruct</code>?</p>
<p>I noticed that even with the trait bound in the <code>MyStruct</code> definition, if I define an interface which <em>uses</em> <code>MyStruct</code>, I still have to repeat the trait bound:</p>
<pre class="lang-rust prettyprint-override"><code>// This works
fn func<T: Clone>(s: MyStruct<T>) -> T { s.field.clone() }
// This does not. Compiler demands a trait bound for `T`
fn func<T>(s: MyStruct<T>) -> T { s.field.clone() }
</code></pre>
| [
{
"answer_id": 74454839,
"author": "Locke",
"author_id": 5987669,
"author_profile": "https://Stackoverflow.com/users/5987669",
"pm_score": 2,
"selected": false,
"text": "impl<T: A + B + C + Etc> for Foo<T>"
},
{
"answer_id": 74456509,
"author": "YthanZhang",
"author_id": 12830907,
"author_profile": "https://Stackoverflow.com/users/12830907",
"pm_score": 1,
"selected": false,
"text": "/// This function doesn't compile, because T cannot be cloned\nfn clone_and_return1<T>(t: &T) -> T {\n t.clone()\n}\n\n/// This compiles, because we limit T to types that implements Clone\nfn clone_and_return2<T>(t: &T) -> T\nwhere\n T: Clone,\n{\n t.clone()\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3311728/"
] |
74,454,628 | <p>I have 2 sequences a:seq and b:seq, I wonder if we use the function, how we can determine that the element at this index in seq a is equal to element at this index in seq b</p>
<pre><code>function test(s:seq<nat>, u:seq<nat>): nat
ensures |s|>0
ensures |u|>0
ensures |s| == |u|
{
// Code
}
method Testing()
{
var sys:seq<nat> := [4,2,9,3,1];
var usr:seq<nat> := [1,2,3,4,5];
assert test(sys, usr) == 1
// The element at the index 2 of sys and usr are equal, so it have 1 element that match in both 2 sequence
}
</code></pre>
<p>Because of the function I could not create a while loop, so I can not do the basic logic on that, so I wonder if there's something that fit the requirement.</p>
| [
{
"answer_id": 74455163,
"author": "Giang Hoa Tran",
"author_id": 20515834,
"author_profile": "https://Stackoverflow.com/users/20515834",
"pm_score": 1,
"selected": false,
"text": "function bullspec(s:seq<nat>, u:seq<nat>): nat\n requires |s| > 0\n requires |u| > 0\n requires |s| == |u|\n{\n var index:=0;\n if |s| == 1 then (\n if s[0]==u[0] \n then 1 else 0\n ) else (\n if s[index] != u[index] \n then bullspec(s[index+1..],u[index+1..]) \n else 1+bullspec(s[index+1..],u[index+1..])\n )\n}\n"
},
{
"answer_id": 74465657,
"author": "Mikaël Mayer",
"author_id": 1287856,
"author_profile": "https://Stackoverflow.com/users/1287856",
"pm_score": 1,
"selected": true,
"text": "function bullspec(s:seq<nat>, u:seq<nat>): (r: nat)\n requires |s| == |u|\n // Ensures r is either a sequence index or the sequence length\n ensures r <= |s|\n // All the elements before r are different\n ensures forall i: nat | i < r :: s[i] != u[i]\n // Either r is the sequence length or the elements at index r are equal\n ensures r == |s| || s[r] == u[r]\n{\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515834/"
] |
74,454,648 | <p>Im trying to add asterisks at the beginning and end of each word but I keep getting undefined at the end of my new string. Thanks for the help in advance.</p>
<pre><code>function solution(s) {
var asterisks = "*"
var newString = ""
for(let i = 0; i <= s.length; i++){
if(s === ""){
return "*";
}else{
newString += asterisks + s[i];}
}
return newString;
}
</code></pre>
| [
{
"answer_id": 74454693,
"author": "Jiangqi Zhu",
"author_id": 20481199,
"author_profile": "https://Stackoverflow.com/users/20481199",
"pm_score": 2,
"selected": false,
"text": "for(let i = 0; i < s.length; i++)\n"
},
{
"answer_id": 74454717,
"author": "John",
"author_id": 11111119,
"author_profile": "https://Stackoverflow.com/users/11111119",
"pm_score": 0,
"selected": false,
"text": "for(let i = 0; i <= s.length; i++)"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20288631/"
] |
74,454,711 | <p>I am trying to write a script that creates and calls a stored procedure named <code>spInsertNewCategory</code> and getting this error on the following code:</p>
<pre><code>CREATE PROCEDURE spInsertCategory(category_name VARCHAR(50))
BEGIN
INSERT INTO Categories
VALUES (@CategoryName);
END
</code></pre>
<p><a href="https://i.stack.imgur.com/km9op.jpg" rel="nofollow noreferrer">enter image description here</a></p>
<p>Any help would be appreciated.</p>
<p>Also getting an error on the 50 that says it is expecting '(' or SELECT. This is the first time I have been completely lost on something. What am I doing wrong?</p>
<p>The code is supposed to be a single input parameter with no return value and I just don't know what to write.</p>
| [
{
"answer_id": 74454765,
"author": "Punit Gajjar",
"author_id": 5127330,
"author_profile": "https://Stackoverflow.com/users/5127330",
"pm_score": 0,
"selected": false,
"text": "DELIMITER //\nCREATE PROCEDURE spInsertCategory(IN category_name VARCHAR(50))\nBEGIN\nINSERT INTO Categories\nVALUES (@CategoryName);\nEND//\nDELIMITER ;\n"
},
{
"answer_id": 74454878,
"author": "D T",
"author_id": 1497597,
"author_profile": "https://Stackoverflow.com/users/1497597",
"pm_score": 1,
"selected": false,
"text": "CREATE PROCEDURE spInsertCategory @CategoryName VARCHAR(50)\nAS\nBEGIN\nINSERT INTO Categories\nVALUES (@CategoryName);\nEND \n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515875/"
] |
74,454,740 | <p>I currently want the top part of my webpage to have an image zooming out. However, this pushes all of the text that I have that includes buttons and my header. My background image is moving like I want it to, but my header and buttons are moving too and I don't want them to move at all.</p>
<pre><code> <div className="static-slider-head banner2">
<Container>
<Row className="">
<Col lg="6" md="6" className="align-self-center intro">
<h1 className="title">
Welcome
</h1>
<h4 className="subtitle font-light">
Filler Text
</h4>
<a
href="/"
className="btn btn-danger m-r-20 btn-md m-t-10 "
>
Filler Text
</a>
<a
href="/"
className="btn btn-success m-r-20 btn-md m-t-10 " target="_blank"
>
Filler Text <i className="fa fa-instagram"></i>
</a>
</Col>
<Col lg="6" md="6">
</Col>
</Row>
</Container>
</div>
</code></pre>
<pre><code>.static-slider-head {
min-height: 36.25rem;
display: flex;
flex-direction: column;
justify-content: center;
overflow: auto;
background-size: cover;
background-position: center center;
display: table;
width: 100%;
padding: 0;
background:linear-gradient(to bottom, rgba(0,0,0,0) 20%, rgba(0,0,0,1)), url('../../public/top2.png') center center no-repeat;
background-color: #e5e5e5;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
animation: scale 10s;
animation-fill-mode: forwards;
transform-origin: bottom right;
overflow: hidden;
.title {
color: $white;
font-weight: 700;
font-size: 70px;
line-height: 100px;
}
.subtitle {
color: $white;
line-height: 30px;
}
}
@keyframes scale {
0% {
transform: scale(1);
}
100% {
transform: scale(1.1);
}
}
</code></pre>
<p>My text and header all shift to the left. I want them to not move. I only want the image to move.</p>
| [
{
"answer_id": 74454765,
"author": "Punit Gajjar",
"author_id": 5127330,
"author_profile": "https://Stackoverflow.com/users/5127330",
"pm_score": 0,
"selected": false,
"text": "DELIMITER //\nCREATE PROCEDURE spInsertCategory(IN category_name VARCHAR(50))\nBEGIN\nINSERT INTO Categories\nVALUES (@CategoryName);\nEND//\nDELIMITER ;\n"
},
{
"answer_id": 74454878,
"author": "D T",
"author_id": 1497597,
"author_profile": "https://Stackoverflow.com/users/1497597",
"pm_score": 1,
"selected": false,
"text": "CREATE PROCEDURE spInsertCategory @CategoryName VARCHAR(50)\nAS\nBEGIN\nINSERT INTO Categories\nVALUES (@CategoryName);\nEND \n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515926/"
] |
74,454,741 | <p>Swapping two nos. by the use of pointers.</p>
<pre><code>int main()
{
int *a;
int *b;
a = 3;
b = 5;
*a=b;
*b=a;
printf("a=%d\n b=%d\n", *a, *b);
</code></pre>
<p>It is showing Segmentation fault at line "*a=b(7)"</p>
<p>I tried to introduce a new variable and assign it to *a and *b but it still shows the same error.</p>
| [
{
"answer_id": 74454815,
"author": "BanjoMan",
"author_id": 19604677,
"author_profile": "https://Stackoverflow.com/users/19604677",
"pm_score": -1,
"selected": false,
"text": "int x = 12"
},
{
"answer_id": 74455498,
"author": "William Pursell",
"author_id": 140750,
"author_profile": "https://Stackoverflow.com/users/140750",
"pm_score": 0,
"selected": false,
"text": "int"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20408702/"
] |
74,454,758 | <p>How to convert a string to an integer in JavaScript?</p>
<pre><code>const secrectNumber = 4;
button class="btn-number">01</button
button class="btn-number">02</button
button class="btn-number">03</button
button class="btn-number">04</button
button class="btn-number">05</button
$(".btn-number").click(function (e) {
if ($(this).text() === secretNumber) {
}
}
</code></pre>
<p>How do I convert button is string to number in JavaScript?</p>
| [
{
"answer_id": 74454815,
"author": "BanjoMan",
"author_id": 19604677,
"author_profile": "https://Stackoverflow.com/users/19604677",
"pm_score": -1,
"selected": false,
"text": "int x = 12"
},
{
"answer_id": 74455498,
"author": "William Pursell",
"author_id": 140750,
"author_profile": "https://Stackoverflow.com/users/140750",
"pm_score": 0,
"selected": false,
"text": "int"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515891/"
] |
74,454,764 | <p>I want to convert time in milisecond to my local time in ISO format.</p>
<pre><code>let time = 1668268800000
console.log(new Date(time).toISOString())
</code></pre>
<p>However this do not output my ISO date in my local time.</p>
| [
{
"answer_id": 74454857,
"author": "sleepystar96",
"author_id": 9824103,
"author_profile": "https://Stackoverflow.com/users/9824103",
"pm_score": 2,
"selected": true,
"text": "let time = 1668268800000\nlet utcDate = new Date(time)\nlocalTime = time - utcDate.getTimezoneOffset() * 60 * 1000\nlocalDate = new Date(localTime)\nlocalIso = localDate.toISOString()\nconsole.log(utcDate.toISOString(), localIso)\n"
},
{
"answer_id": 74458653,
"author": "Terry Lennox",
"author_id": 7237224,
"author_profile": "https://Stackoverflow.com/users/7237224",
"pm_score": 0,
"selected": false,
"text": "Date.getFullYear()"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13812691/"
] |
74,454,783 | <p>I am following a linked list problem in Eloquent JavaScript book and I don't understand how the value for the first link is 10 and not 20 if i is = 1, in the first iteration of the for loop.</p>
<pre><code>function arrayToList(array) {
let list = null;
for (let i = array.length - 1; i >= 0; i--) {
list = { value: array[i], rest: list }; //why is the value 10 and not 20 if i = 1,
}
return list;
}
console.log(arrayToList([10, 20]));
</code></pre>
<blockquote>
<p>{value: 10, rest: {value: 20, rest: null}}</p>
</blockquote>
<p>I think I am thinking of the for loop the wrong way, but I don't know where.</p>
| [
{
"answer_id": 74454857,
"author": "sleepystar96",
"author_id": 9824103,
"author_profile": "https://Stackoverflow.com/users/9824103",
"pm_score": 2,
"selected": true,
"text": "let time = 1668268800000\nlet utcDate = new Date(time)\nlocalTime = time - utcDate.getTimezoneOffset() * 60 * 1000\nlocalDate = new Date(localTime)\nlocalIso = localDate.toISOString()\nconsole.log(utcDate.toISOString(), localIso)\n"
},
{
"answer_id": 74458653,
"author": "Terry Lennox",
"author_id": 7237224,
"author_profile": "https://Stackoverflow.com/users/7237224",
"pm_score": 0,
"selected": false,
"text": "Date.getFullYear()"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20506688/"
] |
74,454,793 | <p>A similar kind of question (but in python version) to the question I would like to ask is given in the following hyperlink:
<a href="https://stackoverflow.com/questions/72531577/plotly-how-to-manually-assign-bar-colors-to-categorical-lables-in-go-bar">Plotly: How to manually assign bar colors to categorical lables in go.bar()</a></p>
<p>So basically my question is how do I always assign a specific colour to my bars no matter if or not that bar category has value or is 0. For example, if I always want the Supportive bar green, the Neutral bar yellow and the Resistant bar red, how do I achieve that? In both the following 2 data frames, dfA and dfB, I would like the colouring scheme of the categories to be as stated above (i.e., "Supportive" - Green, "Neutral" - Yellow, and "Resistant" - Red ):</p>
<pre><code>categories<-c('Supportive', 'Neutral', 'Resistant')
vals <- c(40, 25, 35)
categoriesB<-c('Supportive', 'Neutral', 'Resistant')
valsB <- c(40, 0, 35)
dfA <- data.frame(categories, vals)
dfB <- data.frame(categoriesB, valsB)
</code></pre>
<p>It is very important that even in dfB's case the colour of the bars to stay consistent with the colour of bars in dfA. Any help is much appreciated.</p>
| [
{
"answer_id": 74456209,
"author": "Luiy_coder",
"author_id": 9596339,
"author_profile": "https://Stackoverflow.com/users/9596339",
"pm_score": -1,
"selected": false,
"text": "library(tidyverse)\nlibrary(plotly)\n\ncategories = c('Supportive', 'Neutral', 'Resistant') \nvals = c(40, 25, 35)\n\ncategoriesB = c('Supportive', 'Neutral', 'Resistant') \nvalsB = c(40, 0, 35)\n\ndfA = data.frame(categories, vals)\ndfB = data.frame(categoriesB, valsB)\n\nfig = plot_ly(data = dfA, \n x = ~categories, \n y = ~vals, \n type = \"bar\",\n name = c('Supportive', 'Resistant', 'Neutral'),\n marker = list(color = c('#FF0000', '#FFFF00', '#00FF00'))) %>% \n layout(title = \"Categories Chart\")\nfig\n\nfig1 = plot_ly(data = dfB, \n x = ~categoriesB, \n y = ~valsB, \n type = \"bar\",\n name = c('Supportive', 'Resistant', 'Neutral'),\n marker = list(color = c('#FF0000', '#FFFF00', '#00FF00'))) %>% \n layout(title = \"Categories Chart\")\nfig1\n\n"
},
{
"answer_id": 74460948,
"author": "Dan Adams",
"author_id": 13210554,
"author_profile": "https://Stackoverflow.com/users/13210554",
"pm_score": 1,
"selected": true,
"text": "plot_ly"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18239212/"
] |
74,454,801 | <pre><code>import math
float(input("C"))
#c="speed of light" in m/s
float(input("V"))
#v="speed of mobile" in m/s
float(input("M"))
#m="mass of mobile" in Kg
1/math.sqrt((1-V/C)^2)==Gam2
print(Gam)
M*V==p
M*V*Gam==q
</code></pre>
<p>I checked the capitalization of the input float of "V", and they still match up, but I'm still getting an error.</p>
| [
{
"answer_id": 74454849,
"author": "MarianD",
"author_id": 7023590,
"author_profile": "https://Stackoverflow.com/users/7023590",
"pm_score": 0,
"selected": false,
"text": "float(input(\"C\"))\nfloat(input(\"V\"))\nfloat(input(\"M\"))\n"
},
{
"answer_id": 74454889,
"author": "BingBongnova",
"author_id": 20515939,
"author_profile": "https://Stackoverflow.com/users/20515939",
"pm_score": 1,
"selected": false,
"text": "import math \nC = float(input(\"C\"))\n#c=\"speed of light\" in m/s\nV = float(input(\"V\"))\n#v=\"speed of mobile\" in m/s\nM = float(input(\"M\"))\n#m=\"mass of mobile\" in Kg\nGam = 1 / math.sqrt(math.pow(1 - V / C, 2))\nprint(Gam)\np = M * V\nq = M * V * Gam \n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20516000/"
] |
74,454,807 | <p>Lets say I have the below enums declared</p>
<pre><code>public class Enums{
public enum A{
a1,
a2;
}
public enum B{
b1,
b2;
}
public enum C{
c1,
c2;
}
}
</code></pre>
<p>Now I want to pass a1,b1 and c1 to a constructor while creation of object</p>
<pre><code>Course c = new Course(a1,b1,c1);
</code></pre>
<p>How can pass these values like a list instead of typing all the enums. Can I do as below?</p>
<pre><code>
List<Enums> eValues = new ArrayList<Enums>();
eValues.add(A.valueOf("a1"));
eValues.add(B.value("b1"));
eValues.add(C.value("c1"));
//and then can I do as below?
Course c = new Course(eValues);
</code></pre>
<p>I am getting an error "no suitable method found for add(A)" while adding elements to list</p>
<p>Code on the Constructor side:</p>
<pre><code>public <T extends Enum<T>>Course(T[] eValues){
//some processing using those enums
}
</code></pre>
<p>Need help on how to add enums to a list and send it while object creation? and if possible how to receive them in the constructor</p>
| [
{
"answer_id": 74454974,
"author": "Dylan",
"author_id": 5351192,
"author_profile": "https://Stackoverflow.com/users/5351192",
"pm_score": 0,
"selected": false,
"text": "A"
},
{
"answer_id": 74454979,
"author": "rzwitserloot",
"author_id": 768644,
"author_profile": "https://Stackoverflow.com/users/768644",
"pm_score": 1,
"selected": false,
"text": "A"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14568608/"
] |
74,454,820 | <p>i am new to coding and trying to apply what I've learned to my work.</p>
<p>I have 7 sales record(by month) files in csv format, which i read by pd.read_csv().</p>
<p>Below is an example of what each file looks like.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th></th>
<th>Account A</th>
<th>Account B</th>
<th>Account C</th>
</tr>
</thead>
<tbody>
<tr>
<td>product 1</td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>product 2</td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>product 3</td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>product 4</td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
<p>What i am trying to achieve is to make separate dataframes for each product, with months as index and Account names as columns. Any suggestion on how can i perform this task?</p>
<p>Some people say that using list of list and appending data row by row is better than creating multiple empty data frames and appending data in them. so i created multiple lists for appending data in with the simple code below:</p>
<pre><code>product_name = ['product 1', 'product 2', 'product 3', 'product 4']
for name in product_name:
name = []
</code></pre>
<p>What should be the next steps in drawing data from the original sales record file and how can i append them to the empty list?</p>
<p>Afterward, should i use the code below to transform each list into dataframe?</p>
<pre><code>months = ['Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan', 'Feb', 'Mar']
account = ['Account A', 'Account B', 'Account C']
df = pd.DataFrame (name, columns = account, index = months)
</code></pre>
<p>And finally, may i know how can i save the final separated dataframes into separated files?</p>
<p>Thx!</p>
| [
{
"answer_id": 74454974,
"author": "Dylan",
"author_id": 5351192,
"author_profile": "https://Stackoverflow.com/users/5351192",
"pm_score": 0,
"selected": false,
"text": "A"
},
{
"answer_id": 74454979,
"author": "rzwitserloot",
"author_id": 768644,
"author_profile": "https://Stackoverflow.com/users/768644",
"pm_score": 1,
"selected": false,
"text": "A"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20281393/"
] |
74,454,821 | <p>I need to make 2 xPath(s) where it displays the Procedure's description:</p>
<ul>
<li>IF EVERY Step finished is equal to "True"</li>
<li>If only one of Step finished is true.</li>
</ul>
<p><strong>XML File:</strong></p>
<pre><code><Procedures>
<Procedure>
<description>Work1</description>
<Steps>
<Step finished="False" no="1">Step1</etape>
<Step finished="False" no="2">Step2</etape>
<Step finished="False" no="4">Step3</etape>
<Step finished="True" no="5">Step4</etape>
</Steps>
</Procedure>
</Procedures>
</code></pre>
<p><strong>What I've tried:</strong></p>
<ul>
<li>Expected to see the procedure's description if every step finished is equal to True but it does not work.
<code>XmlNodeList testList = doc.SelectNodes("//Procedure/description[//Step/@finished='True']");</code></li>
</ul>
| [
{
"answer_id": 74454974,
"author": "Dylan",
"author_id": 5351192,
"author_profile": "https://Stackoverflow.com/users/5351192",
"pm_score": 0,
"selected": false,
"text": "A"
},
{
"answer_id": 74454979,
"author": "rzwitserloot",
"author_id": 768644,
"author_profile": "https://Stackoverflow.com/users/768644",
"pm_score": 1,
"selected": false,
"text": "A"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18884000/"
] |
74,454,832 | <p>Have a data frame full of <code>species</code> names. I need to create a <code>species_code</code> variable that has the first 4 characters of the genus and the first 3 characters of the second part of the species name with no spaces.</p>
<p>Sometimes the second species name is not known and then it is abbreviated as "sp." or "spp." If it is "spp.", it breaks the rule of 3 characters (it has 4 incl. the period). In this case the ending should be "sp." as well.</p>
<p>Here is a step by step example and how I usually go about it. I am certain there are way more elegant solutions to this and I was hoping someone can help me with this. What I am wondering is:</p>
<p><strong>(a)</strong> is there another way instead of <code>str_match()</code> within the <code>stringr</code> package? I tried <code>str_extract()</code> but that doesn't extracts the matches within the parentheses, i.e. the pieces that I need (see <code>step2</code> below; can this be made more concise?!)</p>
<p><strong>(b)</strong> can <code>step3</code> be solved in the regex (see explanation in 2nd paragraph above)?</p>
<pre><code>tibble(
# species names
species = c("CALLIERGON GIGANTEUM", "CEPHALOZIELLA SP.", "LICHEN SPP."),
# how the species code should look like after the regex
species_code = c("CALLGIG", "CEPHSP.", "LICHSP.")
) %>%
mutate(
step1 = str_match(species, "(\\w{4})\\w*\\s+(\\w{1,3}\\.?)\\w*"),
step2 = paste0(step1[, 2], step1[, 3]),
step3 = str_replace(step2, "SPP.", "SP.")
) -> almost_done
almost_done
# A tibble: 3 × 5
# species species_code step1[,1] [,2] [,3] step2 step3
# <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#1 CALLIERGON GIGANTEUM CALLGIG CALLIERGON GIGANTEUM CALL GIG CALLGIG CALLGIG
#2 CEPHALOZIELLA SP. CEPHSP. CEPHALOZIELLA SP. CEPH SP. CEPHSP. CEPHSP.
#3 LICHEN SPP. LICHSP. LICHEN SPP. LICH SPP. LICHSPP. LICHSP.
almost_done %>%
select(!(3:4)) -> done
done
# A tibble: 3 × 3
# species species_code step3
# <chr> <chr> <chr>
#1 CALLIERGON GIGANTEUM CALLGIG CALLGIG
#2 CEPHALOZIELLA SP. CEPHSP. CEPHSP.
#3 LICHEN SPP. LICHSP. LICHSP.
</code></pre>
| [
{
"answer_id": 74454974,
"author": "Dylan",
"author_id": 5351192,
"author_profile": "https://Stackoverflow.com/users/5351192",
"pm_score": 0,
"selected": false,
"text": "A"
},
{
"answer_id": 74454979,
"author": "rzwitserloot",
"author_id": 768644,
"author_profile": "https://Stackoverflow.com/users/768644",
"pm_score": 1,
"selected": false,
"text": "A"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4308815/"
] |
74,454,850 | <p>I've been trying to run this minimal example to get <a href="https://rapier.rs/" rel="nofollow noreferrer">Rapier</a>'s physics working with <a href="https://bevyengine.org/" rel="nofollow noreferrer">Bevy</a>:</p>
<pre><code>use bevy::prelude::*;
use bevy_rapier2d::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
.run();
}
</code></pre>
<p>and it's failing:</p>
<pre><code>error[E0277]: the trait bound `bevy_rapier2d::plugin::RapierPhysicsPlugin: Plugin` is not satisfied
--> src/main.rs:8:21
|
8 | .add_plugin(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0))
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Plugin` is not implemented for `bevy_rapier2d::plugin::RapierPhysicsPlugin`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `Plugin`:
AnimationPlugin
AssetCountDiagnosticsPlugin<T>
AssetPlugin
AudioPlugin
BloomPlugin
CameraPlugin
CameraProjectionPlugin<T>
ColorMaterialPlugin
and 44 others
note: required by a bound in `bevy::prelude::App::add_plugin`
--> /home/techperson/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_app-0.9.0/src/app.rs:837:12
|
837 | T: Plugin,
| ^^^^^^ required by this bound in `bevy::prelude::App::add_plugin`
For more information about this error, try `rustc --explain E0277`.
</code></pre>
<p>Expected behavior is what is described in the <a href="https://rapier.rs/docs/user_guides/bevy_plugin/getting_started_bevy" rel="nofollow noreferrer">Rapier documentation</a>.</p>
<p>Some info:</p>
<pre><code>$ cargo version
cargo 1.66.0-beta.1 (7e484fc1a 2022-10-27)
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/techperson/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
beta-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
active toolchain
----------------
beta-x86_64-unknown-linux-gnu (default)
rustc 1.66.0-beta.1 (e080cc5a6 2022-11-01)
</code></pre>
<p>Relevant part of <code>Cargo.toml</code>:</p>
<pre><code>[dependencies]
bevy = "0.9.0"
bevy_rapier2d = "0.18.0"
</code></pre>
<p>I tried manually implementing the <code>Plugin</code> trait, but can't because its from a different crate:</p>
<pre><code>error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
--> src/main.rs:4:1
|
4 | impl Plugin for RapierPhysicsPlugin {}
| ^^^^^^^^^^^^^^^^-------------------
| | |
| | `bevy_rapier2d::plugin::RapierPhysicsPlugin` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
For more information about this error, try `rustc --explain E0117`.
</code></pre>
<p>I've also tried the <code>stable</code>, <code>beta</code>, and <code>nightly</code> toolchains. <code>beta</code> and <code>nightly</code> fail with the aforementioned error, and <code>stable</code> fails because <code>if-let</code> statements aren't stable.</p>
| [
{
"answer_id": 74454872,
"author": "naiveai",
"author_id": 4014075,
"author_profile": "https://Stackoverflow.com/users/4014075",
"pm_score": 3,
"selected": true,
"text": "0.9"
},
{
"answer_id": 74468537,
"author": "mareq",
"author_id": 5292184,
"author_profile": "https://Stackoverflow.com/users/5292184",
"pm_score": 1,
"selected": false,
"text": "bevy_rapier2d = { git = \"https://github.com/devil-ira/bevy_rapier\", branch = \"bevy-0.9\" }\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10113401/"
] |
74,454,852 | <p>Say I have a method, then <code>new</code> an object inside the method:</p>
<pre><code>void MyMethod() {
Obj* p = new Obj();
}
</code></pre>
<p>When the function ends, the pointer will be dropped because it's out of scope, and if I'm not returning the <code>p</code> pointer, that means there's no reference of this <code>Obj</code> object, why can't the compiler do the object deletion for us?</p>
<p>So there won't be a "memory leak" if people forget to do so.</p>
| [
{
"answer_id": 74454928,
"author": "Ben",
"author_id": 874660,
"author_profile": "https://Stackoverflow.com/users/874660",
"pm_score": 2,
"selected": false,
"text": "std::unique_ptr"
},
{
"answer_id": 74474751,
"author": "JoJoModding",
"author_id": 2694054,
"author_profile": "https://Stackoverflow.com/users/2694054",
"pm_score": 0,
"selected": false,
"text": "void bar(Obj* obj); //we do not know what this method does\n\nint MyMethod() {\n Obj* obj = new Obj();\n bar(obj);\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7904678/"
] |
74,454,860 | <p>I was trying to design something that sees if a string contains exactly another substring, and they contain non-alphanumeric</p>
<p>For example:</p>
<pre><code>const subStr = '#320';
const str1 = '#320 people';
const str2 = '#3202 people';
const str3 = "1#3202 people';
</code></pre>
<p>str1 should match because it contains exactly #320
str2 should not match because it contains an extra 2 at the end
str3 should not match because it contains an extra 1 at the front</p>
<p>I can't seem to figure something out that works</p>
| [
{
"answer_id": 74454928,
"author": "Ben",
"author_id": 874660,
"author_profile": "https://Stackoverflow.com/users/874660",
"pm_score": 2,
"selected": false,
"text": "std::unique_ptr"
},
{
"answer_id": 74474751,
"author": "JoJoModding",
"author_id": 2694054,
"author_profile": "https://Stackoverflow.com/users/2694054",
"pm_score": 0,
"selected": false,
"text": "void bar(Obj* obj); //we do not know what this method does\n\nint MyMethod() {\n Obj* obj = new Obj();\n bar(obj);\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20303945/"
] |
74,454,924 | <p>I can't find an answer for this anywhere, so here it goes.</p>
<p>In my html I have a slider, which has values from 0 to 10,000. It will be hard to get to a certain number by just going at it, so I added a couple of <code>span</code> elements that use <code>onclick" "</code> events that are supposed to add/subtract 1/10 depending on which one you press. In order for this to work, I need to retrieve the value of the slider, add/sub 1/10, and change the value of the slider. The problem with this, as from the title, is that I need a variable(at least I suppose), but when I use one, it for some reason sets it to the max value without quotes(" ") and doesn't change whenever I use them. This is confusing as it should be simple but stuff isn't working and I don't understand why. Here is my full code:</p>
<pre><code><!DOCTYPE HTML>
<html>
<head>
<title></title>
<style>
span {
margin: 8px;
font-size: 30px;
}
input[type="range"] {
margin-top: 15px;
}
</style>
</head>
<body>
<div style="text-align: center">
<span onclick="downTen()"><<</span>
<span onclick="downOne()">-</span>
<input type="range" id="range" min="0" max="10000" oninput="this.nextElementSibling.value = this.value">
<output>5000</output>
<span onclick="upOne()">+</span>
<span>>></span>
</div>
<script>
function downTen() {
let downDiez = document.getElementById("range").value;
downDiez -= 10;
document.getElementById("range").value = downDiez;
console.log(document.getElementById("range").value);
}
function downOne() {
let downUno = document.getElementById("range").value;
downUno -= 1;
document.getElementById("range").value = downUno;
console.log(document.getElementById("range").value);
}
function upOne() {
let upUno = document.getElementById("range").value;
upUno += 1;
document.getElementById("range").value = upUno;
console.log(document.getElementById("range").value);
}
function upTen() {
}
</script>
</body>
</html>
</code></pre>
<p>Please help as I need this for a fun project for myself and I gave myself a deadline. I hope this explains everything.</p>
<p>Edit: I've realized it works with subtraction, but addition is buggy.</p>
| [
{
"answer_id": 74454928,
"author": "Ben",
"author_id": 874660,
"author_profile": "https://Stackoverflow.com/users/874660",
"pm_score": 2,
"selected": false,
"text": "std::unique_ptr"
},
{
"answer_id": 74474751,
"author": "JoJoModding",
"author_id": 2694054,
"author_profile": "https://Stackoverflow.com/users/2694054",
"pm_score": 0,
"selected": false,
"text": "void bar(Obj* obj); //we do not know what this method does\n\nint MyMethod() {\n Obj* obj = new Obj();\n bar(obj);\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18897131/"
] |
74,454,929 | <p>i am trying to truncate a selected models from my application using <a href="https://www.yiiframework.com/doc/api/2.0/yii-db-activerecord#deleteAll()-detail" rel="nofollow noreferrer">deleteAll()</a></p>
<p>my controller:</p>
<p>there are a lot of models but i didn't include them for maintain as short.</p>
<pre><code><?php
namespace app\controllers;
use yii\web\Controller;
use app\models\Marks;
use app\models\ActivityHistory;
use app\models\Attendance;
use app\models\Students;
public function actionTruncate(){
$models = array("Marks","ActivityHistory","Attendance","Students");
foreach($models as $key=>$model){
$model::deleteAll();
}
exit;
}
</code></pre>
<p>this getting error that</p>
<blockquote>
<p>Class 'Marks' not found</p>
</blockquote>
<p>when i run individual query like <code>Marks::deleteAll();</code> it works.
how to solve this in loop?
and suggest me a good way to do this functionality</p>
| [
{
"answer_id": 74454928,
"author": "Ben",
"author_id": 874660,
"author_profile": "https://Stackoverflow.com/users/874660",
"pm_score": 2,
"selected": false,
"text": "std::unique_ptr"
},
{
"answer_id": 74474751,
"author": "JoJoModding",
"author_id": 2694054,
"author_profile": "https://Stackoverflow.com/users/2694054",
"pm_score": 0,
"selected": false,
"text": "void bar(Obj* obj); //we do not know what this method does\n\nint MyMethod() {\n Obj* obj = new Obj();\n bar(obj);\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13345208/"
] |
74,454,938 | <p>I have a sample dataframe:</p>
<pre><code>| ID | SampleColumn1| SampleColumn2 | SampleColumn3 | SampleColumn4 |
|:-- |:------------:| ------------ :| ------------ | ------------ |
| 1 |sample Apple | sample Cherry | sample Lime | sample Apple |
| 2 |sample Cherry | sample lemon | sample Grape | sample Cherry |
</code></pre>
<p>I would like to create a new DataFrame based off of this initial dataframe. Should one of several values in a list [Apple, Lime, Cherry, Guava, Pear] be in any of the columns for a row, it would <strong>appear as a 1 in the new dataframe for its column</strong>. I do not wish to get the frequency, just if one of the values of the values from the list are in the dataframe row, then it should be a 1, else it will be a 0. In this case, the output should be:</p>
<pre><code>| ID | Apple | Lime | Cherry | Guava | Pear |
| 1 | 1 | 1 | 1 | 0 | 0 |
| 2 | 0 | 0 | 1 | 0 | 0 |
</code></pre>
<p>Currently I have tried in going about in initially establishing the dataframe by creating the columns based off the list mentioned before (list=[Apple, Lime, Cherry, Guava, Pear]) and then using the find function for a string, transforming a series into a string for each row then using an if condition if the value has returned and equals the column name of the new dataframe. I am getting a logic error in this regard.</p>
| [
{
"answer_id": 74454928,
"author": "Ben",
"author_id": 874660,
"author_profile": "https://Stackoverflow.com/users/874660",
"pm_score": 2,
"selected": false,
"text": "std::unique_ptr"
},
{
"answer_id": 74474751,
"author": "JoJoModding",
"author_id": 2694054,
"author_profile": "https://Stackoverflow.com/users/2694054",
"pm_score": 0,
"selected": false,
"text": "void bar(Obj* obj); //we do not know what this method does\n\nint MyMethod() {\n Obj* obj = new Obj();\n bar(obj);\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10981685/"
] |
74,454,972 | <pre><code>3**2==9 ^ 3-2==4
False
True ^ False
TRUE
</code></pre>
<p>Why is the result of first line False while it should be True?</p>
| [
{
"answer_id": 74454928,
"author": "Ben",
"author_id": 874660,
"author_profile": "https://Stackoverflow.com/users/874660",
"pm_score": 2,
"selected": false,
"text": "std::unique_ptr"
},
{
"answer_id": 74474751,
"author": "JoJoModding",
"author_id": 2694054,
"author_profile": "https://Stackoverflow.com/users/2694054",
"pm_score": 0,
"selected": false,
"text": "void bar(Obj* obj); //we do not know what this method does\n\nint MyMethod() {\n Obj* obj = new Obj();\n bar(obj);\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20422327/"
] |
74,454,986 | <p>I have two different situation, in <strong>small</strong> DB with 200 Row (So Simple) and in <strong>large</strong> DB with 2,000,000,000 Row (And adding more rows every day) I want select one or more row so in this case, which one is better query for select?</p>
<p>example table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>code</th>
<th>x_key</th>
<th>group</th>
<th>name</th>
<th>title</th>
<th>other columns</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>aa</td>
<td>ak32d</td>
<td>g1</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<tr>
<td>200</td>
<td>zz</td>
<td>zgi32</td>
<td>g5</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
</tbody>
</table>
</div>
<p><strong>ID</strong> : primary
<strong>Code</strong> : index (not composite index)
<strong>x_Key</strong> : index (not composite index)
<strong>Group</strong> : for example 20 percent of rows in g5 group</p>
<p>so for example this is same table for small and large DB, which QUERY is better to select one or more row? (question mark is mean i put search value in queries)</p>
<p>in Small DB, One Row needed:</p>
<pre><code>SELECT name,title FROM table WHERE code=?
SELECT name,title FROM table WHERE code=? AND x_key=?
SELECT name,title FROM table WHERE code=? AND x_key=? AND group=?
SELECT name,title FROM table WHERE code=? LIMIT 1
SELECT name,title FROM table WHERE code=? AND x_key=? LIMIT 1
SELECT name,title FROM table WHERE code=? AND x_key=? AND group=? LIMIT 1
</code></pre>
<p>in Small DB, More than one Row needed:</p>
<pre><code>SELECT name,title FROM table WHERE group=?
SELECT name,title FROM table WHERE group=? AND name LIKE `%test`
</code></pre>
<p>&&</p>
<p>in Large DB, One Row needed:</p>
<pre><code>SELECT name,title FROM table WHERE code=?
SELECT name,title FROM table WHERE code=? AND x_key=?
SELECT name,title FROM table WHERE code=? AND x_key=? AND group=?
SELECT name,title FROM table WHERE code=? LIMIT 1
SELECT name,title FROM table WHERE code=? AND x_key=? LIMIT 1
SELECT name,title FROM table WHERE code=? AND x_key=? AND group=? LIMIT 1
</code></pre>
<p>in Large DB, More than one Row needed:</p>
<pre><code>SELECT name,title FROM table WHERE group=?
SELECT name,title FROM table WHERE group=? AND name LIKE `%test`
</code></pre>
<p>In small and large which one is better for SELECT, and even for UPDATE?</p>
| [
{
"answer_id": 74454928,
"author": "Ben",
"author_id": 874660,
"author_profile": "https://Stackoverflow.com/users/874660",
"pm_score": 2,
"selected": false,
"text": "std::unique_ptr"
},
{
"answer_id": 74474751,
"author": "JoJoModding",
"author_id": 2694054,
"author_profile": "https://Stackoverflow.com/users/2694054",
"pm_score": 0,
"selected": false,
"text": "void bar(Obj* obj); //we do not know what this method does\n\nint MyMethod() {\n Obj* obj = new Obj();\n bar(obj);\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19014207/"
] |
74,454,996 | <p>Given the array below, how can I return the element containing the max number?</p>
<pre><code>let ar = [["finalOrderData",1],["finalFabricData",3],["finalDecorationData",3],["finalHtData",3]]
</code></pre>
<p><strong>Expected Result</strong></p>
<pre><code>let ar = ["finalFabricData",3]
</code></pre>
<p>This is the function I'm trying with, but it only returns the number itself:</p>
<pre><code>function getMaxOf2DIndex(arr, idx) {
return Math.max.apply(null, arr.map(function (e) { return e[idx] }))
}
</code></pre>
<p>Appreciate any help!</p>
| [
{
"answer_id": 74455050,
"author": "sleepystar96",
"author_id": 9824103,
"author_profile": "https://Stackoverflow.com/users/9824103",
"pm_score": 2,
"selected": false,
"text": "let ar = [[\"finalOrderData\",1],[\"finalFabricData\",3],[\"finalDecorationData\",3],[\"finalHtData\",3]]\n\nvar maxNumber = ar[0]\n\nar.forEach((element) => maxNumber = element[1] > maxNumber[1] ? element : maxNumber)\n"
},
{
"answer_id": 74455080,
"author": "Ricky Mo",
"author_id": 10317684,
"author_profile": "https://Stackoverflow.com/users/10317684",
"pm_score": 2,
"selected": false,
"text": "let ar = [[\"finalOrderData\",1],[\"finalFabricData\",3],[\"finalDecorationData\",3],[\"finalHtData\",3]]\nlet result = ar.reduce((acc,cur) => !acc || cur[1] > acc[1] ? cur : acc, undefined);\nconsole.log(result);"
},
{
"answer_id": 74455086,
"author": "iyhc",
"author_id": 15300260,
"author_profile": "https://Stackoverflow.com/users/15300260",
"pm_score": 3,
"selected": true,
"text": "Array.sort()"
},
{
"answer_id": 74455121,
"author": "Shiham Samsudeen",
"author_id": 6488792,
"author_profile": "https://Stackoverflow.com/users/6488792",
"pm_score": 2,
"selected": false,
"text": " function getMaxOf2DIndex(arr, idx) {\n let maxItem = arr[0];\n \n arr.forEach((item, i) => {\n if(item[idx] >= maxItem[idx])\n maxItem = item; \n });\n \n return maxItem;\n}"
},
{
"answer_id": 74455175,
"author": "Ping",
"author_id": 20288037,
"author_profile": "https://Stackoverflow.com/users/20288037",
"pm_score": 0,
"selected": false,
"text": "const ar = [\n [\"finalOrderData\",1],\n [\"finalFabricData\",3],\n [\"finalDecorationData\",3],\n [\"finalHtData\",3]\n]\n\n// the 1st result of the biggest value:\nconst output1 = ar.sort((A,B) => B[1] - A[1])[0]\n\nconsole.log(output1)\n// output: [\"finalFabricData\",3]\n\n// the last result of the biggest value:\nconst output2 = ar.sort((A,B) => B[1] <= A[1] ? -1 : 1)[0]\n\nconsole.log(output2)\n// output: [\"finalHtData\",3]"
},
{
"answer_id": 74455519,
"author": "Abhishek Chandel",
"author_id": 4053624,
"author_profile": "https://Stackoverflow.com/users/4053624",
"pm_score": 0,
"selected": false,
"text": "ar.reduce((res, val) => Math.max(res[1],val[1]) === res[1] ? res : val );\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11832197/"
] |
74,454,997 | <p>I am using Processing to create a basketball game. I have managed to create the basketball game but I want to have a click to start home screen. I have made the graphic for the home screen but I am not sure how to integrate it into the game code. Any ideas on how to go about this. Thanks!</p>
<p>I found something on the internet related to this which was...</p>
<pre><code>if (started) {
//all the code for the game
} else {
// all the code for the start screen
if (keyDown("enter")) {
started = true;
}
}
</code></pre>
<p>Im not sure if this is leading me in the right direction or how I could necessarily use this.</p>
| [
{
"answer_id": 74455050,
"author": "sleepystar96",
"author_id": 9824103,
"author_profile": "https://Stackoverflow.com/users/9824103",
"pm_score": 2,
"selected": false,
"text": "let ar = [[\"finalOrderData\",1],[\"finalFabricData\",3],[\"finalDecorationData\",3],[\"finalHtData\",3]]\n\nvar maxNumber = ar[0]\n\nar.forEach((element) => maxNumber = element[1] > maxNumber[1] ? element : maxNumber)\n"
},
{
"answer_id": 74455080,
"author": "Ricky Mo",
"author_id": 10317684,
"author_profile": "https://Stackoverflow.com/users/10317684",
"pm_score": 2,
"selected": false,
"text": "let ar = [[\"finalOrderData\",1],[\"finalFabricData\",3],[\"finalDecorationData\",3],[\"finalHtData\",3]]\nlet result = ar.reduce((acc,cur) => !acc || cur[1] > acc[1] ? cur : acc, undefined);\nconsole.log(result);"
},
{
"answer_id": 74455086,
"author": "iyhc",
"author_id": 15300260,
"author_profile": "https://Stackoverflow.com/users/15300260",
"pm_score": 3,
"selected": true,
"text": "Array.sort()"
},
{
"answer_id": 74455121,
"author": "Shiham Samsudeen",
"author_id": 6488792,
"author_profile": "https://Stackoverflow.com/users/6488792",
"pm_score": 2,
"selected": false,
"text": " function getMaxOf2DIndex(arr, idx) {\n let maxItem = arr[0];\n \n arr.forEach((item, i) => {\n if(item[idx] >= maxItem[idx])\n maxItem = item; \n });\n \n return maxItem;\n}"
},
{
"answer_id": 74455175,
"author": "Ping",
"author_id": 20288037,
"author_profile": "https://Stackoverflow.com/users/20288037",
"pm_score": 0,
"selected": false,
"text": "const ar = [\n [\"finalOrderData\",1],\n [\"finalFabricData\",3],\n [\"finalDecorationData\",3],\n [\"finalHtData\",3]\n]\n\n// the 1st result of the biggest value:\nconst output1 = ar.sort((A,B) => B[1] - A[1])[0]\n\nconsole.log(output1)\n// output: [\"finalFabricData\",3]\n\n// the last result of the biggest value:\nconst output2 = ar.sort((A,B) => B[1] <= A[1] ? -1 : 1)[0]\n\nconsole.log(output2)\n// output: [\"finalHtData\",3]"
},
{
"answer_id": 74455519,
"author": "Abhishek Chandel",
"author_id": 4053624,
"author_profile": "https://Stackoverflow.com/users/4053624",
"pm_score": 0,
"selected": false,
"text": "ar.reduce((res, val) => Math.max(res[1],val[1]) === res[1] ? res : val );\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74454997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20516180/"
] |
74,455,077 | <p>I am trying to wrap my head around this behavior that I am seeing. I know that the structs get copied when they are moved around as they are ValueType. But I cannot understand why this sample code fails. Here is just a simple C# code to demonstrate the issue:</p>
<pre><code>public class MyClass
{
private MyStruct ms;
public MyClass()
{
ms = new MyStruct("");
}
public void Add(dynamic d)
{
ms.Add(d);
}
public void Print()
{
Console.WriteLine("L: " + ms.GetLength());
}
}
public struct MyStruct
{
private dynamic[] items;
public MyStruct(string junk)
{
items = new dynamic[0];
}
public int GetLength()
{
return items.Length;
}
public void Add(dynamic d)
{
Array.Resize<dynamic>(ref items, items.Length + 1);
items[items.Length - 1] = d;
}
}
</code></pre>
<p>By running the code below, I get wrong result. In debugger I can see that the item is added but it does not persist, which means I see "L: 0" twice (instead of "L: 0" and "L: 1"):</p>
<pre><code>MyClass mc = new MyClass();
mc.Print();
mc.Add("Test");
mc.Print();
</code></pre>
<p>I noticed that if in MyClass.Add, the ms.Add is called with a type other than "dynamic" ("string", for instance) it works fine. Something like this:</p>
<pre><code>public void Add(string d)
{
ms.Add(d);
}
</code></pre>
<p>or even this:</p>
<pre><code>public void Add(dynamic d)
{
string s = d.ToString();
ms.Add(s);
}
</code></pre>
<p>It makes me think that I am probably working on a copy, but if that is the case, I do not understand why. I am accessing the field directly so I do not expect this to happen.</p>
<p>Thank you very much in advance.</p>
| [
{
"answer_id": 74455382,
"author": "liwuen",
"author_id": 2452314,
"author_profile": "https://Stackoverflow.com/users/2452314",
"pm_score": 0,
"selected": false,
"text": "MyClass"
},
{
"answer_id": 74455555,
"author": "Klaus Gütter",
"author_id": 2142950,
"author_profile": "https://Stackoverflow.com/users/2142950",
"pm_score": 2,
"selected": true,
"text": "dynamic"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20515910/"
] |
74,455,101 | <p>I want to capitalize each first letter from a sentence for Flutter..??</p>
<p><strong>This is a capitalized sentence</strong>
I'm expecting from <strong>This Is A Capitalized Sentence</strong></p>
| [
{
"answer_id": 74455142,
"author": "Nice umang",
"author_id": 10835478,
"author_profile": "https://Stackoverflow.com/users/10835478",
"pm_score": 0,
"selected": false,
"text": "extension StringExtension on String {\n String capitalize() {\n return \"${this[0].toUpperCase()}${this.substring(1).toLowerCase()}\";\n }\n}\n"
},
{
"answer_id": 74455185,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https://Stackoverflow.com/users/18670641",
"pm_score": 0,
"selected": false,
"text": "extension StringExtension on String {\n"
},
{
"answer_id": 74455302,
"author": "Vignesh KM",
"author_id": 4646166,
"author_profile": "https://Stackoverflow.com/users/4646166",
"pm_score": 2,
"selected": true,
"text": "extension StringExtension on String {\n String capitalizeByWord() {\n if (trim().isEmpty) {\n return '';\n }\n return split(' ')\n .map((element) =>\n \"${element[0].toUpperCase()}${element.substring(1).toLowerCase()}\")\n .join(\" \");\n }\n}\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20497216/"
] |
74,455,123 | <p>I just can't vertically center this text inside my div (red background), I've tried everything but nothing is working, please help! I can't even get my text inside the div whithout using margins/padding for some reason.
I've tried using div, span, p and h1 for the text but nothing worked =(</p>
<p><a href="https://i.stack.imgur.com/djX8B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/djX8B.png" alt="enter image description here" /></a></p>
<p><strong>THIS IS MY CODE:</strong></p>
<pre><code> <div class="headerdiv">
<div class="backtotop">
<a class="material-symbols-outlined" href="#" >arrow_upward</a>
<a class="backtotoptext" href="#">Voltar ao topo</a>
</div>
<div class="githubcontainer">
<a href="https://github.com/maruan-achkar/javascript_exercicios" target="_blank" class="githublink" >//GITHUB LINK</a>
</div>
<div class="dropdown">
<div class="dropdown-title-container">
<p class="dropdown-title">MENU</p>
</div>
<div class="dropdown-content">
<a class="dropdowna" href="#trocarvariaveis">// Trocar Variaveis<br></a>
<a class="dropdowna" href="#celsiusparafarenheit">// Celsius para Farenheit<br></a>
<a class="dropdowna" href="#farenheitparacelsius">// Farenheit para Celsius<br></a>
<a class="dropdowna" href="#areacirculo">// Area Circulo<br></a>
<a class="dropdowna" href="#parouimpar">// Par ou Impar<br></a>
<a class="dropdowna" href="#intervalo">// Intervalo entre numeros<br></a>
<a class="dropdowna" href="#intervalovetor">// Intervalo entre maior e menor de vetor<br></a>
<a class="dropdowna" href="#maiormenor">// Maior e menor numero<br></a>
<a class="dropdowna" href="#paisagemouretrato">// Paisagem ou retrato<br></a>
<a class="dropdowna" href="#fizzbuzz">// Fizz ou Buzz<br></a>
<a class="dropdowna" href="#stringobject">// String do objeto<br></a>
<a class="dropdowna" href="#parimparlimite">// Par ou impar ate limite<br></a>
</div>
</div>
</div>
</header>
--------------------------------------------CSS--------------------------------------------
.dropdown {
float: left;
background-color: #F6F7EB;
height: 100%;
width: 100px;
}
.dropdown-title-container{
background-color: #DC3318;
height: 100%;
display: flex;
justify-content: center;
}
.dropdown-title{
font-family: Arial;
font-weight: bolder;
font-size: 1.75em;
line-height: 100%;
}
.dropdown-content {
display: none;
position: absolute;
top: 48px;
background-color: #F6F7EB;
padding-right: 15px;
outline: solid black 3px;
box-shadow: 0px 10px 15px black;
border-radius: 0.1vw;
font-size: 0.8em;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdowna{
color: black;
font-size: 1.75em;
margin-left: 2vw;
text-decoration: none;
}```.sticky{
position: fixed;
top: 0;
width: 100%;
height: 45px;
background-color: #DC3318;
box-shadow: 0px 0px 5px rgb(0, 0, 0, 0.65);
}
.headerdiv{
background-color: greenyellow;
height: 100%;
width: 100%;
}
.backtotop{
font-weight: bolder;
font-size: 0.75em;
margin-right: 0;
height: 100%;
width: 160px;
float: right;
display: flex;
align-items: center;
}
.backtotoptext{
margin: auto;
text-decoration: none;
color: black;
font-size: 1.55em;
margin-right: 12px;
}
.material-symbols-outlined{
text-decoration: none;
margin-right: -30px;
margin-bottom: 3px;
color: black;
}
.backtotop:hover .backtotoptext{
color: rgb(0, 132, 255);
}
.backtotop:hover .material-symbols-outlined{
color: rgb(0, 132, 255);
}
.githubcontainer{
width: 200px;
height: 100%;
float: right;
margin-right: 40px;
display: flex;
align-items: center;
}
.githublink{
color: black;
margin: auto;
font-size: 1.35em;
text-decoration: none;
}
.githublink:hover{
text-decoration: underline;
}
</code></pre>
| [
{
"answer_id": 74455228,
"author": "K JOHN",
"author_id": 10031834,
"author_profile": "https://Stackoverflow.com/users/10031834",
"pm_score": 3,
"selected": true,
"text": "align-items:center;"
},
{
"answer_id": 74455240,
"author": "Luke.Lee",
"author_id": 20240788,
"author_profile": "https://Stackoverflow.com/users/20240788",
"pm_score": 1,
"selected": false,
"text": ".dropdown-title-container{\n background-color: #DC3318;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n"
},
{
"answer_id": 74455248,
"author": "Igor Ponso",
"author_id": 14623002,
"author_profile": "https://Stackoverflow.com/users/14623002",
"pm_score": 1,
"selected": false,
"text": "align-items: center"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20287603/"
] |
74,455,173 | <p>I have two tables from different databases, and I need to create a report, where there is need to see discrepancy in data:</p>
<p>Table A:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">DATE</th>
<th style="text-align: center;">FLIGHT</th>
<th style="text-align: center;">AC</th>
<th style="text-align: center;">DEST</th>
<th style="text-align: center;">ATD</th>
<th style="text-align: center;">TDN</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">14.01.2022</td>
<td style="text-align: center;">150</td>
<td style="text-align: center;">AIRB</td>
<td style="text-align: center;">JFK</td>
<td style="text-align: center;">02:45</td>
<td style="text-align: center;">1:35</td>
</tr>
<tr>
<td style="text-align: center;">15.01.2022</td>
<td style="text-align: center;">152</td>
<td style="text-align: center;">BOEING</td>
<td style="text-align: center;">MIA</td>
<td style="text-align: center;">02:45</td>
<td style="text-align: center;">1:38</td>
</tr>
<tr>
<td style="text-align: center;">15.01.2022</td>
<td style="text-align: center;">145</td>
<td style="text-align: center;">AIRB</td>
<td style="text-align: center;">SEA</td>
<td style="text-align: center;">01:25</td>
<td style="text-align: center;">01:05</td>
</tr>
</tbody>
</table>
</div>
<p>Table B:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">DATE</th>
<th style="text-align: center;">FLIGHT</th>
<th style="text-align: center;">AC</th>
<th style="text-align: center;">DEST</th>
<th style="text-align: center;">ATD</th>
<th style="text-align: center;">TDN</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">14.01.2022</td>
<td style="text-align: center;">150</td>
<td style="text-align: center;">AIRB</td>
<td style="text-align: center;">JFK</td>
<td style="text-align: center;">02:45</td>
<td style="text-align: center;">1:35</td>
</tr>
<tr>
<td style="text-align: center;">15.01.2022</td>
<td style="text-align: center;">152</td>
<td style="text-align: center;">BOEING</td>
<td style="text-align: center;">MIA</td>
<td style="text-align: center;">02:39</td>
<td style="text-align: center;">1:38</td>
</tr>
<tr>
<td style="text-align: center;">15.01.2022</td>
<td style="text-align: center;">145</td>
<td style="text-align: center;">AIRB</td>
<td style="text-align: center;">SEA</td>
<td style="text-align: center;">01:28</td>
<td style="text-align: center;">01:15</td>
</tr>
</tbody>
</table>
</div>
<p>The result should be only rows different in last two columns:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">DATE</th>
<th style="text-align: center;">FLIGHT</th>
<th style="text-align: center;">AC</th>
<th style="text-align: center;">DEST</th>
<th style="text-align: center;">ATD_B</th>
<th style="text-align: center;">TDN_B</th>
<th style="text-align: center;">ATD_A</th>
<th style="text-align: center;">TDN_A</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">15.01.2022</td>
<td style="text-align: center;">152</td>
<td style="text-align: center;">BOEING</td>
<td style="text-align: center;">MIA</td>
<td style="text-align: center;">02:39</td>
<td style="text-align: center;">1:38</td>
<td style="text-align: center;">02:45</td>
<td style="text-align: center;">01:38</td>
</tr>
<tr>
<td style="text-align: center;">15.01.2022</td>
<td style="text-align: center;">145</td>
<td style="text-align: center;">AIRB</td>
<td style="text-align: center;">SEA</td>
<td style="text-align: center;">01:28</td>
<td style="text-align: center;">01:15</td>
<td style="text-align: center;">01:25</td>
<td style="text-align: center;">01:05</td>
</tr>
</tbody>
</table>
</div>
<p>Now we can see where discrepancy is.</p>
<p>I have tried</p>
<pre><code>select * from table_a
minus
select * from table_b
</code></pre>
<p>But it seems not the right approach</p>
| [
{
"answer_id": 74455228,
"author": "K JOHN",
"author_id": 10031834,
"author_profile": "https://Stackoverflow.com/users/10031834",
"pm_score": 3,
"selected": true,
"text": "align-items:center;"
},
{
"answer_id": 74455240,
"author": "Luke.Lee",
"author_id": 20240788,
"author_profile": "https://Stackoverflow.com/users/20240788",
"pm_score": 1,
"selected": false,
"text": ".dropdown-title-container{\n background-color: #DC3318;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n"
},
{
"answer_id": 74455248,
"author": "Igor Ponso",
"author_id": 14623002,
"author_profile": "https://Stackoverflow.com/users/14623002",
"pm_score": 1,
"selected": false,
"text": "align-items: center"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16561042/"
] |
74,455,179 | <p>I'm trying to get Font-Awesome (6.2.1) to work but it's only showing up as squares. I dont know if i linked right, because the font awesome link always confuses me.</p>
<p>Does anyone have any suggestions?Its my cart icon</p>
<pre><code>#product1 .pro .des .cart{
width: 40px;
height: 40px;
line-height: 40px;
border-radius: 50px;
background-color: #e8f6ea;
font-weight: 500;
color: #088178;
border: 1px solid #cce7d0;
position: absolute;
bottom: 20px;
right: 10px;
}
<div class="pro">
<img src="casa-wacom-2-removebg-preview.png" alt="">
<div class="des">
<span>Wacom</span>
<h5>Case para Wacom</h5>
<div class="star">
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
<i class="fas fa-star"></i>
</div>
<a><i class="fa-light fa-cart-shopping cart"></i></a>
<h4>R$19,99</h4>
</div>
</div>
</code></pre>
| [
{
"answer_id": 74455217,
"author": "Bryn Lewis",
"author_id": 2261733,
"author_profile": "https://Stackoverflow.com/users/2261733",
"pm_score": 0,
"selected": false,
"text": " <i class=\"fa-solid fa-star\"></i>\n"
},
{
"answer_id": 74455646,
"author": "Ponsiva",
"author_id": 9936892,
"author_profile": "https://Stackoverflow.com/users/9936892",
"pm_score": 2,
"selected": false,
"text": "<i class=\"fas fa-rocket\"></i>\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19320922/"
] |
74,455,264 | <p>I have two tables with same structure. Let it be 3 columns and a primary key, which are all number values.</p>
<p>Both tables should have similar values, but there are some different values present in the tables. I need to find out these values and at which positions they exist. How can I write the script for this in Oracle SQL Developer?</p>
<p>I tried it using joins and cursors. I'm new to this PL/SQL scripting, thus its not easy for me to understand it. so any kind of help is appreciated! Happy coding!</p>
<pre><code>CREATE OR REPLACE PACKAGE mismatch_finder IS
PROCEDURE find_mismatch_values;
FUNCTION row_finder_tb1(pkey number) RETURN table1%rowtype;
FUNCTION row_finder_tb2(pkey number) RETURN table2%rowtype;
END mismatch_finder;
CREATE OR REPLACE PACKAGE BODY mismatch_finder AS
PROCEDURE find_mismatch_values AS
CURSOR CUR IS
select pk from(select * from table1 minus select * from table2); REC CUR%rowtype; t1 table1%rowtype; t2 table2%rowtype; col_count number := 1;
BEGIN
OPEN CUR; LOOP FETCH CUR into REC; EXIT when CUR%NOTFOUND;
t1 := row_finder_tb1(REC.pk); t2 := row_finder_tb2(REC.pk);
IF (t1.column_1 != t2.column_1) THEN dbms_output.put_line('Value missmatch at key value' || REC.pk || ' column number ' || col_count || ' Table 1 value is : ' || t1.column_1 || ' and Table 2 value is : ' || t2.column_1);
END IF; col_count := col_count + 1;
IF (t1.column_2 != t2.column_2) THEN dbms_output.put_line('Value missmatch at key value' || REC.pk || ' column number ' || col_count || ' Table 1 value is : ' || t1.column_2 || ' and Table 2 value is : ' || t2.column_2);
END IF; col_count := col_count + 1;
IF (t1.column_3 != t2.column_3) THEN dbms_output.put_line('Value missmatch at key value' || REC.pk || ' column number ' || col_count || ' Table 1 value is : ' || t1.column_3 || ' and Table 2 value is : ' || t2.column_3);
END IF; col_count := 1;
END LOOP; CLOSE CUR;
END find_mismatch_values;
FUNCTION row_finder_tb1(p_key number) RETURN table1%rowtype IS
TEMP table1%rowtype;
BEGIN
select * into TEMP from table1 where table1.pk = p_key; RETURN(TEMP);
END row_finder_tb1;
FUNCTION row_finder_tb2(p_key number) RETURN table2%rowtype IS
TEMP table2%rowtype;
BEGIN
select * into TEMP from table2 where table2.pk = p_key; RETURN(TEMP);
END row_finder_tb2;
END mismatch_finder;
</code></pre>
| [
{
"answer_id": 74455217,
"author": "Bryn Lewis",
"author_id": 2261733,
"author_profile": "https://Stackoverflow.com/users/2261733",
"pm_score": 0,
"selected": false,
"text": " <i class=\"fa-solid fa-star\"></i>\n"
},
{
"answer_id": 74455646,
"author": "Ponsiva",
"author_id": 9936892,
"author_profile": "https://Stackoverflow.com/users/9936892",
"pm_score": 2,
"selected": false,
"text": "<i class=\"fas fa-rocket\"></i>\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20506650/"
] |
74,455,266 | <p>Firstly, I'm a beginner and I don't speak English very well, so any questions about what I'm trying to say are welcome. I was making a python program that received two numbers, and the program showed the prime numbers between them.</p>
<p>The algorithm takes the numbers, turns them into a list, then divides each number in that list by each of its predecessors. Then each integer division is passed to another list to see which of the numbers passed to the other list are primes.</p>
<p>Once passed to the second list, the prime numbers are those that are not repeated in that list, that is, when removing all the repeated values, I have a list of primes, but in some values the function simply does not work. I would like to understand why. Thanks in advance!</p>
<p>Follow the code below:</p>
<pre class="lang-py prettyprint-override"><code>def Find_Primes(smaller_num, bigger_num):
array = list(range(smaller_num, (bigger_num + 1)))
array2 = []
for i in array:
for j in range(1, i):
if i % j == 0:
array2.append(i)
for num in array2:
if array2.count(num) > 1:
while num in arrayt2:
arrayt2.remove(num)
print(array2)
smaller_number = int(input('Text the smaller number of interval: '))
bigger_number = int(input('Text the other number of interval: '))
Find_Primes(smaller_number, bigger_number)
</code></pre>
| [
{
"answer_id": 74455217,
"author": "Bryn Lewis",
"author_id": 2261733,
"author_profile": "https://Stackoverflow.com/users/2261733",
"pm_score": 0,
"selected": false,
"text": " <i class=\"fa-solid fa-star\"></i>\n"
},
{
"answer_id": 74455646,
"author": "Ponsiva",
"author_id": 9936892,
"author_profile": "https://Stackoverflow.com/users/9936892",
"pm_score": 2,
"selected": false,
"text": "<i class=\"fas fa-rocket\"></i>\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20516312/"
] |
74,455,279 | <p>This code doesn't work right now because I don't know the exact code I should use. I need to print out the number of words containing less than 5 letters.
This is what I've been trying:</p>
<pre><code>text = "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout."
words = text.split()
letterCount = {w: len(w) for w in words}
lessthan5 = '1,2,3,4'
count = 0
if words == lessthan5 : #i put words to refer to line 3(letter count)
result = count + 1
print(result)
</code></pre>
<p>The output I need is an integer, ex.17.
Pls help thank u so much</p>
| [
{
"answer_id": 74455217,
"author": "Bryn Lewis",
"author_id": 2261733,
"author_profile": "https://Stackoverflow.com/users/2261733",
"pm_score": 0,
"selected": false,
"text": " <i class=\"fa-solid fa-star\"></i>\n"
},
{
"answer_id": 74455646,
"author": "Ponsiva",
"author_id": 9936892,
"author_profile": "https://Stackoverflow.com/users/9936892",
"pm_score": 2,
"selected": false,
"text": "<i class=\"fas fa-rocket\"></i>\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20174903/"
] |
74,455,392 | <p>I need to create a variable with an asterisk.</p>
<pre><code>originalFilePath = "/home/user/reports/file_name_xxxx.pdf"
</code></pre>
<p>The file_name will be replaced every day with a numeric value, like - file_name_20221116.pdf. How can I pass "*" - star, in the variable?</p>
<p>So the code would look like this -</p>
<pre><code>originalFilePath = "/home/user/reports/file_name_*.pdf"
</code></pre>
<p>Any help would be appreciated.</p>
| [
{
"answer_id": 74455431,
"author": "GCMeccariello",
"author_id": 16175571,
"author_profile": "https://Stackoverflow.com/users/16175571",
"pm_score": -1,
"selected": false,
"text": "import datetime\ntimestamp = datetime.datetime.now().date()\noriginalFilePath = f\"/home/user/reports/file_name_{timestamp}.pdf\"\n"
},
{
"answer_id": 74455524,
"author": "Shyam Bhattacharyya",
"author_id": 11554058,
"author_profile": "https://Stackoverflow.com/users/11554058",
"pm_score": 0,
"selected": false,
"text": "originalFilePath = \"/home/user/reports/file_name_xxxx.pdf\"\n"
},
{
"answer_id": 74458274,
"author": "Klas Š.",
"author_id": 9288580,
"author_profile": "https://Stackoverflow.com/users/9288580",
"pm_score": 0,
"selected": false,
"text": "import glob\n\nreport_pattern = \"/home/user/reports/file_name_*.pdf\"\nreports = glob.glob(report_pattern)\n# reports == ['/home/user/reports/file_name_20221116.pdf']\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16306747/"
] |
74,455,396 | <p>May I ask how to count the broken door in below table?
I want to show the record of Block B also, but I only can show Block A record.</p>
<p>Also, if my selection table query is too long, but I will reuse many times.
How can I define the valuable to the long selection query?</p>
<p>Table: doorStatus</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Door</th>
<th>Block</th>
<th>key_Number</th>
<th>Broken</th>
</tr>
</thead>
<tbody>
<tr>
<td>door1</td>
<td>A</td>
<td>001</td>
<td>Y</td>
</tr>
<tr>
<td>door2</td>
<td>A</td>
<td>001</td>
<td>Y</td>
</tr>
<tr>
<td>door3</td>
<td>A</td>
<td>002</td>
<td>Y</td>
</tr>
<tr>
<td>door4</td>
<td>B</td>
<td>013</td>
<td>N</td>
</tr>
</tbody>
</table>
</div>
<p>Except result:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Block</th>
<th>key_number</th>
<th>Count_Broken</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>001</td>
<td>2</td>
</tr>
<tr>
<td>A</td>
<td>002</td>
<td>1</td>
</tr>
<tr>
<td>B</td>
<td>013</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
<p>Thank you for your help.</p>
| [
{
"answer_id": 74455560,
"author": "JHH",
"author_id": 20127235,
"author_profile": "https://Stackoverflow.com/users/20127235",
"pm_score": 2,
"selected": false,
"text": "-- prep data\ncreate table door_status (\n door varchar(10),\n block char(1),\n key_number varchar(3),\n broken char(1));\n \ninsert into door_status\nvalues\n('door1','A','001','Y'),\n('door2','A','001','Y'),\n('door3','A','002','Y'),\n('door4','B','013','N');\n\n-- query\nselect block,\n key_number,\n sum(case broken when 'Y' then 1 else 0 end) as count_broken\n from door_status\n group by 1,2;\n"
},
{
"answer_id": 74455579,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 1,
"selected": false,
"text": "GROUP BY"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15453505/"
] |
74,455,427 | <p>I have this array of JSON and I want to loop through them and use it to fill up my <code>option</code> element.</p>
<p><strong>Sample Array:</strong></p>
<pre><code>var myOptionData = [
{fooValue:"1", fooText:"option A"},
{fooValue:"2", fooText:"option B"},
{fooValue:"3", fooText:"option C"}
]
</code></pre>
<p><strong>I did use this method:</strong></p>
<pre><code>var fields="";
fields += "</select >";
fields += "<option value='0'></option>";
$.each(myOptionData , function (key, value) {
fields += "<option value=" + value.fooValue + ">" + value.fooText + "</option>";
});
fields += "</select >";
</code></pre>
<p>//But I want to make it more flexible, so that I can reuse it in making another <code><option></code> from another array of JSON, like this scenario:</p>
<pre><code>var myNewOptionData = [
{myValue:"5", myText:"option E"},
{myValue:"6", myText:"option F"},
{myValue:"7", myText:"option G"},
{myValue:"8", myText:"option H"}
]
</code></pre>
<p>//Now I cannot use the method above</p>
| [
{
"answer_id": 74455504,
"author": "Carsten Massmann",
"author_id": 2610061,
"author_profile": "https://Stackoverflow.com/users/2610061",
"pm_score": 3,
"selected": true,
"text": "function mkSelect(data){\n return \"<select><option value='0'></option>\"\n + data.map(o=>{\n let [val,txt]=Object.values(o);\n return \"<option value=\" + val + \">\" + txt + \"</option>\"}).join(\"\") \n + \"</select >\";\n}\nconst myOptionData = [\n {fooValue:\"1\", fooText:\"option A\"},\n {fooValue:\"2\", fooText:\"option B\"},\n {fooValue:\"3\", fooText:\"option C\"}\n], \n myNewOptionData = [\n {myValue:\"5\", myText:\"option E\"},\n {myValue:\"6\", myText:\"option F\"},\n {myValue:\"7\", myText:\"option G\"},\n {myValue:\"8\", myText:\"option H\"}\n];\n\ndocument.querySelector(\"#frm\").innerHTML=mkSelect(myOptionData)+\"<br>\"\n +mkSelect(myNewOptionData); "
},
{
"answer_id": 74455682,
"author": "Darío Kozicki",
"author_id": 13710695,
"author_profile": "https://Stackoverflow.com/users/13710695",
"pm_score": 0,
"selected": false,
"text": " function createSelect(options, valueName, textName) {\n const select = `<select><option value='0'></option>\n ${options.map(option => `<option value=\"${option[valueName]}\">${option[textName]}</option>`)}\n </select>`;\n\n return select;\n }\n\n console.log(\n createSelect([{randomValue: 1, randomName: 'Go select!'}], 'randomValue', 'randomName')\n );"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18492863/"
] |
74,455,428 | <p>I have a list of strings that I want to perform operations on and append to rows in a dataframe. Running these operations on a single string works fine but I am having trouble looping through. The code below returns an empty dataframe and I am not sure why?</p>
<pre><code>col_names = ["Version Available", "Newer Version Available"]
def my_function(item):
for x in item:
querywords = x.split()
resultwords = [word for word in querywords if word not in stopwords]
result = ' '.join(resultwords)
line = re.findall(r'\bNewer.*(?=\sVersion\b)', result)
line = "".join(line)
line = line.replace("Newer Version Available :", "")
line2 = re.findall(r'(Version.*){2}(?=\sSource\b)', result)
line2 = "".join(line2)
line2 = line2.replace("Version Available :", "")
s = [[line] + [line2]]
data = pd.DataFrame(s)
data.columns = col_names
</code></pre>
<pre><code>df = my_function(my_list)
</code></pre>
| [
{
"answer_id": 74455530,
"author": "iamjaydev",
"author_id": 10968621,
"author_profile": "https://Stackoverflow.com/users/10968621",
"pm_score": 2,
"selected": true,
"text": "\ncol_names = [\"Version Available\", \"Newer Version Available\"]\n\ndef my_function(item):\n df = pd.DataFrame(columns=col_names) #initialize data frame\n for x in item:\n querywords = x.split()\n resultwords = [word for word in querywords if word not in stopwords]\n result = ' '.join(resultwords)\n line = re.findall(r'\\bNewer.*(?=\\sVersion\\b)', result)\n line = \"\".join(line)\n line = line.replace(\"Newer Version Available :\", \"\")\n line2 = re.findall(r'(Version.*){2}(?=\\sSource\\b)', result)\n line2 = \"\".join(line2)\n line2 = line2.replace(\"Version Available :\", \"\")\n df.loc[len(df.index)] = [line,line2] # add row to data\n return df\n\ndf = my_function(my_list)\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17543526/"
] |
74,455,441 | <p>I have formulas for the top 4 rows formula is as follows row 1) C1= A1+B1 row 2 ) C2=A2+B2 row 3) C3=A3+B3 row 4) C4=C3/C1 and the next row is blank ie C5 post which the same continues 4 rows has formula and the 5th row is blank I have a huge data how to copy the formula below please help</p>
<p>Am struck please someone assist
I have skipped the blanks and copied the first four rows selected the below rows and pasted I need any other alternative either by formula or by copy paste</p>
| [
{
"answer_id": 74455530,
"author": "iamjaydev",
"author_id": 10968621,
"author_profile": "https://Stackoverflow.com/users/10968621",
"pm_score": 2,
"selected": true,
"text": "\ncol_names = [\"Version Available\", \"Newer Version Available\"]\n\ndef my_function(item):\n df = pd.DataFrame(columns=col_names) #initialize data frame\n for x in item:\n querywords = x.split()\n resultwords = [word for word in querywords if word not in stopwords]\n result = ' '.join(resultwords)\n line = re.findall(r'\\bNewer.*(?=\\sVersion\\b)', result)\n line = \"\".join(line)\n line = line.replace(\"Newer Version Available :\", \"\")\n line2 = re.findall(r'(Version.*){2}(?=\\sSource\\b)', result)\n line2 = \"\".join(line2)\n line2 = line2.replace(\"Version Available :\", \"\")\n df.loc[len(df.index)] = [line,line2] # add row to data\n return df\n\ndf = my_function(my_list)\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20516523/"
] |
74,455,445 | <p>PyTorch and Torchvision were compiled with different CUDA versions. PyTorch has CUDA <code>version=11.6</code> and torchvision <code>CUDA Version 11.3</code>. Please reinstall the torchvision that matches your PyTorch install.</p>
<p>I've tried to reinstall torchvision so many times from the website as well as PyTorch and python.
I'm stuck I have no idea how to solve this issue.</p>
| [
{
"answer_id": 74455530,
"author": "iamjaydev",
"author_id": 10968621,
"author_profile": "https://Stackoverflow.com/users/10968621",
"pm_score": 2,
"selected": true,
"text": "\ncol_names = [\"Version Available\", \"Newer Version Available\"]\n\ndef my_function(item):\n df = pd.DataFrame(columns=col_names) #initialize data frame\n for x in item:\n querywords = x.split()\n resultwords = [word for word in querywords if word not in stopwords]\n result = ' '.join(resultwords)\n line = re.findall(r'\\bNewer.*(?=\\sVersion\\b)', result)\n line = \"\".join(line)\n line = line.replace(\"Newer Version Available :\", \"\")\n line2 = re.findall(r'(Version.*){2}(?=\\sSource\\b)', result)\n line2 = \"\".join(line2)\n line2 = line2.replace(\"Version Available :\", \"\")\n df.loc[len(df.index)] = [line,line2] # add row to data\n return df\n\ndf = my_function(my_list)\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20516544/"
] |
74,455,474 | <p>The function can't be unconditionally invoked because it can be 'null'.</p>
<p>getting an error in this part <code>auth.currentUser</code>:</p>
<pre class="lang-dart prettyprint-override"><code>FirebaseAuth auth = FirebaseAuth.instance;
final User user = await auth.currentUser();
String uid = user.uid;
await FirebaseFirestore.instance
.collection('data')
.doc(uid)
.collection('data')
.doc();
</code></pre>
| [
{
"answer_id": 74455530,
"author": "iamjaydev",
"author_id": 10968621,
"author_profile": "https://Stackoverflow.com/users/10968621",
"pm_score": 2,
"selected": true,
"text": "\ncol_names = [\"Version Available\", \"Newer Version Available\"]\n\ndef my_function(item):\n df = pd.DataFrame(columns=col_names) #initialize data frame\n for x in item:\n querywords = x.split()\n resultwords = [word for word in querywords if word not in stopwords]\n result = ' '.join(resultwords)\n line = re.findall(r'\\bNewer.*(?=\\sVersion\\b)', result)\n line = \"\".join(line)\n line = line.replace(\"Newer Version Available :\", \"\")\n line2 = re.findall(r'(Version.*){2}(?=\\sSource\\b)', result)\n line2 = \"\".join(line2)\n line2 = line2.replace(\"Version Available :\", \"\")\n df.loc[len(df.index)] = [line,line2] # add row to data\n return df\n\ndf = my_function(my_list)\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20061332/"
] |
74,455,478 | <p>I'm new to javascript so maybe it's a dumb mistake. I'm trying to pass the values of the object that I get in this webscrapping function to the constant but I'm not succeeding. Every time I try to print the menu it prints as "undefined".
`</p>
<pre><code>const puppeteer = require("puppeteer");
async function getMenu() {
console.log("Opening the browser...");
const browser = await puppeteer.launch({
headless: true
});
const page = await browser.newPage();
await page.goto('https://pra.ufpr.br/ru/ru-centro-politecnico/', {waitUntil: 'domcontentloaded'});
console.log("Content loaded...");
// Get the viewport of the page
const fullMenu = await page.evaluate(() => {
return {
day: document.querySelector('#conteudo div:nth-child(3) p strong').innerText,
breakfastFood: document.querySelector('tbody tr:nth-child(2)').innerText,
lunchFood: document.querySelector('tbody tr:nth-child(4)').innerText,
dinnerFood: document.querySelector('tbody tr:nth-child(6)').innerText
};
});
await browser.close();
return {
breakfast: fullMenu.day + "\nCafé da Manhã:\n" + fullMenu.breakfastFood,
lunch: fullMenu.day + "\nAlmoço:\n" + fullMenu.lunchFood,
dinner: fullMenu.day + "\nJantar:\n" + fullMenu.dinnerFood
};
};
const menu = getMenu();
console.log(menu.breakfast);
</code></pre>
<p>`</p>
<p>I've tried to pass these values in several ways to a variable but I'm not succeeding. I also accept other methods of passing these strings, I'm doing it this way because it's the simplest I could think of.</p>
| [
{
"answer_id": 74455530,
"author": "iamjaydev",
"author_id": 10968621,
"author_profile": "https://Stackoverflow.com/users/10968621",
"pm_score": 2,
"selected": true,
"text": "\ncol_names = [\"Version Available\", \"Newer Version Available\"]\n\ndef my_function(item):\n df = pd.DataFrame(columns=col_names) #initialize data frame\n for x in item:\n querywords = x.split()\n resultwords = [word for word in querywords if word not in stopwords]\n result = ' '.join(resultwords)\n line = re.findall(r'\\bNewer.*(?=\\sVersion\\b)', result)\n line = \"\".join(line)\n line = line.replace(\"Newer Version Available :\", \"\")\n line2 = re.findall(r'(Version.*){2}(?=\\sSource\\b)', result)\n line2 = \"\".join(line2)\n line2 = line2.replace(\"Version Available :\", \"\")\n df.loc[len(df.index)] = [line,line2] # add row to data\n return df\n\ndf = my_function(my_list)\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19314172/"
] |
74,455,600 | <p>I want to solve a mixed integer quadratic programming problem with 267 variables [1] using SCIP.</p>
<p>CPLEX can solve the problem in about 30 seconds and a solution that is extremely close to the optimum is already found within a fraction of a second [2, 3].</p>
<p>Unfortunately, SCIP really struggles with this problem, unable to find a solution that is anywhere near the optimum even after running for over 20 minutes [4].</p>
<p>Why is this? Is CPLEX really <em>that</em> much better at MIQP than SCIP? Did I not configure SCIP correctly? How can I solve this problem with SCIP?</p>
<p>It also seems to me like the solutions SCIP finds are very far away from the solution of the relaxation. I was under the impression that SCIP would first solve the relaxation and then try to find an integer solution based on that. Is this not correct? If yes, why are the solutions so far off?</p>
<ul>
<li>[1] <a href="https://gist.github.com/julmb/e425ef372b110825d49fee8649d88a49#file-267p-lp" rel="nofollow noreferrer">https://gist.github.com/julmb/e425ef372b110825d49fee8649d88a49#file-267p-lp</a></li>
<li>[2] <a href="https://gist.github.com/julmb/e425ef372b110825d49fee8649d88a49#file-cplex-log" rel="nofollow noreferrer">https://gist.github.com/julmb/e425ef372b110825d49fee8649d88a49#file-cplex-log</a></li>
<li>[3] <a href="https://gist.github.com/julmb/e425ef372b110825d49fee8649d88a49#file-cplex-sol" rel="nofollow noreferrer">https://gist.github.com/julmb/e425ef372b110825d49fee8649d88a49#file-cplex-sol</a></li>
<li>[4] <a href="https://gist.github.com/julmb/e425ef372b110825d49fee8649d88a49#file-scip-log" rel="nofollow noreferrer">https://gist.github.com/julmb/e425ef372b110825d49fee8649d88a49#file-scip-log</a></li>
</ul>
| [
{
"answer_id": 74474924,
"author": "stefan",
"author_id": 3925235,
"author_profile": "https://Stackoverflow.com/users/3925235",
"pm_score": 3,
"selected": false,
"text": "heuristics/nlpdiving/freq = 0\nheuristics/nlpdiving/freqofs = 0\nheuristics/nlpdiving/maxnlpiterabs = 10000\nheuristics/nlpdiving/nlpfastfail = FALSE\nheuristics/nlpdiving/varselrule = f\n"
},
{
"answer_id": 74492097,
"author": "Erwin Kalvelagen",
"author_id": 5625534,
"author_profile": "https://Stackoverflow.com/users/5625534",
"pm_score": 0,
"selected": false,
"text": "Classifier predicts products in MIQP should be linearized.\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/688076/"
] |
74,455,609 | <p>I want to show the Admob App an open Ad and for that I followed this link and is working fine. Now Ad is showing whenever I opened the app but I want to show ad only when a variable is divisible by 3. For like ad comes to the user 3 times and the ad dispose of and for the six-time show ad again
<a href="https://codefittings.com/admob-app-open-ad-in-flutter-with-complete-guide/" rel="nofollow noreferrer">site i followed</a></p>
| [
{
"answer_id": 74474924,
"author": "stefan",
"author_id": 3925235,
"author_profile": "https://Stackoverflow.com/users/3925235",
"pm_score": 3,
"selected": false,
"text": "heuristics/nlpdiving/freq = 0\nheuristics/nlpdiving/freqofs = 0\nheuristics/nlpdiving/maxnlpiterabs = 10000\nheuristics/nlpdiving/nlpfastfail = FALSE\nheuristics/nlpdiving/varselrule = f\n"
},
{
"answer_id": 74492097,
"author": "Erwin Kalvelagen",
"author_id": 5625534,
"author_profile": "https://Stackoverflow.com/users/5625534",
"pm_score": 0,
"selected": false,
"text": "Classifier predicts products in MIQP should be linearized.\n"
}
] | 2022/11/16 | [
"https://Stackoverflow.com/questions/74455609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20378705/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.