qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,206,850 | <p>I am a beginner in python . i am getting this error in python . please tell me the logic behind this error .</p>
<pre><code>def sequence (n):
while n ! == 1:
print(n)
if n%2 == 0:
n = n/2
else:
n=n*3+1
</code></pre>
<p>please tell me the logic behind this error</p>
| [
{
"answer_id": 74206883,
"author": "Kungfu panda",
"author_id": 15349625,
"author_profile": "https://Stackoverflow.com/users/15349625",
"pm_score": 0,
"selected": false,
"text": "# you can use dictionary datatype in python which maps key and value.\na = {'k':1, 'i':2, 's':3, 'a':4,}\n"
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338776/"
] |
74,206,855 | <p>I want to show a minimize moveable calling screen in top of the app <a href="https://i.stack.imgur.com/sDHhq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sDHhq.jpg" alt="enter image description here" /></a></p>
<p>I tried with stack it does not meet my expectation</p>
| [
{
"answer_id": 74206883,
"author": "Kungfu panda",
"author_id": 15349625,
"author_profile": "https://Stackoverflow.com/users/15349625",
"pm_score": 0,
"selected": false,
"text": "# you can use dictionary datatype in python which maps key and value.\na = {'k':1, 'i':2, 's':3, 'a':4,}\n"
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15248704/"
] |
74,206,867 | <p>I have MainActivity.kt with passing an activity context to <strong>MyObj</strong>-class:</p>
<pre><code>class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
MyObj.processing(this)
}
}
</code></pre>
<p>MyObj.kt:</p>
<pre><code>class MyObj {
companion object {
fun processing( cx:Context ) {
// -- doesnt work (universal way)
val intent = cx.intent
// -- i have to cast context to activity via hardcoded way (not universal)
val intent = (cx as MainActivity).intent
}
}
}
</code></pre>
<p>I would like to have an universal MyObj without a need to cast in a manual way. Is it possible?</p>
| [
{
"answer_id": 74206883,
"author": "Kungfu panda",
"author_id": 15349625,
"author_profile": "https://Stackoverflow.com/users/15349625",
"pm_score": 0,
"selected": false,
"text": "# you can use dictionary datatype in python which maps key and value.\na = {'k':1, 'i':2, 's':3, 'a':4,}\n"
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6105745/"
] |
74,206,890 | <p>I made a GUI Python program with Tkinter.
I made a progressbar using "from tkinter.ttk import Progressbar".
When I press a button, I apply a function that do something and return a Boolean value.
I need that the progressbar will run until that function ends the process, and after that it will stop.</p>
<pre><code>from tkinter.ttk import Progressbar
import time
import threading
wheel_flag = False
root = tk.Tk()
wheel = Progressbar(row,orient=HORIZONTAL,length=100,mode="indeterminate")
def btn_function()
loading_function = threading.Thread(target=start_loading)
loading_function.start()
boolean_wheel = threading.Thread(target=some_function, args = (x,y)) #"some_function" returns a boolean value
boolean_wheel.start()
while True:
if not boolean_wheel.is_alive():
break
wheel_flag = True
def start_loading():
while True:
global wheel_flag
wheel['value'] += 10
root.update_idletasks()
time.sleep(0.5)
if wheel_flag:
break
</code></pre>
<p>Here I don't get the boolean_wheel value, but I want to check if it true or false and send to the user message if function succeeded or not.</p>
<p>I want that when "btn_function" is applied, the progressbarwill start to load until "some_function" will finish run.
Now the result I get is that the loading start only after "some_function" finished, and runs without stopping until I close the program.</p>
| [
{
"answer_id": 74207463,
"author": "Ahmed AEK",
"author_id": 15649230,
"author_profile": "https://Stackoverflow.com/users/15649230",
"pm_score": 2,
"selected": true,
"text": "btn_function"
},
{
"answer_id": 74209555,
"author": "furas",
"author_id": 1832058,
"author_pr... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19896669/"
] |
74,206,925 | <p>In my table <code>Product</code> in MySQL I would like to count how many Product_Id has been Saved in Fav, Purchased or Delivered. Then organize the result in rows with null or not null by Fav, Purchase, Delivery in column or the inverse, like I explain below.</p>
<p>With this query:</p>
<pre><code>SELECT COUNT(IF(Fav IS NOT NULL, ID, NULL)) AS "Fav_Not-null", COUNT(IF(Fav IS NULL, ID, NULL)) AS "Fav_Null" ,
COUNT(IF(Purchase IS NOT NULL, ID, NULL)) AS "Purchase_Not-null", COUNT(IF(Purchase IS NULL, ID, NULL)) AS "Purchase_Null" ,
COUNT(IF(Delivery IS NOT NULL, ID, NULL)) AS "Delivery_Not-null", COUNT(IF(Delivery IS NULL, ID, NULL)) AS "Delivery_Null"
FROM Product
</code></pre>
<p>I have this result:</p>
<pre><code># Fav_Not-null Fav_null Purchase_Not-null Purchase_null Delivery_Not-null Delivery_null
1 75 25 53 47 27 73
</code></pre>
<p>It's ok but I would like to show the result in different way like:</p>
<pre><code> Fav Purchase Delivery
Null 25 47 73
Not-null 75 53 27
</code></pre>
<p>or like:</p>
<pre><code> Null Not-null
Fav 25 75
Purchase 47 53
Delivery 73 27
</code></pre>
<p>Thanks for the help</p>
| [
{
"answer_id": 74207076,
"author": "Delta32000",
"author_id": 12939087,
"author_profile": "https://Stackoverflow.com/users/12939087",
"pm_score": 0,
"selected": false,
"text": "SELECT\n 'Null' AS TYPE\n COUNT(IF(Fav IS NOT NULL, ID, NULL)) AS \"Fav_Not-null\" AS Fav,\n COUNT(IF(... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17783040/"
] |
74,206,943 | <p>Kinda confuse how to solve this one. Like each inversion between letters will be added a pause using the character "_", but this does not apply if there are spaces. There is a ReverseString function with a str parameter of type string which will be the input character data to be reversed.</p>
<pre><code>package main
import "fmt"
func ReverseString(str string) string {
r := ""
for i := len(str) - 1; i >= 0; i-- {
if str[i] >= 0 && string(str[i]) != " " {
r += string(str[i]) + "_"
}
}
return string(r)
}
func main() {
fmt.Println(ReverseString("hello world"))
fmt.Println(ReverseString("i am a student"))
}
</code></pre>
<pre><code>var _ = Describe("ReverseString", func() {
When("input str contains 'Hello World'", func() {
It("should return 'd_l_r_o_W o_l_l_e_H'", func() {
Expect(main.ReverseString("Hello World")).To(Equal("d_l_r_o_W o_l_l_e_H"))
})
})
</code></pre>
| [
{
"answer_id": 74207076,
"author": "Delta32000",
"author_id": 12939087,
"author_profile": "https://Stackoverflow.com/users/12939087",
"pm_score": 0,
"selected": false,
"text": "SELECT\n 'Null' AS TYPE\n COUNT(IF(Fav IS NOT NULL, ID, NULL)) AS \"Fav_Not-null\" AS Fav,\n COUNT(IF(... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20267588/"
] |
74,206,948 | <p>If I used a <code>variable</code> to check for boolean, the "!isNumber" is highlighted with the warning "Condition '!isNumber' is always true":</p>
<pre><code> val isNumber = bind.number.isChecked
when (array) {
"A" -> {
if (isNumber) {
return "number"
} else if (!isNumber) {
return "letter"
}
}
</code></pre>
<p>However if I used the view directly to check for boolean, there is no warning:</p>
<pre><code> when (acArray) {
"A" -> {
if (bind.number.isChecked) {
return "number"
} else if (!bind.number.isChecked) {
return "letter"
}
}
</code></pre>
| [
{
"answer_id": 74207055,
"author": "Majed Al-Moqbeli",
"author_id": 17122042,
"author_profile": "https://Stackoverflow.com/users/17122042",
"pm_score": 1,
"selected": false,
"text": " when (array) {\n \"A\" -> {\n if (isNumber) {\n return \"number\"\n ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7764977/"
] |
74,206,971 | <p>Here is a simplified version of an API, that I am developing. Different users can create, update and delete entities of some kind. And I need to periodically prepare or update one ZIP file per customer, containing the latest versions of their entities.</p>
<p>My idea is to store the entities in a DynamoDB table and then periodically run a batch process, which would read the changes from the table's stream. My question is how do I make sure that each subsequent batch read would continue from the correct place? That is, from the first unread event.</p>
<p>A bit more info:</p>
<ul>
<li>I need to run this outside of an AWS Lambda function.</li>
<li>I prefer to use a DynamoDB stream, not a Kinesis data stream for this, if possible.</li>
<li>I know I can put a timestamp in the table and just read from the latest timestamp that I had (that is, not using streams at all). There are some synchronization problems with this.</li>
<li>I had implemented this before by using a second table to act like a journal. While this works, it's a bit clunky, so I wanted to see if I can use streams for this.</li>
<li>My program is in Java, but I won't mind hints for other languages or even direct API calls.</li>
</ul>
<p>This is kind of a follow-up question to this answer: <a href="https://stackoverflow.com/a/44010290/106350">https://stackoverflow.com/a/44010290/106350</a>.</p>
| [
{
"answer_id": 74209933,
"author": "Borislav Stoilov",
"author_id": 5625696,
"author_profile": "https://Stackoverflow.com/users/5625696",
"pm_score": 0,
"selected": false,
"text": "Dynamo Stream -> Lambda -> SNS (If more than one consumer) -> FIFO SQS\n"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74206971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/106350/"
] |
74,207,053 | <p>I have a table which store each type of clothes we sale, a simplification could be :</p>
<pre><code>TypeCloth (id, name_type, desc)
</code></pre>
<p>I have a second table storing all articles for each type of cloths</p>
<pre><code>Cloth (id, name_cloth, desc, price, ... , type_cloth_id)
</code></pre>
<p>I want to do a query that let me show a quick view of the last 4 cloths of each type of cloths</p>
<p>I've done something like this :</p>
<pre><code>@type_cloths = TypeCloth.all
@cloth = Cloth.where(type_cloth_id: @type_cloths.ids)
</code></pre>
<p>If I put a LIMIT 4 here I will just get 4 cloths. I would like to get 4 cloths of each types</p>
<p>I'm sure i'm missing something obvious here</p>
| [
{
"answer_id": 74209933,
"author": "Borislav Stoilov",
"author_id": 5625696,
"author_profile": "https://Stackoverflow.com/users/5625696",
"pm_score": 0,
"selected": false,
"text": "Dynamo Stream -> Lambda -> SNS (If more than one consumer) -> FIFO SQS\n"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7295677/"
] |
74,207,064 | <p>i"am learning c++ and decided to make a simple calculator and when i compiled the project and ran it all it showed is a black screen. Btw im running MS VSCode 2022. Thanks in advance for help! :)
`</p>
<pre><code>#include <iostream>
using namespace std;
int main() {
int konec = 0;
double cislox = 0;
double cisloy = 0;
int operace = 0;
double vysledek1 = 0;
double vysledek2 = 0;
double vysledek3 = 0;
double vysledek4 = 0;
while (konec == 0); {
cout << "Vítejte v kalkulačce Ver. 0.1" << endl;
cout << "stiskněte 1 pro sčítání, 2 pro odčítání, 3 pro násobení, 4 pro dělení" << endl;
cin >> operace;
switch (operace) {
case 1:
cout << "Zadejte číslo X" << endl;
cin >> cislox;
cout << "Zadejte číslo Y" << endl;
cin >> cisloy;
vysledek1 = cislox + cisloy;
cout << cislox << "+" << cisloy << "=" << vysledek1;
break;
case 2:
cout << "Zadejte číslo X" << endl;
cin >> cislox;
cout << "Zadejte číslo Y" << endl;
cin >> cisloy;
vysledek2 = cislox - cisloy;
cout << cislox << "-" << cisloy << "=" << vysledek2;
break;
case 3:
cout << "Zadejte číslo X" << endl;
cin >> cislox;
cout << "Zadejte číslo Y" << endl;
cin >> cisloy;
vysledek3 = cislox * cisloy;
cout << cislox << "*" << cisloy << "=" << vysledek3;
break;
case 4:
cout << "Zadejte číslo X" << endl;
cin >> cislox;
cout << "Zadejte číslo Y" << endl;
cin >> cisloy;
vysledek2 = cislox / cisloy;
cout << cislox << "/" << cisloy << "=" << vysledek4;
break;
}
cout << "chcete ukoncit program?" << "1 = ANO; 0 = NE" << endl;
cin >> konec;
}
return 0;
}
</code></pre>
<p>`</p>
<p>Well, i tried cheking all the code, but there should be no mistakes. Maybe im compiling it wrong? (im a MS VSCode user only for a while)</p>
| [
{
"answer_id": 74207095,
"author": "Kevin",
"author_id": 4528799,
"author_profile": "https://Stackoverflow.com/users/4528799",
"pm_score": 2,
"selected": false,
"text": ";"
},
{
"answer_id": 74207129,
"author": "Murgalha",
"author_id": 12730696,
"author_profile": "htt... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338894/"
] |
74,207,089 | <p>I am trying to build a bot which gives a random answer from CSV file.
Piece of code I have problem with:</p>
<pre class="lang-py prettyprint-override"><code>def get_data(lounaslista):
with open('C:\Users\p7l1n\Desktop\lounasbotti\lounaslista.csv', 'r') as f:
r = csv.reader(f)
data = [row for row in r]
return data
</code></pre>
<p>Error I'm getting:</p>
<p><code>SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape</code></p>
<p>I tried solutions from following <a href="https://stackoverflow.com/questions/68733658/is-there-a-faster-and-more-simple-way-for-randomizing-the-order-of-these-questio?noredirect=1&lq=1/">post</a>.</p>
| [
{
"answer_id": 74207095,
"author": "Kevin",
"author_id": 4528799,
"author_profile": "https://Stackoverflow.com/users/4528799",
"pm_score": 2,
"selected": false,
"text": ";"
},
{
"answer_id": 74207129,
"author": "Murgalha",
"author_id": 12730696,
"author_profile": "htt... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20324986/"
] |
74,207,092 | <p>Our web app need to run on two different servers. There are also two different properties files for those servers, like application.prd1.properties and application.prd1.properties. I do not use spring boot. So I can not use <strong>-Dspring.profiles.active=prd1</strong> script.</p>
<p>Now I am getting the properties file like below image
<a href="https://i.stack.imgur.com/jg6uU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jg6uU.png" alt="enter image description here" /></a></p>
<p>How can I use two different properties files on two different servers without spring boot?</p>
| [
{
"answer_id": 74207095,
"author": "Kevin",
"author_id": 4528799,
"author_profile": "https://Stackoverflow.com/users/4528799",
"pm_score": 2,
"selected": false,
"text": ";"
},
{
"answer_id": 74207129,
"author": "Murgalha",
"author_id": 12730696,
"author_profile": "htt... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8252154/"
] |
74,207,116 | <p>I am using scala 2.13 and have a string like this:</p>
<pre><code>-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAtp/Uo28kOjROL50aajnpK25CJoVoic2bqqu6OS2baWWD9fT2
ESqq8mbFxYN3O7JXbs+74YpTdg1jSUALOz9zj/H2eCF71QYvoHmdoi0iiQuy3gS1
6YczVvBvinSwfEnO6Wi/Xx6AC8urdr==
-----END RSA PRIVATE KEY-----
</code></pre>
<p>and I want to extract out</p>
<pre><code>MIIEpAIBAAKCAQEAtp/Uo28kOjROL50aajnpK25CJoVoic2bqqu6OS2baWWD9fT2
ESqq8mbFxYN3O7JXbs+74YpTdg1jSUALOz9zj/H2eCF71QYvoHmdoi0iiQuy3gS1
6YczVvBvinSwfEnO6Wi/Xx6AC8urdr==
</code></pre>
<p>I am using it as follows:</p>
<pre><code>val privateKey =
"-----BEGIN RSA PRIVATE KEY-----\r\nMIIEpAIBAAKCAQEAtp/Uo28kOjROL50aajnpK25CJoVoic2bqqu6OS2baWWD9fT2ESqq8mbFxYN3O7JXbs+74YpTdg1jSUALOz9zj/H2eCF71QYvoHmdoi0iiQuy3gS16YczVvBvinSwfEnO6Wi/Xx6AC8urdr==\r\n-----END RSA PRIVATE KEY-----\r\n"
val result = privateKey match {
case s"-----BEGIN RSA PRIVATE KEY-----\r\n$privateKeyB64\r\n-----END RSA PRIVATE KEY-----\r\n" => privateKeyB64
case _ => {
throw AEMServiceAccountError(s"Invalid RSA Private Key - Please check service account credentials for AEM.")
}
}
println(result)
</code></pre>
<p>but the above code always throws <code>Invalid RSA Private Key - Please check service account credentials for AEM.</code></p>
<p>Can someone help me debug what am I doing wrong here?</p>
| [
{
"answer_id": 74207899,
"author": "Alexey Ki",
"author_id": 12225798,
"author_profile": "https://Stackoverflow.com/users/12225798",
"pm_score": 2,
"selected": false,
"text": "val regex = \"-----BEGIN RSA PRIVATE KEY-----\\r\\n(.*)\\r\\n-----END RSA PRIVATE KEY-----\\r\\n\".r\nval result... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338961/"
] |
74,207,134 | <p>Let's say I have one array with 4 elements and also 4 divs.</p>
<pre class="lang-js prettyprint-override"><code>array = [a, b, c, d]
</code></pre>
<pre class="lang-html prettyprint-override"><code><div class="introduce-data-here"></div>
<div class="introduce-data-here"></div>
<div class="introduce-data-here"></div>
<div class="introduce-data-here"></div>
</code></pre>
<p>How do I insert the "a" from the array into the first div, then the "b" into the second div and so on and so on.</p>
<p>This is what I expect to have:</p>
<pre class="lang-html prettyprint-override"><code><div class="introduce-data-here">a</div>
<div class="introduce-data-here">b</div>
<div class="introduce-data-here">c</div>
<div class="introduce-data-here">d</div>
</code></pre>
| [
{
"answer_id": 74207899,
"author": "Alexey Ki",
"author_id": 12225798,
"author_profile": "https://Stackoverflow.com/users/12225798",
"pm_score": 2,
"selected": false,
"text": "val regex = \"-----BEGIN RSA PRIVATE KEY-----\\r\\n(.*)\\r\\n-----END RSA PRIVATE KEY-----\\r\\n\".r\nval result... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20325766/"
] |
74,207,135 | <p>I know that I need to use a <strong>Protocol</strong> if I want to type-hint a Mixin class.</p>
<pre><code>from typing import Protocol
class MyProtocol(Protocol):
a: int
class MyMixin:
def method(self: MyProtocol):
return self.a * 10
</code></pre>
<p>Here we type-hinting <strong>self</strong> and this does the job.
The problem arises when MyMixin also has its own properties/methods not related to Protocol class</p>
<pre><code>class MyMixin:
b: int
def method(self: MyProtocol):
return self.a * self.b # here should be typing error, MyProtocol has no "b"
</code></pre>
<p>How to properly resolve this kind of case?</p>
| [
{
"answer_id": 74207899,
"author": "Alexey Ki",
"author_id": 12225798,
"author_profile": "https://Stackoverflow.com/users/12225798",
"pm_score": 2,
"selected": false,
"text": "val regex = \"-----BEGIN RSA PRIVATE KEY-----\\r\\n(.*)\\r\\n-----END RSA PRIVATE KEY-----\\r\\n\".r\nval result... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13885312/"
] |
74,207,172 | <p>Within my application, I am dynamically creating and returning customers in JSON format. I would like to differentiate each customer, so I am adding a comma after the creation of each customer, but I do not wish to add the comma separation to the last element, so I would like to remove it.</p>
<p>Hence, I need to access the last element and make the modification, but I am running into some problems when doing the same. I tried to do this but was unable to concatenate the same. I am unable to get the last customer without a comma. The following is the code I have:</p>
<pre><code> public static Multi <String> generate(final Input input) {
final ObjectMapper objectMapper = new ObjectMapper();
try {
final Multi < String > generatedCustomer = Multi.createFrom().publisher(CustomerGenerator.createModels(input)).onItem().transform(
event - > {
try {
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(event) + ",";
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
});
final Multi < String > lastCustomer = generatedEvents.select().last().onItem().transform(i - > i.substring(0, i.length() - 1));
return Multi.createBy().concatenating().streams(generatedCustomer, lastCustomer);
} catch (Exception e) {
throw new CustomerException("Exception occurred during the generation of Customer : " + e);
}
}
</code></pre>
<p>How to achieve this?</p>
<p><strong>Updated</strong>
My application currently produces customer information in the following format asynchronously, so I would like to add a wrapper to it and make it look like the following JSON.</p>
<pre><code>{
"name": "Batman",
"age": 45,
"city": "gotham"
}
</code></pre>
<p>I would like to add a wrapper to it and make it like this:</p>
<pre><code>{
"isA": "customerDocument",
"createdOn": "2022-10-10T12:29:43",
"customerBody": {
"customerList": [
{
"name": "Batman",
"age": 45,
"city": "gotham"
},
{
"name": "superman",
"age": 50,
"city": "moon"
}
]
}
}
</code></pre>
<p>Hence, I have added a code something like this:</p>
<pre><code> public static Multi < String > generate(final Input input) {
final ObjectMapper objectMapper = new ObjectMapper();
try {
final Multi < String > beginDocument = Multi.createFrom().items("\"isA\":\"customerDocument\", \"creationDate\":\"" + Instant.now().toString() + "\", \"customerBody\":{ \"customerList\":[");
final Multi < String > generatedCustomer = Multi.createFrom().publisher(CustomerGenerator.createModels(input)).onItem().transform(
event - > {
try {
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(event) + ",";
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
});
final Multi < String > lastCustomer = generatedEvents.select().last().onItem().transform(i - > i.substring(0, i.length() - 1));
return Multi.createBy().concatenating().streams(beginDocument, generatedCustomer, lastCustomer, Multi.createFrom().items("]}}"));
} catch (Exception e) {
throw new CustomerException("Exception occurred during the generation of Customer : " + e);
}
}
</code></pre>
| [
{
"answer_id": 74210621,
"author": "Davide D'Alto",
"author_id": 2404683,
"author_profile": "https://Stackoverflow.com/users/2404683",
"pm_score": 1,
"selected": false,
"text": " public static Multi <String> generate(final Input input) {\n final ObjectMapper objectMapper = new Objec... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7584240/"
] |
74,207,228 | <pre><code>with res as(select us.column,mg.column as status,count(mg.column) FROM Table_name1 it
LEFT JOIN Table_name2 us on it.column=us.column
LEFT JOIN Table_name3 mg on it.column=mg.column
where it.column is not null and it.column in(5,6) and (it.column + '05:30:00'::INTERVAL)::date between '2022-08-28' and '2022-10-03' group by us.column,mg.column)
select res.column,
(case when column='Open' then count end) as Open_status,
(case when column='Closed' then count end) as Closed_status
from res group by res.column,res.column,res.column
</code></pre>
<p>i need to solve the remove duplicate entry in column1 open and close when it open and close status count details show and when it close the open details show the particular person</p>
<p><a href="https://i.stack.imgur.com/zqYq5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zqYq5.png" alt="i got output like this" /></a></p>
<p><a href="https://i.stack.imgur.com/OEQP0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OEQP0.png" alt="expected output like this" /></a></p>
| [
{
"answer_id": 74210621,
"author": "Davide D'Alto",
"author_id": 2404683,
"author_profile": "https://Stackoverflow.com/users/2404683",
"pm_score": 1,
"selected": false,
"text": " public static Multi <String> generate(final Input input) {\n final ObjectMapper objectMapper = new Objec... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20060151/"
] |
74,207,235 | <pre><code>login_input = {"MEK1300":"Python"}
username = {}
user = input("To login enter Yes. If you want to register enter No: ")
def login_info():
if user == "Yes":
login_user()
else:
user == "No"
register_user()
return user
def register_user():
new_user = input("Enter a username: ")
if new_user in login_input:
print("Your username already exists! ")
else:
new_password = input("Enter a password: ")
username[new_user] = new_password
print("Successful registration!")
def login_user():
login_user = input("Enter your username: ")
password = input("Enter your password: ")
if login_user in login_input and login_input[login_user] == password:
print("Successful login! ")
else:
print("Invalid username/passord. Register a new user!")
</code></pre>
<p>This is the beginning of a multiple choice quiz in python btw. How can i make this work? I dont want it to be to complicated.</p>
| [
{
"answer_id": 74210621,
"author": "Davide D'Alto",
"author_id": 2404683,
"author_profile": "https://Stackoverflow.com/users/2404683",
"pm_score": 1,
"selected": false,
"text": " public static Multi <String> generate(final Input input) {\n final ObjectMapper objectMapper = new Objec... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339030/"
] |
74,207,238 | <p>I want to apply limit on Sequelize table declaration.
This would actually limit the rows total of the table to 1 by forbidding to add more rows into it.
How can I achieve this in the table model definition?</p>
| [
{
"answer_id": 74207321,
"author": "r31sr4r",
"author_id": 3329423,
"author_profile": "https://Stackoverflow.com/users/3329423",
"pm_score": 0,
"selected": false,
"text": "findAll({\n limit: 2,\n where: { YOUR QUERY }\n)}\n"
},
{
"answer_id": 74207502,
"author": "Xavier... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20122571/"
] |
74,207,253 | <p>I'm new in flutter, i'm using <strong>sms_autofill</strong> package to listen otp from my phone.</p>
<p>My question is how to directly navigate to the next screen when otp already filled without making a button ?</p>
<p>Here's my otp screen</p>
<p><a href="https://i.stack.imgur.com/30Kz2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/30Kz2.jpg" alt="enter image description here" /></a></p>
<p>Really appreciate for your help, Thanks before...</p>
| [
{
"answer_id": 74207321,
"author": "r31sr4r",
"author_id": 3329423,
"author_profile": "https://Stackoverflow.com/users/3329423",
"pm_score": 0,
"selected": false,
"text": "findAll({\n limit: 2,\n where: { YOUR QUERY }\n)}\n"
},
{
"answer_id": 74207502,
"author": "Xavier... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12897358/"
] |
74,207,287 | <p>I'm learning React and making a very simple app, where I am getting info from github api and displaying my repos information. It doesn't work tho and I keep getting an error when I'm trying to find a particular</p>
<blockquote>
<p>Uncaught TypeError: data.find is not a function</p>
</blockquote>
<p>Here's my code (I deleted almost everything meaningful and left only the part where I'm trying to get at least one repository from the array):</p>
<pre><code>`const RepoList = ({ repos }) => {
const data = Getapiinfo("egor-no");
const repo = data.find(item => item.name == "clangametesttask")
return (
<>
<p>{JSON.stringify(repo)}</p>
</>
);
}`
</code></pre>
<p>That's what Getapiinfo function does (gets all the information about all my repos):</p>
<pre><code>function Getapiinfo(login) {
const [data, setData] = useState(null);
useEffect(() => {
fetch(`https://api.github.com/users/${login}/repos`)
.then((response) => response.json())
.then(setData);
}, []);
if (data) {
return data;
};
return "";
}
</code></pre>
<p>I'm not sure what I am missing, because <code>data </code> is definitely an array. At least when I delete the find line, it all works as expected and gets an element by its index:</p>
<pre><code>const RepoList = ({ repos }) => {
const data = Getapiinfo("egor-no");
return (
<>
<p>{JSON.stringify(data)}</p>
<p>{JSON.stringify(data[0])}</p>
</>
);
}
</code></pre>
<p>Can you help me with that? I've already spent too much time on this problem and I know it is something simple that I can't just notice. I've also looked through several topics here but none of them seem to have a correct answer or any answers at all :D</p>
| [
{
"answer_id": 74207321,
"author": "r31sr4r",
"author_id": 3329423,
"author_profile": "https://Stackoverflow.com/users/3329423",
"pm_score": 0,
"selected": false,
"text": "findAll({\n limit: 2,\n where: { YOUR QUERY }\n)}\n"
},
{
"answer_id": 74207502,
"author": "Xavier... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13447185/"
] |
74,207,292 | <p>I collect some data from various urls into an array, using a for loop:</p>
<pre><code>let data3;
const getPhotosData = async (album) => {
const url = `https://jsonplaceholder.typicode.com/albums/${album}/photos`;
const res = await fetch(url);
const jsonRes = await res.json();
return jsonRes;
};
let data = [];
for (let i = 1; i < 101; i++) {
const promise = getPhotosData(i);
promise.then((items) => {
data.push(items);
});
data3 = data;
}
</code></pre>
<p>if I log <code>data3</code> to the console, I'll get an array with multiple arrays of 50 objects each, but if I log <code>data3.length</code> I get 0, and of course i can't perform any iterations on it like, <code>map</code>, <code>flat</code> or <code>forEach</code> (what i want is to flatten data3 into a single array of objects).</p>
<p>I tried defining <code>data3</code> as a state variable and then only flatten it (or even just get its's length), after setting it's value inside a <code>useEffect</code> hook, with <code>data</code> inside dependency array (or dependency array empty), but got same results.</p>
| [
{
"answer_id": 74207321,
"author": "r31sr4r",
"author_id": 3329423,
"author_profile": "https://Stackoverflow.com/users/3329423",
"pm_score": 0,
"selected": false,
"text": "findAll({\n limit: 2,\n where: { YOUR QUERY }\n)}\n"
},
{
"answer_id": 74207502,
"author": "Xavier... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19108978/"
] |
74,207,322 | <p>I have a hard time understanding why I can refer to the output columns in <code>returns table(col type)</code>.</p>
<p>There is a subtle bug in the below code, the <code>order by</code> var refers to <code>res</code> in <code>returns</code>, not to <code>data1</code> which we aliased to <code>res</code>. <code>res</code> in <code>where</code> is always null and we get 0 rows.</p>
<p>Why can I refer to the column name in output?<br />
In what cases do I want this?</p>
<pre><code>CREATE OR REPLACE FUNCTION public.test(var INTEGER)
RETURNS table(res int )
LANGUAGE plpgsql
AS $function$
begin
return query
select data1 res
from table_with_data
where res < var;
end
$function$
</code></pre>
| [
{
"answer_id": 74236504,
"author": "Zegarek",
"author_id": 5298879,
"author_profile": "https://Stackoverflow.com/users/5298879",
"pm_score": 3,
"selected": true,
"text": "res"
},
{
"answer_id": 74243433,
"author": "Erwin Brandstetter",
"author_id": 939860,
"author_pro... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/286930/"
] |
74,207,350 | <pre><code>CREATE or replace PROCEDURE mytransactions (n_transactions_id VARCHAR,
n_transaction_amount SMALLINT,
n_transaction_date TIMESTAMP,
n_Delivery_date Date,
n_customer_id VARCHAR,
n_product_id VARCHAR,
n_store_id VARCHAR)
LANGUAGE plpgsql AS
$BODY$
BEGIN
INSERT INTO transactions
(transactions_id,
transaction_amount,
transaction_date,
Delivery_date,
customer_id,
product_id,
store_id)
VALUES
(n_transactions_id, n_transaction_amount,
n_transaction_date,
n_Delivery_date,
n_customer_id,
n_product_id,
n_store_id);
END;
$BODY$
</code></pre>
<p>Here is my stored procedure, it creates successfully, however once I call</p>
<pre><code>CALL mytransactions
('555', 3, current_timestamp , to_date('2022-10-25','YYYY-MM-DD'),
'003', '300', '002RW');
</code></pre>
<p>it I get an error.</p>
<pre><code>ERROR: procedure mytransactions(unknown, integer, timestamp with time zone, date, unknown, unknown, unknown) does not exist
LINE 1: CALL mytransactions
^
HINT: No procedure matches the given name and argument types. You might need to add explicit type casts.
</code></pre>
<p>Here you can find full tables <a href="https://dbfiddle.uk/9_NIQDw6" rel="nofollow noreferrer">https://dbfiddle.uk/9_NIQDw6</a></p>
| [
{
"answer_id": 74236504,
"author": "Zegarek",
"author_id": 5298879,
"author_profile": "https://Stackoverflow.com/users/5298879",
"pm_score": 3,
"selected": true,
"text": "res"
},
{
"answer_id": 74243433,
"author": "Erwin Brandstetter",
"author_id": 939860,
"author_pro... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339101/"
] |
74,207,357 | <p>I have a Class B, which is inheriting Class A.
I have a Class C, which is inheriting Class B and Class A;</p>
<p>There is a variable named "a" in class A which I have to access in class D, but not by using resolution operator on class B for example , d.B::a;</p>
<pre><code>#include<bits/stdc++.h>
using namespace std;
class A{
public:
int a;
};
class B : public A{
public:
int b;
};
class D : public B, public A{
public:
int d;
};
int main() {
D d;
d.B::a = 1; // This is working correctly on this path class D -\> class B -\> class A
d.a = 2;
/*
But This line gives the following error
Non-static member 'a' found in multiple base-class subobjects of type 'A':
class D -> class B -> class A
class D -> class A
*/
return 0;
}
int main() {
D d;
d.D::a = 2; //This is not working correctly on this path class D -\> class A
d.A::a = 2; //This is not working correctly on this path class D -\> class A
//How do I use Scope Resolution to access variable "a" from second path ?!
return 0;
}
</code></pre>
| [
{
"answer_id": 74236504,
"author": "Zegarek",
"author_id": 5298879,
"author_profile": "https://Stackoverflow.com/users/5298879",
"pm_score": 3,
"selected": true,
"text": "res"
},
{
"answer_id": 74243433,
"author": "Erwin Brandstetter",
"author_id": 939860,
"author_pro... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7408242/"
] |
74,207,407 | <p>I have a dataset that contains 8 columns "A1", "A2" etc, each with a value of 0-4, including NAs. These columns are repeated for different time points, so "3A1" would be 3 month, "6A1" is 6 months etc. I want to create a new column called "Status" that:</p>
<ul>
<li>If all columns are NA -> "incomplete"</li>
<li>If any of the 8 columns contain NA -> "partial completion"</li>
<li>If all columns !=NA -> "fully completed"</li>
</ul>
<p>Can someone help with the code?</p>
<pre><code>October_data_UK$"Status" <- ifelse(October_data_UK$`A1`!=0 & October_data_UK$`A2`!==0 & October_data_UK$`A3`!==0 & October_data_UK$`A4`!==0 & October_data_UK$`A5`!==0 & October_data_UK$`A6`!==0 & October_data_UK$`A7`!==0 & October_data_UK$`A8`!==0 & October_data_UK$`A9`!==0 & October_data_UK$`A10`!==0, 2,
ifelse(October_data_UK$`A1`==0 | October_data_UK$`A2`==0| October_data_UK$`A3`==0 | October_data_UK$`A4`==0 | October_data_UK$`A5`==0 | October_data_UK$`A6`==0 | October_data_UK$`A7`==0 | October_data_UK$`A8`==0 | October_data_UK$`A9`==0 | October_data_UK$`A10`==0, 1),
ifelse(October_data_UK$`A1`==0 & October_data_UK$`A2`==0 & October_data_UK$`A3`==0 & October_data_UK$`A4`==0 & October_data_UK$`A5`==0 & October_data_UK$`A6`==0 & October_data_UK$`A7`==0 & October_data_UK$`A8`==0 & October_data_UK$`A9`==0 & October_data_UK$`A10`==0, 0, NA))
</code></pre>
<pre><code></code></pre>
| [
{
"answer_id": 74207534,
"author": "DaveArmstrong",
"author_id": 8206434,
"author_profile": "https://Stackoverflow.com/users/8206434",
"pm_score": 1,
"selected": false,
"text": "set.seed(207)\nmat <- matrix(sample(c(1:4, NA), 400, replace=TRUE), ncol=10)\ncolnames(mat) <- paste(\"A\", 1:... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19251173/"
] |
74,207,427 | <p>Suppose I have 3 worksheets "Asutosh","Asutosh2","Asutosh3" I want to delete "Asutosh2" and "Asutosh3" using vba.</p>
<p>I used vba but I have to do it manually for other names such as if I record for Asutosh , other extra duplicate sheets don not delete.</p>
| [
{
"answer_id": 74207505,
"author": "EuanM28",
"author_id": 12200628,
"author_profile": "https://Stackoverflow.com/users/12200628",
"pm_score": 1,
"selected": false,
"text": "Private Sub Workbook_BeforeClose(Cancel As Boolean) 'Closes all other worksheets par \"Asutosh\", saves user time ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20046004/"
] |
74,207,428 | <p>Given a python dictionary. I've written a function that returns a list of keys whose values are unique in the given dictionary. Let's say that <code>aDict = {1: 1, 3: 2, 6: 0, 7: 0, 8: 4, 10: 0}</code>. The function returns <code>[1, 3, 8]</code>. Keys that are mapped to 0 aren't returned because their share value with other key.</p>
<p>The function works but it's complexity is quadratic and verbose. I couldn't do it with dictionary comprehension.</p>
<pre><code>def foo(aDict):
result = []
for key in aDict.keys():
count = 0
for other in aDict.keys():
if aDict[key] == aDict[other]:
count += 1
if count > 1:
break
else:
result.append(key)
return sorted(result)
print(foo({1: 1, 3: 2, 6: 0, 7: 0, 8: 4, 10: 0}))
</code></pre>
| [
{
"answer_id": 74207557,
"author": "Vsevolod Timchenko",
"author_id": 5153932,
"author_profile": "https://Stackoverflow.com/users/5153932",
"pm_score": 2,
"selected": false,
"text": "from collections import defaultdict\n\ndef foo1(aDict):\n capture = defaultdict(lambda: 0)\n for i ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11473652/"
] |
74,207,443 | <p>I just got handed down an older JavaScript project (the original devs already left the company and are not available). Recently I found a condition like this:</p>
<pre class="lang-js prettyprint-override"><code>const xPermanent = await Promise(/* some call to a Sequelize 5.8.x object */)
const xMulti = await Promise(/* some call to a Sequelize 5.8.x object */)
// lots of code which occasionally checks but never modifies xMulti
if (xPermanent && (!xMulti || xMulti)) {
</code></pre>
<p>I'm no expert in Javascript. As I understand, this always evaluates to <code>true</code> if <code>xPermanent</code> is true. Are there any edge cases in which this could evaluate to <code>false</code> other than <code>xPermanent</code> being <code>false</code>?</p>
<p>My normal understanding of logic would say, that I can remove the second part of the condition, but I also heard Javascript does weird things evaluating objects sometimes...</p>
| [
{
"answer_id": 74207508,
"author": "Greg Burghardt",
"author_id": 3092298,
"author_profile": "https://Stackoverflow.com/users/3092298",
"pm_score": 2,
"selected": false,
"text": "(!xMulti || xMulti)"
},
{
"answer_id": 74207636,
"author": "Keith",
"author_id": 6870228,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338982/"
] |
74,207,473 | <p>I had 3 objects</p>
<pre><code>[{u'criados': u'25/10/2022 00:50', u'arquivo': u'http://hml.static.detran.al.gov.br/media/infracoes/notificacoes/9.pdf', u'id': 1, u'tipo': u'NAI', u'slug': u'Teste-1'}, {u'criados': u'25/10/2022 23:54', u'arquivo': u'http://hml.static.detran.al.gov.br/media/infracoes/notificacoes/Profile.pdf', u'id': 2, u'tipo': u'NIP', u'slug': u'copa-06'}, {u'criados' : u'16/5/2020 21:25', u'arquivo': u'http://hml.static.detran.al.gov.br/media/infracoes/notificacoes/test.pdf', u'id' : 3, u'tipo: u'NIP', u'slug': u'test-02'}]
</code></pre>
<p>this objects has different year and i want to display in html something like this:</p>
<pre><code>2022
- Object 1
- Object 2
2020
- Object 3
</code></pre>
<p>please help me</p>
| [
{
"answer_id": 74208150,
"author": "Hashem",
"author_id": 18806558,
"author_profile": "https://Stackoverflow.com/users/18806558",
"pm_score": 0,
"selected": false,
"text": "{{regroup}}"
},
{
"answer_id": 74208318,
"author": "Zkh",
"author_id": 19235697,
"author_profil... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18996279/"
] |
74,207,479 | <p>I am trying to handle file errors manually so I can print my own message and currently I have this code:</p>
<pre class="lang-hs prettyprint-override"><code>handleFileError :: FileError -> IO a
handleFileError (FileError errorKind) = do
case errorKind of
NotFound -> undefined
NoPermission -> undefined
IsDirectory -> undefined
fileRead :: String -> IO String
fileRead file = do
pathExists <- doesPathExist file
notDirectory <- doesFileExist file
-- These two must be handled before `System.Directory.getPermissions` is called
-- or else it will error.
permissions <- getPermissions file
let hasReadPermissions = readable permissions
if hasReadPermissions then undefined -- This is the success case
else handleFileError $ FileError NoPermissions
</code></pre>
<p>I would like to check if any of the 3 booleans (pathExists, notDirectory, and hasReadPermissions) are false, and then act accordingly. I tried to implement this using a case with <code>False</code>, however this just always runs the first branch.</p>
| [
{
"answer_id": 74207741,
"author": "Basil",
"author_id": 17365525,
"author_profile": "https://Stackoverflow.com/users/17365525",
"pm_score": 1,
"selected": false,
"text": "if"
},
{
"answer_id": 74209608,
"author": "Daniel Wagner",
"author_id": 791604,
"author_profile"... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17365525/"
] |
74,207,480 | <pre><code>def repeat(num_times):
def decorator_repeat(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
for _ in range(num_times):
func(*args, **kwargs)
return wrapper
return decorator_repeat
@repeat(num_times=2)
def say_whee(name):
print(f"Hello {name}")
say_whee('Alex')
# Hello Alex
# Hello Alex
</code></pre>
<p>say_whee function object is passed in decorator_repeat, however, to me, it seems no parameter is passed into wrapper. Inside wrapper, it has access to func because it is accessed through outer scope. But how does func(*args, **kwargs) get access to say_whee's param, namely 'Alex'? It seems that decorator takes func, then func's params just magically seep through to wrapper as well as func inside wrapper. How is this implemented behind the scenes?</p>
| [
{
"answer_id": 74207719,
"author": "Ahmed AEK",
"author_id": 15649230,
"author_profile": "https://Stackoverflow.com/users/15649230",
"pm_score": 0,
"selected": false,
"text": "decorator_repeat"
},
{
"answer_id": 74207985,
"author": "chepner",
"author_id": 1126841,
"au... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19756041/"
] |
74,207,481 | <p>In the algorithm I am writing I didn't expect the following part to be the bottleneck.
Here is a trimmed down version of my code:</p>
<pre><code>using LinearAlgebra
A = rand(1000,100)
R = triu(rand(100,100))
for i = 1:300
R = triu(rand(100,100))
@views nrms = norm.(eachrow(A[i:end, :] * R'))
end
</code></pre>
<p>Is there a way to accelerate the computation of <code>nrms</code>?</p>
<p>I could perfectly store A transposed instead of how I am storing it now if that helps, but the impact seems minimal, for example</p>
<pre><code>@views nrms = norm.(eachcol(conj(R)*AT[:,i:end])
</code></pre>
<p>with <code>AT = copy(transpose(A))</code>.
I also tried writing manually a loop that would avoid storing the product <code>A[i:end, :] * R'</code> but this was always much slower as no blas was used then for gemm.</p>
| [
{
"answer_id": 74212889,
"author": "DNF",
"author_id": 2749865,
"author_profile": "https://Stackoverflow.com/users/2749865",
"pm_score": 3,
"selected": true,
"text": "@tturbo"
},
{
"answer_id": 74249893,
"author": "Dan Getz",
"author_id": 3580870,
"author_profile": "h... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339131/"
] |
74,207,489 | <p>I'm trying to create a regex that will select the numbers/numbers with commas(if easier, can trim commas later) that do not have a parentheses after and not the numbers inside the parentheses should not be selected either.</p>
<p>Used with the JavaScript's String.match method</p>
<p>Example strings</p>
<pre><code>9(296,178),5,3(123),10
10,9(296,178),2,5,3(123),3(124,125)
10,7,5(296,293,444,1255),3(218),2,4
</code></pre>
<p>What i have so far:</p>
<pre><code>/((^\d+[^\(])|(,\d+,)|(,*\d+$))/gm
</code></pre>
<p>I tried this in regex101 and underlined the numbers i would like to match and x on the one that should not.</p>
<p><a href="https://i.stack.imgur.com/X4xFs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X4xFs.png" alt="I tried this in regex101 and underlined the numbers i would like to match and x on the one that should not" /></a></p>
| [
{
"answer_id": 74207760,
"author": "Mathieu CAROFF",
"author_id": 9878263,
"author_profile": "https://Stackoverflow.com/users/9878263",
"pm_score": 0,
"selected": false,
"text": "var textA = `9(296,178),5,3(123),10\n10,9(296,178),2,5,3(123),3(124,125)\n10,7,5(296,293,444,1255),3(218),2,4... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14662242/"
] |
74,207,528 | <p>I need to find the minimum distance from a point <code>(X,Y)</code> to a curve defined by four coefficients <code>C0, C1, C2, C3</code> like <code>y = C0 + C1X + C2X^2 + C3X^3</code></p>
<p>I have used a numerical approach using <code>np.linspace</code> and <code>np.polyval</code> to generate discrete <code>(X,Y)</code> for the curve and then the <code>shapely</code> 's <code>Point</code>, <code>MultiPoint</code> and <code>nearest_points</code> to find the nearest points, and finally <code>np.linalg.norm</code> to find the distance.</p>
<p>This is a numerical approach by discretizing the curve.</p>
<p>My question is how can I find the distance by analytical methods and code it?</p>
| [
{
"answer_id": 74207760,
"author": "Mathieu CAROFF",
"author_id": 9878263,
"author_profile": "https://Stackoverflow.com/users/9878263",
"pm_score": 0,
"selected": false,
"text": "var textA = `9(296,178),5,3(123),10\n10,9(296,178),2,5,3(123),3(124,125)\n10,7,5(296,293,444,1255),3(218),2,4... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4451521/"
] |
74,207,537 | <p>I wrote type checking constexpr function.
It the type is <code>type1</code> or <code>type2</code> then returns true, otherwise returns false.</p>
<p>Here is the code. It works as I expected.</p>
<pre class="lang-cpp prettyprint-override"><code>#include <type_traits>
struct type1{};
struct type2{};
struct type3{};
template <typename T>
constexpr bool is_type1or2() {
return std::is_same_v<T, type1> || std::is_same_v<T, type2>;
}
static_assert(is_type1or2<type1>());
static_assert(is_type1or2<type2>());
static_assert(!is_type1or2<type3>());
int main(){}
</code></pre>
<p><a href="https://godbolt.org/z/dncKo1Pbb" rel="nofollow noreferrer">https://godbolt.org/z/dncKo1Pbb</a></p>
<p>Now, <code>type1</code> is changed to template that has non-type parameter.
How to do the same type checking?</p>
<pre class="lang-cpp prettyprint-override"><code>#include <type_traits>
template <std::size_t N>
struct type1{};
struct type2{};
struct type3{};
template <typename T>
constexpr bool is_type1or2() {
return std::is_same_v<T, type2>;
}
template <typename T, std::size_t N>
constexpr bool is_type1or2() {
return std::is_same_v<T, type1<N>>;
}
// I want to write as follows but I couldn't find a way, so far.
// static_assert(is_type1or2<type1<42>>());
// so I pass explicit second template argument 42.
static_assert(is_type1or2<type1<42>, 42>());
static_assert(is_type1or2<type2>());
static_assert(!is_type1or2<type3>());
int main(){}
</code></pre>
<p><a href="https://godbolt.org/z/G1o5447z8" rel="nofollow noreferrer">https://godbolt.org/z/G1o5447z8</a></p>
<p>I tried but I can't eliminate the second template argument. It avoids generic code.
Is there any good way to check the type is <code>type1<anyN></code> or <code>type2</code> ?</p>
<p>In my actual case, I have 20 of non template types like <code>type2</code> and 20 of template types like <code>type1</code>. And half of them need to match. I want to avoid code repeatation as long as I can.</p>
<h2>Clarify requirement</h2>
<p>For template type <code>type1<N></code>, <code>N</code> is not important. Both template is <code>type1</code> is important. So the result of <code>is_type1or2<type1<10>>()</code> and <code>is_type1or2<type1<20>>()</code> are always same. I don't need to define individual template argument specialization based matching.</p>
| [
{
"answer_id": 74208177,
"author": "Nelfeal",
"author_id": 3854570,
"author_profile": "https://Stackoverflow.com/users/3854570",
"pm_score": 2,
"selected": false,
"text": "template <typename>\nstruct is_type1 : public std::false_type {};\n\ntemplate <std::size_t N>\nstruct is_type1<type1... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1922763/"
] |
74,207,553 | <p>Why doesn't this work in C#?</p>
<pre><code>var dict1 = new Dictionary<int, System.Collections.IEnumerable>();
dict1[0] = new List<string>(); // OK, because implements IEnumerable
var dict2 = new Dictionary<int, List<string>>();
dict1 = (Dictionary<int, System.Collections.IEnumerable>)dict2; // Compiler error CS0030
</code></pre>
<p>We can clearly see that every value in <code>dict2</code> <em>must</em> implement <code>IEnumerable</code> because it is a <code>List<T></code>, so why can't I assign it to a <code>Dictionary<int, System.Collections.IEnumerable></code>? Is there a way to do this?</p>
<p>My use case here is that I have some code that wants to use the more specific stuff in (in this example) the <code>List<string></code>, but some other code that needs to take an <code>IEnumerable</code> dictionary. I can explicitly cast in every predicate to get access to the more specific stuff, but it seems pretty messy and I'd rather have a reference to the (same) Dictionary where its value's type is actually <code>List<string></code>:</p>
<pre><code>var dict1 = new Dictionary<int, System.Collections.IEnumerable>();
dict1[0] = new List<string>(); // OK, because implements IEnumerable
var result = dict1.Where(x => ((List<string>)x.Value).Capacity > 100);
</code></pre>
| [
{
"answer_id": 74207672,
"author": "jmcilhinney",
"author_id": 584183,
"author_profile": "https://Stackoverflow.com/users/584183",
"pm_score": 1,
"selected": false,
"text": "var dict1 = new Dictionary<int, System.Collections.IEnumerable>();\ndict1[0] = new List<string>(); // OK, because ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/178757/"
] |
74,207,571 | <p>I am trying to collect all active TIs via the Beta Graph API by following <a href="https://learn.microsoft.com/en-us/graph/api/tiindicators-list?view=graph-rest-beta&tabs=http" rel="nofollow noreferrer">this</a>. But it doesn't return anything. Here is what I use in Postman:</p>
<p><code>https://graph.microsoft.com/beta/security/tiIndicators</code></p>
<p>Response (200):</p>
<pre><code>{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#security/tiIndicators",
"value": []
}
</code></pre>
<p>A bit of context for the environment I work in.</p>
<ul>
<li>The tenant has multiple Sentinel workspaces & resource groups.</li>
<li>The application I use has the correct permissions:
<ul>
<li><code>ThreatIndicators.Read.All</code></li>
<li><code>ThreatIndicators.ReadWrite.OwnedBy</code></li>
<li><code>ThreatSubmission.Read.All</code></li>
<li><code>ThreatSubmission.ReadWrite.All</code></li>
</ul>
</li>
</ul>
<p>It is my current belief that this might be due to the limitations of the Beta API. My reasoning is that accourding to <a href="https://learn.microsoft.com/en-us/graph/api/tiindicators-list?view=graph-rest-beta&tabs=http" rel="nofollow noreferrer">this</a> documentation you need the <code>ThreatIndicators.ReadWrite.OwnedBy</code> permission to access the API. This would suggest that currently you can only view TI's that the resource itself created.</p>
<p>If more info is needed just ask.</p>
| [
{
"answer_id": 74207672,
"author": "jmcilhinney",
"author_id": 584183,
"author_profile": "https://Stackoverflow.com/users/584183",
"pm_score": 1,
"selected": false,
"text": "var dict1 = new Dictionary<int, System.Collections.IEnumerable>();\ndict1[0] = new List<string>(); // OK, because ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13549544/"
] |
74,207,577 | <p>I am doing school project in university (C++). In nutshell the professor has made a skeleton program that needs functions added to it. The program saves train stations (id, name, coordinates xy) and regions.</p>
<p>I am supposed to make several functions that handle data in the program (add station, count stations, return them in alphabetical order, measure distance between stations, find station with id etc), and most of them I can make myself. But in order to use those functions, I need the first function to work. That function is supposed to create a station object and store it to a vector.</p>
<p>I don't understand why the program gives me an error when I try to build it. I am using qtcreator.</p>
<p>Below is the code I have written:</p>
<pre><code>bool Datastructures::add_station(StationID id, const Name& name, Coord xy)
{
Station x (id, name, xy);
x.id_ = id;
x.name_ = name;
x.coord_ = xy;
if(std::count(stations.begin(), stations.end(), x.id_)){
return false;
}
stations.push_back(x);
return true;
}
</code></pre>
<p>The code is referring to the following struct that I created:</p>
<pre><code>struct Station {
StationID id_;
Name name_;
Coord coord_;
Station(StationID id, Name name, Coord coord):
id_(id), name_(name), coord_(coord){
}
};
std::vector<Station> stations;
</code></pre>
<p>The initialization of Struct object is nested inside the Datastructures.hh file, under private part of the class Datastructures.</p>
<p>When I try to build the whole program, I receive the error:</p>
<pre><code>/opt/lintula/gcc/include/c++/12.1.0/bits/predefined_ops.h:270: error: no match for ‘operator==’ (operand types are ‘Datastructures::Station’ and ‘const std::__cxx11::basic_string<char>’)
In file included from /opt/lintula/gcc/include/c++/12.1.0/bits/stl_algobase.h:71,
from /opt/lintula/gcc/include/c++/12.1.0/string:50,
from ../prg1/datastructures.hh:10,
from ../prg1/datastructures.cc:7:
/opt/lintula/gcc/include/c++/12.1.0/bits/predefined_ops.h: In instantiation of ‘bool __gnu_cxx::__ops::_Iter_equals_val<_Value>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<Datastructures::Station*, std::vector<Datastructures::Station> >; _Value = const std::__cxx11::basic_string<char>]’:
/opt/lintula/gcc/include/c++/12.1.0/bits/stl_algobase.h:2123:12: required from ‘typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::__count_if(_InputIterator, _InputIterator, _Predicate) [with _InputIterator = __gnu_cxx::__normal_iterator<Datastructures::Station*, vector<Datastructures::Station> >; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const __cxx11::basic_string<char> >; typename iterator_traits< <template-parameter-1-1> >::difference_type = long int]’
/opt/lintula/gcc/include/c++/12.1.0/bits/stl_algo.h:4034:29: required from ‘typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<Datastructures::Station*, vector<Datastructures::Station> >; _Tp = __cxx11::basic_string<char>; typename iterator_traits< <template-parameter-1-1> >::difference_type = long int]’
../prg1/datastructures.cc:80:18: required from here
/opt/lintula/gcc/include/c++/12.1.0/bits/predefined_ops.h:270:24: error: no match for ‘operator==’ (operand types are ‘Datastructures::Station’ and ‘const std::__cxx11::basic_string<char>’)
270 | { return *__it == _M_value; }
| ~~~~~~^~~~~~~~~~~
</code></pre>
<p>I don't understand what I have done wrong. This is my first post here btw, so sorry for technical mistakes.</p>
| [
{
"answer_id": 74207672,
"author": "jmcilhinney",
"author_id": 584183,
"author_profile": "https://Stackoverflow.com/users/584183",
"pm_score": 1,
"selected": false,
"text": "var dict1 = new Dictionary<int, System.Collections.IEnumerable>();\ndict1[0] = new List<string>(); // OK, because ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339195/"
] |
74,207,589 | <p>I need to make a pyramid in python using recursion.
Already made it, but I need help making it with recursion.</p>
<pre><code>def pyramid(n):
for i in range(0, n):
for j in range(0, i+1):
print("* ",end="")
print("\r")
pyramid(5)
</code></pre>
| [
{
"answer_id": 74207631,
"author": "Matei Piele",
"author_id": 18143450,
"author_profile": "https://Stackoverflow.com/users/18143450",
"pm_score": 4,
"selected": true,
"text": "def pyramid(n):\n if n==0:\n return\n else:\n pyramid(n-1)\n print(\"* \"*n)\n\nn = ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339270/"
] |
74,207,598 | <p>Suppose I have these two dataframes:</p>
<pre><code>df1=
ID index
087 4
087 5
087 6
</code></pre>
<pre><code>df2=
ID index
087 1
087 2
087 3
...
087 10
087 11
087 12
...
</code></pre>
<p>And I would like to compare/join them based on the ID and index columns and then create a 'pred' column in the rows that df1 also has. So that the resulting df would look like this:</p>
<pre><code>result_df=
ID index pred
087 1 0
087 2 0
087 3 0
087 4 1
087 5 1
087 6 1
087 7 0
...
087 12 0
...
</code></pre>
<p>Does anybody have a neat solution to this?</p>
| [
{
"answer_id": 74207661,
"author": "Hisham",
"author_id": 7231697,
"author_profile": "https://Stackoverflow.com/users/7231697",
"pm_score": 1,
"selected": false,
"text": "import pandas as pd\n\nnew_df = pd.merge(df1, df2, how='inner', on = 'ID')\nnew_df\n"
},
{
"answer_id": 74207... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20127965/"
] |
74,207,607 | <p>So. I am trying to convert a uint16_t (16 byte int) to class. To get the class member varaible. But it is not working as expected.</p>
<pre class="lang-cpp prettyprint-override"><code>
class test{
public:
uint8_t m_pcp : 3; // Defining max size as 3 bytes
bool m_dei : 1;
uint16_t m_vid : 12; // Defining max size as 12 bytes
public:
test(uint16_t vid, uint8_t pcp=0, bool dei=0) {
m_vid = vid;
m_pcp = pcp;
m_dei = dei;
}
};
int main() {
uint16_t tci = 65535;
test t = (test)tci;
cout<<"pcp: "<<t.m_pcp<<" dei: "<<t.m_dei<<" vid "<<t.m_vid<<"\n";
return 0;
}
</code></pre>
<p>Expected output:</p>
<pre><code>pcp:1 dei: 1 vid 4095
</code></pre>
<p>The actual output:</p>
<pre><code>pcp: dei: 0 vid 4095
</code></pre>
<p>Also,</p>
<pre><code>cout<<sizeof(t)
</code></pre>
<p>returns 2. shouldn't it be 4?</p>
<p>Am I doing something wrong?</p>
| [
{
"answer_id": 74207903,
"author": "Nelfeal",
"author_id": 3854570,
"author_profile": "https://Stackoverflow.com/users/3854570",
"pm_score": 2,
"selected": true,
"text": "test t = (test)tci;\n"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19393268/"
] |
74,207,638 | <p>I am working on <code>yii2</code>.</p>
<p>I have a below field in my <code>_form</code></p>
<pre><code>$form->field($model, 'area_name')
->widget(Select2::className(),[
'data' => \common\models\AllowArea::toAreaArrayList(),
'options' => ['placeholder'=>'Select Area'],
'pluginOptions' => [
'allowClear' => true,
'multiple' => true
],
]);
?>
</code></pre>
<p>When I am trying to select from it I am getting</p>
<p><strong>Area Name must be a string.</strong></p>
<p><strong>GUI</strong></p>
<p><a href="https://i.stack.imgur.com/ZZYTf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZZYTf.png" alt="enter image description here" /></a></p>
<p>Below is my validation rule</p>
<pre><code>public function rules()
{
return [
[['user_id','created_by','updated_by'], 'integer'],
[['area_name','user_id','salesman_code','city_name'], 'required'],
[['area_code', 'user_name'], 'string', 'max' => 50],
[['created_at'],'safe'],
[['area_name', 'salesman_code', 'salesman_name'], 'string', 'max' => 100],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
];
}
</code></pre>
<p><strong>Function</strong></p>
<pre><code>public static function toAreaArrayList()
{
$sds = Yii::$app->sds->createCommand("Select * from Area")->queryAll();
return ArrayHelper::map(Yii::$app->sds->createCommand("select distinct AreaNameFull from Area where AreaCode NOT IN ('020201001','020202001')")->queryAll(),'AreaNameFull',function($sds, $defaultValue){
return $sds['AreaNameFull'];
});
}
</code></pre>
<p>Any help would be highly appreciated.</p>
| [
{
"answer_id": 74207903,
"author": "Nelfeal",
"author_id": 3854570,
"author_profile": "https://Stackoverflow.com/users/3854570",
"pm_score": 2,
"selected": true,
"text": "test t = (test)tci;\n"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6854117/"
] |
74,207,647 | <p>How can I change the textcolor of word A when the user hovers over word B? E.g. when the user hovers over the h1 "My name is", the text of the other h1 "Paul" should change to white.</p>
<p>Any solutions for this issue? Thanks in advance!</p>
<p>Update:
I want the text "Not a" and "but here for them." to become white when the user hovers over the word restaurant and the word "restaurant" should become red. The second part (that "restaurant" becomes red) works fine, but the first part doesn`t work</p>
<p>This is the code im using:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.headingRestaurant:hover textb {
color: blue;
}
.headingRestaurant:hover {
color: red;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><h1 class="textb">Not a <span id="heading1" class="headingRestaurant">restaurant</span>, <br> but here for them.</h1></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74207752,
"author": "Adam",
"author_id": 12571484,
"author_profile": "https://Stackoverflow.com/users/12571484",
"pm_score": 3,
"selected": false,
"text": ".texta:hover + .textb {\n color:red;\n}"
},
{
"answer_id": 74207933,
"author": "Haseeb Javed",
"auth... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20332178/"
] |
74,207,686 | <p>I have an NumPy array of good animals, and a DataFrame of people with a list of animals they own.</p>
<pre><code>good_animals = np.array(['Owl', 'Dragon', 'Shark', 'Cat', 'Unicorn', 'Penguin'])
data = {
> 'People': [1, 2, 3, 4, 5],
> 'Animals': [['Owl'], ['Owl', 'Dragon'], ['Dog', 'Human'], ['Unicorn', 'Pitbull'], []],
> }
df = pd.DataFrame(data)
</code></pre>
<p>I want to add another column to my DataFrame, showing all the good animals that person owns.</p>
<p>The following gives me a Series showing whether or not each animal is a good animal.</p>
<pre><code>df['Animals'].apply(lambda x: np.isin(x, good_animals))
</code></pre>
<p>But I want to see the actual good animals, not just booleans.</p>
| [
{
"answer_id": 74207842,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": true,
"text": "intersection"
},
{
"answer_id": 74208574,
"author": "Picard",
"author_id": 20339387,
"author_prof... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339243/"
] |
74,207,691 | <p>In my ReactJS frontend I am building a form where the user can view and edit settings. The form is part of a function that does the following:</p>
<ul>
<li>Call the backend to get the settigs. Store the result from backend in variable <code>data</code></li>
<li>Map/show the <code>data</code> in text fields</li>
<li>When the user clicks "Submit" then send changes as json back to the backend.</li>
</ul>
<p><strong>This is a picture of the flow:</strong></p>
<p><a href="https://i.stack.imgur.com/7i7fb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7i7fb.png" alt="enter image description here" /></a></p>
<p><strong>This is a picture of the ReactApp:</strong></p>
<p><a href="https://i.stack.imgur.com/GidmP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GidmP.png" alt="enter image description here" /></a></p>
<p><strong>This is my code so far:</strong></p>
<pre><code>import { useContext, useEffect, useState } from "react";
export function Settings() {
const [data, setData] = useState([]);
// Send general settings
const handleSubmit = async (e) => {
e.preventDefault();
let result = await fetch("https://localhost:5002/api/update_settings", {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: data,
});
let resultJson = await result.json();
let resultMessage = resultJson['message']
let resulData = resultJson['data']
let resultError = resultJson['error']
if (result.status === 200 || result.status === 201) {
document.getElementById("feedback_div").style.display = "block";
document.getElementById("feedback_p").innerHTML = resultMessage;
}
else{
document.getElementById("feedback_div").style.display = "block";
document.getElementById("feedback_p").innerHTML = resultError + " " + resultMessage;
}
};
useEffect(() => {
fetch('https://localhost:5002/api/get_settings')
.then(response => response.json())
.then(json => setData(json))
}, []);
return (
<div>
<h1>Settings</h1>
{/* Feedback */}
<div id="feedback_div" style={{display: "none"}}><p id='feedback_p'>Feedback box is here</p></div>
{/* Form */}
<form onSubmit={handleSubmit}>
<label>
<p>Title</p>
<input type="text" name="inp_title" value={data?.settings_website_title} onChange={(e) => setData(e.target.value)} />
</label>
<label>
<p>Title short</p>
<input type="text" name="inp_title_short" value={data?.settings_website_title_short} onChange={(e) => setData(e.target.value)} />
</label>
<p><button>Submit</button></p>
</form>
</div>
);
}
export default Settings;
</code></pre>
<p><strong>Backend get_settings return value:</strong></p>
<pre><code> {
"settings_website_title", "My Website",
"settings_website_title_short", "MyWeb"
}
</code></pre>
<p><strong>My problems:</strong></p>
<p>How can I send the data back to the backend? I belive that when the user makes changes into the text box I call <code>onChange={(e) => setData(e.target.value)}</code> but I do not think this is correct? Because <code>data</code> should be the JSON, and not a single value.</p>
<p>Also I get this error on this code:</p>
<blockquote>
<p>Warning: A component is changing an uncontrolled input to be
controlled. This is likely caused by the value changing from undefined
to a defined value, which should not happen. Decide between using a
controlled or uncontrolled input element for the lifetime of the
component. More info: <a href="https://reactjs.org/link/controlled-components" rel="nofollow noreferrer">https://reactjs.org/link/controlled-components</a></p>
</blockquote>
| [
{
"answer_id": 74207818,
"author": "David",
"author_id": 328193,
"author_profile": "https://Stackoverflow.com/users/328193",
"pm_score": 2,
"selected": true,
"text": "<input\n type=\"text\"\n name=\"inp_title\"\n value={data?.settings_website_title}\n onChange={(e) => setData({ ...da... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9827719/"
] |
74,207,720 | <p>My index is loading well on browser, but when I click home page, there is nothing 404 error, is responding static/index.html, (when I click home page or any other such as contact, it is searching for html in static) why is it asking for index.html in static files and how can I rectify that?[<img src="https://i.stack.imgur.com/b7dXo.png" alt="When i click home there is an error message as on the image " /></p>
<p>I stored my html files on templates folder thinking that when i clicked my dropdown, they were going to apper on my web.</p>
| [
{
"answer_id": 74207818,
"author": "David",
"author_id": 328193,
"author_profile": "https://Stackoverflow.com/users/328193",
"pm_score": 2,
"selected": true,
"text": "<input\n type=\"text\"\n name=\"inp_title\"\n value={data?.settings_website_title}\n onChange={(e) => setData({ ...da... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20334245/"
] |
74,207,728 | <p>I am developing a VSTO project where i want to save some user data using roaming settings
i searched for it and it is applicable only in javascript office.js
Is there any alternative that i can use in my VSTO project?</p>
<pre><code>using Outlook = Microsoft.Office.Interop.Outlook;
</code></pre>
| [
{
"answer_id": 74207818,
"author": "David",
"author_id": 328193,
"author_profile": "https://Stackoverflow.com/users/328193",
"pm_score": 2,
"selected": true,
"text": "<input\n type=\"text\"\n name=\"inp_title\"\n value={data?.settings_website_title}\n onChange={(e) => setData({ ...da... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428318/"
] |
74,207,802 | <p>I have a report, unconfirmed by me but from a reliable source, that the code</p>
<pre><code>qsort(a, n, sizeof *a, cmpfunc);
</code></pre>
<p>is compiled by a modern version of gcc <em>as if</em> it had been written</p>
<pre><code>if(n == 0)
__builtin_trap();
qsort(a, n, sizeof *a, cmpfunc);
</code></pre>
<p>Evidently it is believed that calling <code>qsort</code> with <code>n == 0</code> is undefined behavior.</p>
<p><em>[Edit: The whole premise here was found to be false; see "Update 2" below.]</em></p>
<p>It has been pointed out that Posix explicitly blesses the <code>n == 0</code> case, <s>but evidently no extant version of the C Standard does</s>.</p>
<p>So the obvious questions are:</p>
<ol>
<li>Is calling <code>qsort</code> with <code>n = 0</code> actually undefined behavior in C?</li>
<li>Is every program which ever calls <code>qsort</code> with arbitrary <code>n</code> truly obliged to check for <code>n == 0</code> and not call <code>qsort</code> in that case?</li>
<li>Why would gcc perform this "optimization"? Even if you believe that calling <code>qsort</code> with <code>n == 0</code> is undefined, this would seem to marginally slow down every <em>non</em> undefined program.</li>
</ol>
<p>Textbook implementations of quicksort (which, I know, <code>qsort</code> is not required to be) pretty much can't not handle <code>n = 0</code> correctly. I wonder if gcc's behavior here is trying to guard against a <code>qsort</code> implementation that somehow does something much worse than a <code>__builtin_trap</code> if the initial call has <code>n == 0</code>?</p>
<hr />
<p>Update: Thanks for the responses so far. <s>It sounds like gcc is in the wrong here.</s> As I said, I haven't confirmed <a href="https://mm.icann.org/pipermail/tz/2022-October/032096.html" rel="nofollow noreferrer">this result</a> myself, but I'm <a href="https://mm.icann.org/pipermail/tz/2022-October/032097.html" rel="nofollow noreferrer">trying to find out</a> which version of gcc and with which optimization flags the issue was observed.</p>
<hr />
<p>Update 2: The original report I referred to was <a href="https://mm.icann.org/pipermail/tz/2022-October/032107.html" rel="nofollow noreferrer">in error</a>. Two key clarifications:</p>
<ol>
<li>gcc was in fact checking for <code>a == 0</code>, <em>not</em> <code>n == 0</code>. This is obviously a completely different kettle of fish: As this thread (and others) has confirmed, calling <code>qsort</code> on a null pointer is considerably more problematic, and almost certainly formally undefined.</li>
<li>The compilation in question included the <code>-fsanitize=undefined</code> and <code>-fsanitize-undefined-trap-on-error</code> flags, so <em>of course</em> gcc was being stringent about checking for inadvertent null pointers (and even at a cost to efficiency).</li>
</ol>
<p>Sorry for the misinformation and runaround. I'm afraid this question is now in the realm of "not reproducible or was caused by a typo", and I have put one close vote in the hopper on that basis.</p>
<p>For what it's worth, the gcc version was 12.2.1.</p>
| [
{
"answer_id": 74208234,
"author": "Jean-Baptiste Yunès",
"author_id": 719263,
"author_profile": "https://Stackoverflow.com/users/719263",
"pm_score": 2,
"selected": false,
"text": "qsort()"
},
{
"answer_id": 74208258,
"author": "Lundin",
"author_id": 584518,
"author_... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3923896/"
] |
74,207,808 | <p>So I have a selection of text files all of which are on one line
I need a way to seperate the line into multiple lines after every number.</p>
<p>At the minute I have something like this</p>
<pre><code>a 111111b 222c 3d 444444
</code></pre>
<p>and I need a way to get it to this</p>
<pre><code>a 11111
b 222
c 3
d 444444
</code></pre>
<p>I have been trying to create a gawk with regex but I'm not aware of a way to get this to work. (I am fairly new to shell)</p>
| [
{
"answer_id": 74208234,
"author": "Jean-Baptiste Yunès",
"author_id": 719263,
"author_profile": "https://Stackoverflow.com/users/719263",
"pm_score": 2,
"selected": false,
"text": "qsort()"
},
{
"answer_id": 74208258,
"author": "Lundin",
"author_id": 584518,
"author_... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10101692/"
] |
74,207,835 | <p>I need to grab the browse image upload url and apply it as a background cover to a div, and this is what I've tried but i don't get the background image:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$("#top_img").css("background-image", e.target.result);
$("#top_img").css("background-size", "cover");
}
reader.readAsDataURL(input.files[0]);
}
}
$("#upload").change(function() {
readURL(this);
});</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="upload" class="form-control" type="file" id="formFile">
<div id="top_img" style="height: 484px; width: 1080px; position: relative; top:0; left: 0;"></div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74207949,
"author": "GalAbra",
"author_id": 3103891,
"author_profile": "https://Stackoverflow.com/users/3103891",
"pm_score": 1,
"selected": false,
"text": "url()"
},
{
"answer_id": 74207957,
"author": "Carsten Løvbo Andersen",
"author_id": 2943218,
"au... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1018804/"
] |
74,207,857 | <p>sorry if this is a noob question, I wasn't able to find a solution online (maybe I just don't know what to search for).</p>
<p>How do I return the "found" dictionary from this recursive function
(I am only able to return the nth number)</p>
<p>Note: simply returning found at the end does not work for multiple reasons</p>
<pre><code># Nth Fibonacci number generator
def nth_Rfib(n, found = {0:1, 1:1}):
if n in found:
return found[n]
else:
found[n] = nth_Rfib(n-1, found) + nth_Rfib(n-2, found)
#print(found)
return found[n] # return found ** Doesn't Work **
print(nth_Rfib(5)) # 8
# instead, it should return: {0: 1, 1: 1, 2: 2, 3: 3, 4: 5, 5: 8}
</code></pre>
<p>Thank you.</p>
| [
{
"answer_id": 74207914,
"author": "Yevhen Kuzmovych",
"author_id": 4727702,
"author_profile": "https://Stackoverflow.com/users/4727702",
"pm_score": 3,
"selected": true,
"text": "found"
},
{
"answer_id": 74208720,
"author": "Stef",
"author_id": 3080723,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18208667/"
] |
74,207,872 | <p>I need to align numbers right for any input. However I can't seem to do it only for a specific input not for any input. I've also tried turning the list of strings into a list of nums using <code>list comprehension</code> and then do <code>print("{:5d}".format(i))</code>. I've also tried doing something like <code>print("{:>len(i)}".format(i))</code></p>
<pre><code>n = input().split()
m = sorted(n, key =int, reverse = True)
for i in m:
print("{:>10}".format(i))
</code></pre>
<p>Sample Input:</p>
<pre><code>8 11 12 123 45678
</code></pre>
<p>Sample Output:</p>
<pre><code>45678
123
12
11
8
</code></pre>
<p>I've managed to do it for the input above, but not for any input.</p>
| [
{
"answer_id": 74207914,
"author": "Yevhen Kuzmovych",
"author_id": 4727702,
"author_profile": "https://Stackoverflow.com/users/4727702",
"pm_score": 3,
"selected": true,
"text": "found"
},
{
"answer_id": 74208720,
"author": "Stef",
"author_id": 3080723,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20243451/"
] |
74,207,889 | <p>In a KendoUI grid with a selection set to "multiple", how do I invert a current selection?</p>
| [
{
"answer_id": 74207890,
"author": "mortenma71",
"author_id": 608397,
"author_profile": "https://Stackoverflow.com/users/608397",
"pm_score": 0,
"selected": false,
"text": "var $grid = $(\"#grid\").data(\"kendoGrid\");\nvar $selectedRows = $grid.select();\n$grid.refresh(); // clear exist... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/608397/"
] |
74,207,922 | <p>I'm trying to intersect <code>array1</code> and <code>array2</code> and find the elements that contain the same <code>name</code>.</p>
<p>Then on <code>array3</code> I only want to keep the elements that exist on the first intersection by <code>name</code>.</p>
<p>I'm stuck here, I just get true and falses. Any help?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const array1 = [{
name: 'John'
}];
const array2 = [{
name: 'Elisa'
}, {
name: 'John'
}];
const array3 = [{
name: 'Elisa',
age: 10
}, {
name: 'John',
age: 23
}, {
name: 'Maria',
age: 30
}];
const intersectArray = array1.map(elem1 => array2.map(elem2 => elem1.name === elem2.name));
console.log(intersectArray);
const filteredArray = array3.map(elem3 => intersectArray.map(elem => elem.name === elem3.name));
console.log(filteredArray);</code></pre>
</div>
</div>
</p>
<p>The expected result should be:</p>
<blockquote>
<p>{ name: 'John', age: 23 }</p>
</blockquote>
| [
{
"answer_id": 74207986,
"author": "Rory McCrossan",
"author_id": 519413,
"author_profile": "https://Stackoverflow.com/users/519413",
"pm_score": 0,
"selected": false,
"text": "filter()"
},
{
"answer_id": 74207997,
"author": "Cerbrus",
"author_id": 1835379,
"author_pr... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12046376/"
] |
74,207,924 | <p>I want to show a dialog on my flutter app when the <code>onTap</code> is triggered.</p>
<p>sample of my code:</p>
<pre><code> hintText: "Mot de passe",
prefixIcon: Icon(
Icons.lock,
color: Color(0xfff28800),
),
//hide/show
suffixIcon: InkWell(
onTap: _togglePasswordVew,
child: Icon(Icons.visibility_off, color: Colors.grey,),
)
</code></pre>
<p>I want to test the <code>Icons.visibility_off</code> with a <code>show0Dialog</code> message</p>
| [
{
"answer_id": 74209402,
"author": "Muhammad Qazmouz",
"author_id": 19122402,
"author_profile": "https://Stackoverflow.com/users/19122402",
"pm_score": 0,
"selected": false,
"text": "openDialog(){\n Get.defaultDialog(\n title: 'Some message',\n actions: [\n Row(\n ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20183851/"
] |
74,207,943 | <p><a href="https://i.stack.imgur.com/6FvFy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6FvFy.png" alt="enter image description here" /></a></p>
<p>I am trying to time scale the custom cost fields "labor" and "material" so I can view how these data are distributed over a given time horizon.</p>
<pre><code>Sub MSCostOutlay()
'This macro will copy timescaled variance data into the Baseline9Cost field.
Dim TSVBaselineCost As TimeScaleValue 'Capture the dataset for the Baseline10Cost
Dim TSVSBaselineCost As TimeScaleValues
Dim t As Task
' ActiveProject.StatusDate = InputBox("Enter the Status Date.", "Status Date", ActiveProject.StatusDate)
For Each t In ActiveProject.Tasks
Set TSVSBaselineCost = t.TimeScaleData((ActiveProject.StatusDate), ActiveProject.StatusDate, pjTaskTimescaledBaseline9Cost, pjTimescaleMonths, 1)
For Each TSVBaselineCost In TSVSBaselineCost
TSVBaselineCost = t.Cost4
Next TSVBaselineCost
t.Baseline9Cost = t.Baseline9Cost + 1
Next t
End Sub
</code></pre>
<p>Above is the code I tried to use to store the labor cost in a time scaled array. I tried testing this script on one day worth of data to cut down on processing time. Regardless, I kept getting a run-time error of 1101 with no success.</p>
| [
{
"answer_id": 74209402,
"author": "Muhammad Qazmouz",
"author_id": 19122402,
"author_profile": "https://Stackoverflow.com/users/19122402",
"pm_score": 0,
"selected": false,
"text": "openDialog(){\n Get.defaultDialog(\n title: 'Some message',\n actions: [\n Row(\n ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20334639/"
] |
74,207,947 | <p>I'm building this frontend and am using cards to display some data, four of them in total. So I searched for someone's HTML card codepen and found one to use. But now I need to change the CSS to have the cards stacked instead of in a row. Can someone help me edit this code snippet?</p>
<p>It looks like this right now:</p>
<p><a href="https://i.stack.imgur.com/baWhE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/baWhE.png" alt="enter image description here" /></a></p>
<p>But I want the last two stacked on top of the first two.</p>
<p>The codepen is:</p>
<p><a href="https://codepen.io/eduarde/pen/MWwvbjL" rel="nofollow noreferrer">CodePen</a>
<a href="https://codepen.io/eduarde/pen/MWwvbjL" rel="nofollow noreferrer">https://codepen.io/eduarde/pen/MWwvbjL</a></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.c-dashboardInfo {
margin-bottom: 15px;
}
.c-dashboardInfo .wrap {
background: #ffffff;
box-shadow: 2px 10px 20px rgba(0, 0, 0, 0.1);
border-radius: 7px;
text-align: center;
position: relative;
overflow: hidden;
padding: 40px 25px 20px;
height: 100%;
}
.c-dashboardInfo__title,
.c-dashboardInfo__subInfo {
color: #6c6c6c;
font-size: 1.18em;
}
.c-dashboardInfo span {
display: block;
}
.c-dashboardInfo__count {
font-weight: 600;
font-size: 2.5em;
line-height: 64px;
color: #323c43;
}
.c-dashboardInfo .wrap:after {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 10px;
content: "";
}
.c-dashboardInfo:nth-child(1) .wrap:after {
background: linear-gradient(82.59deg, #00c48c 0%, #00a173 100%);
}
.c-dashboardInfo:nth-child(2) .wrap:after {
background: linear-gradient(81.67deg, #0084f4 0%, #1a4da2 100%);
}
.c-dashboardInfo:nth-child(3) .wrap:after {
background: linear-gradient(69.83deg, #0084f4 0%, #00c48c 100%);
}
.c-dashboardInfo:nth-child(4) .wrap:after {
background: linear-gradient(81.67deg, #ff647c 0%, #1f5dc5 100%);
}
.c-dashboardInfo__title svg {
color: #d7d7d7;
margin-left: 5px;
}
.MuiSvgIcon-root-19 {
fill: currentColor;
width: 1em;
height: 1em;
display: inline-block;
font-size: 24px;
transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
user-select: none;
flex-shrink: 0;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="container pt-5">
<div class="row align-items-stretch">
<div class="c-dashboardInfo col-lg-3 col-md-6">
<div class="wrap">
<h4 class="heading heading5 hind-font medium-font-weight c-dashboardInfo__title">Portfolio Balance<svg
class="MuiSvgIcon-root-19" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation">
<path fill="none" d="M0 0h24v24H0z"></path>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z">
</path>
</svg></h4><span class="hind-font caption-12 c-dashboardInfo__count">€10,500</span>
</div>
</div>
<div class="c-dashboardInfo col-lg-3 col-md-6">
<div class="wrap">
<h4 class="heading heading5 hind-font medium-font-weight c-dashboardInfo__title">Rental income<svg
class="MuiSvgIcon-root-19" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation">
<path fill="none" d="M0 0h24v24H0z"></path>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z">
</path>
</svg></h4><span class="hind-font caption-12 c-dashboardInfo__count">€500</span><span
class="hind-font caption-12 c-dashboardInfo__subInfo">Last month: €30</span>
</div>
</div>
<div class="c-dashboardInfo col-lg-3 col-md-6">
<div class="wrap">
<h4 class="heading heading5 hind-font medium-font-weight c-dashboardInfo__title">Available funds<svg
class="MuiSvgIcon-root-19" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation">
<path fill="none" d="M0 0h24v24H0z"></path>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z">
</path>
</svg></h4><span class="hind-font caption-12 c-dashboardInfo__count">€5000</span>
</div>
</div>
<div class="c-dashboardInfo col-lg-3 col-md-6">
<div class="wrap">
<h4 class="heading heading5 hind-font medium-font-weight c-dashboardInfo__title">Rental return<svg
class="MuiSvgIcon-root-19" focusable="false" viewBox="0 0 24 24" aria-hidden="true" role="presentation">
<path fill="none" d="M0 0h24v24H0z"></path>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z">
</path>
</svg></h4><span class="hind-font caption-12 c-dashboardInfo__count">6,40%</span>
</div>
</div>
</div>
</div>
</body></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74209402,
"author": "Muhammad Qazmouz",
"author_id": 19122402,
"author_profile": "https://Stackoverflow.com/users/19122402",
"pm_score": 0,
"selected": false,
"text": "openDialog(){\n Get.defaultDialog(\n title: 'Some message',\n actions: [\n Row(\n ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19966841/"
] |
74,207,961 | <p>I'm observing some unexpected floating point behaviour in Elixir.</p>
<pre><code>4.7 / 0.1 = 47.0 (good!)
4.8 / 0.1 = 47.9999999999 (bad!)
4.9 / 0.1 = 49 (good!)
</code></pre>
<p>While I understand the limitations of fp accuracy, in this case, the answer just looks wrong.</p>
<p>Curiously, I tried this in python as well, and got the same result, which is even more mysterious. When I changed the format to <code>4.8 * (1/0.1)</code>, I get the right answer (48.0).</p>
<p>What is going on here?</p>
| [
{
"answer_id": 74208967,
"author": "Adam Millerchip",
"author_id": 1225617,
"author_profile": "https://Stackoverflow.com/users/1225617",
"pm_score": 0,
"selected": false,
"text": "iex(2)> Decimal.div(Decimal.new(\"4.8\"), Decimal.new(\"0.1\"))\n#Decimal<48>\niex(3)> Decimal.mult(Decimal.... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/222151/"
] |
74,207,964 | <p>Hi I've the following file.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="" xmlns:uap="" IgnorableNamespaces="">
<Identity Name="xxxxxxxxxx" Publisher="CN=$username$" Version="xxxx"/>
<mp:PhoneIdentity PhoneProductId="xxxxxxxxxxx" PhonePublisherId=""/>
<Properties>
<DisplayName>xxxxxxxxxx</DisplayName>
<PublisherDisplayName>xxxxxxxx</PublisherDisplayName>
<Logo>images\StoreLogo.png</Logo>
<Description>A sample Apache Cordova application that responds to the deviceready event.</Description>
</Properties>
<Dependencies>
<TargetDeviceFamily MaxVersionTested="" MinVersion="" Name="Windows.Universal"/>
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="" StartPage="">
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient"/>
<DeviceCapability Name="webcam"/>
<DeviceCapability Name="location"/>
</Capabilities>
</Package>
</code></pre>
<p>I wanted to insert under the Capabilities element. So, the output should look like</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="" xmlns:uap="" IgnorableNamespaces="">
<Identity Name="xxxxxxxxxx" Publisher="CN=$username$" Version="xxxx"/>
<mp:PhoneIdentity PhoneProductId="xxxxxxxxxxx" PhonePublisherId=""/>
<Properties>
<DisplayName>xxxxxxxxxx</DisplayName>
<PublisherDisplayName>xxxxxxxx</PublisherDisplayName>
<Logo>images\StoreLogo.png</Logo>
<Description>A sample Apache Cordova application that responds to the deviceready event.</Description>
</Properties>
<Dependencies>
<TargetDeviceFamily MaxVersionTested="" MinVersion="" Name="Windows.Universal"/>
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="" StartPage="">
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient"/>
<Capability Name="privateNetworkClientServer"/>
<DeviceCapability Name="webcam"/>
<DeviceCapability Name="location"/>
</Capabilities>
</Package>
</code></pre>
<p>To achieve the above I'm using XMLStarlet as below.</p>
<pre><code>xmlstarlet ed \
-a '/Package/Capabilities' -t elem -n Capability \
-i '/Package/Capabilities/Capability' -t attr -n Name -v privateNetworkClientServer \
<inputfile >outputfile
</code></pre>
<p>The output I'm getting is the same without any modifications. Am I doing anything silly.</p>
| [
{
"answer_id": 74208967,
"author": "Adam Millerchip",
"author_id": 1225617,
"author_profile": "https://Stackoverflow.com/users/1225617",
"pm_score": 0,
"selected": false,
"text": "iex(2)> Decimal.div(Decimal.new(\"4.8\"), Decimal.new(\"0.1\"))\n#Decimal<48>\niex(3)> Decimal.mult(Decimal.... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18772149/"
] |
74,207,977 | <p>Here's my problem. Let's say I have a JSON structure that I'm reading using Swift's <code>Codable</code> API. What I want to do is not decode part of the JSON but read it as a string even though it's valid JSON.</p>
<p>In a playground I'm messing about with this code:</p>
<pre class="lang-swift prettyprint-override"><code>
import Foundation
let json = #"""
{
"abc": 123,
"def": {
"xyz": "hello world!"
}
}
"""#
struct X: Decodable {
let abc: Int
let def: String
enum CodingKeys: String, CodingKey {
case abc
case def
}
init(decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
abc = try container.decode(Int.self, forKey: .abc)
var defContainer = try container.nestedUnkeyedContainer(forKey: .def)
def = try defContainer.decode(String.self)
// def = try container.decode(String.self, forKey: .def)
}
}
let x = try JSONDecoder().decode(X.self, from: json.data(using: .utf8)!)
</code></pre>
<p>Essentially I'm trying to read the <code>def</code> structure as a string instead of a dictionary.</p>
<p>Any clues?</p>
| [
{
"answer_id": 74209084,
"author": "Caleb",
"author_id": 643383,
"author_profile": "https://Stackoverflow.com/users/643383",
"pm_score": 2,
"selected": false,
"text": "Scanner"
},
{
"answer_id": 74209499,
"author": "Rob Napier",
"author_id": 97337,
"author_profile": "... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/247090/"
] |
74,207,980 | <p><strong>My input is:</strong></p>
<pre><code>a = {
"name": "a",
"address": {
"state": "b",
"full": {
"city": "c"
}
}
}
</code></pre>
<p><strong>my expected output is:</strong></p>
<pre><code>{
"name": "a",
"address.state": "b",
"address.full.city": "c"
}
</code></pre>
<p>I have try many time but its very difficult.</p>
| [
{
"answer_id": 74208073,
"author": "R. Baraiya",
"author_id": 13888486,
"author_profile": "https://Stackoverflow.com/users/13888486",
"pm_score": 1,
"selected": false,
"text": "import pandas as pd\nlist(pd.json_normalize(YourDict).T.to_dict().values())[0]\n"
},
{
"answer_id": 742... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74207980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19807705/"
] |
74,208,033 | <p>I want to rank the number i added up from first to third but i cant think of a way to rank it properly since when there is a duplicate it will only show the number once and continues to the second highest</p>
<p>im new to the language and it would be great for someone to help me on this</p>
<p>Edit: Sorry i think there is a misunderstanding here my sums are in an array that is connected to the names in another array and im trying to sort it out with the same index value</p>
<p>Edit 2: Also i am stuck at c# 7.3 so i cant use some of the new codes</p>
<pre><code>int first = Int32.MinValue;
int fs, nd, thr;
int temp = 0;
for (fs = 0; fs < hounds; fs++)
{
if (score_SUM[fs] > first)
{
first = score_SUM[fs];
temp = fs;
}
}
Console.WriteLine("\n" + "First:{1} {0}", first, houndname[temp]);
int second = Int32.MinValue;
for (nd = 0; nd < hounds; nd++)
{
if (score_SUM[nd] > second && score_SUM[nd] < first)
{
second = score_SUM[nd];
temp = nd;
}
}
Console.WriteLine("Second:{1} {0}", second, houndname[temp]);
int third = Int32.MinValue;
for (thr = 0; thr < hounds; thr++)
{
if (score_SUM[thr] > third && score_SUM[thr] < second)
{
third = score_SUM[thr];
temp = thr;
}
}
Console.WriteLine("Third:{1} {0}", third, houndname[temp]);
Console.ReadLine();
</code></pre>
<p>example</p>
<p>10 , 5 , 10 , 6, 1</p>
<p>The output will be like</p>
<p>10
6
5</p>
<p>But I expected</p>
<p>10
10
6</p>
<p>but i cant find a way to write a block a code for that</p>
| [
{
"answer_id": 74208096,
"author": "frankM_DN",
"author_id": 20034020,
"author_profile": "https://Stackoverflow.com/users/20034020",
"pm_score": 0,
"selected": false,
"text": "<"
},
{
"answer_id": 74208148,
"author": "Chris",
"author_id": 13280555,
"author_profile": "... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339512/"
] |
74,208,041 | <p>Is it possible to <code>infer</code> a parameter of an overload function?</p>
<p>For instance:</p>
<pre class="lang-js prettyprint-override"><code>type MyFunction = {
(key: "one", params: { first: string }): void;
(key: "two", params: { second: string }): void;
}
type MyFunctionParams<T extends string> = MyFunction extends (
key: T,
params: infer P,
) => void
? P
: never;
// should be `{ first: string }`
type OneParams = MyFunctionParams<"one"> // never
</code></pre>
<p><a href="https://www.typescriptlang.org/play?#code/C4TwDgpgBAsiBiBXAdgY2ASwPbKgXigG8AoKKACgGsIQAuKAIhwgYBoowBDAJ04FsAzvUJQAZhm4Dg9KdwzIA5lAC+ASnoA3LBgAmAblIVqdRsADuWNhx78hRKAIiocOmcDmKV6qFt0HlxMSgkLAIKOjYyAAKNoIAPAAqUBAAHsAQyDoCDu7yCgB8+KFIaJg4yWkZWRSGxvQJrIZcvIL08qIQ3FBRjar4hb46hgD83Yb0yBAanQbEAPRzDgAWWIgANjpQAEbQAAYi4pLSOR5KyrtB4NAA8pMxLdkEcCUROPe2cUyTDIULUJPTbhAA" rel="nofollow noreferrer">Typescript playground</a></p>
| [
{
"answer_id": 74209026,
"author": "T.J. Crowder",
"author_id": 157247,
"author_profile": "https://Stackoverflow.com/users/157247",
"pm_score": 3,
"selected": true,
"text": "MyFunction"
},
{
"answer_id": 74209253,
"author": "caTS",
"author_id": 18244921,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8990411/"
] |
74,208,047 | <p>I have data as following</p>
<pre><code>STORE_NO STORE_ADDRESS STORE_TYPE STORE_OWNER STORE_HOURS
1 123 Drive Thru Harpo 24hrs
1 123 Curbside Harpo 24hrs
1 123 Counter Harpo 24hrs
2 456 Drive Thru Groucho 9 to 9
2 456 Counter Groucho 9 to 9
</code></pre>
<p>And I want to pivot it as following.</p>
<pre><code>STORE_NO STORE_ADDRESS Drive Thru Curbside Counter STORE_OWNER STORE_HOURS
1 123 TRUE TRUE TRUE Harpo 24hrs
2 456 TRUE FALSE TRUE Groucho 9 to 9
</code></pre>
<p>Here is what I have</p>
<pre><code>select *
from stores
pivot(count(STORE_TYPE) for STORE_TYPE in ('Drive Thru', 'Curbside', 'Counter'))
as store_flattened;
</code></pre>
<p>But this returns a 1 or a 0. How do I convert to TRUE / FALSE without making this a CTE?</p>
| [
{
"answer_id": 74209026,
"author": "T.J. Crowder",
"author_id": 157247,
"author_profile": "https://Stackoverflow.com/users/157247",
"pm_score": 3,
"selected": true,
"text": "MyFunction"
},
{
"answer_id": 74209253,
"author": "caTS",
"author_id": 18244921,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/420558/"
] |
74,208,052 | <p>I have a dataset with two columns called car data. I want to subtract the values in the both columns and then return the different values for average_distance using bootstrap. but my current code only return just one value multiple times.</p>
<p>I want Average_distance to be: 0.05, 0.7, 0.6, 0.9. 0.10 etc with the different values but i am getting Average_distance 0.99, 0.99,0.99, 0.99, 0.99.0.99 etc</p>
<pre><code>average_distance <- c()
Bootss <- 10
total <- 5000
for (i in seq(Bootss)){
car_diff <- car_data[,1] - car_data[,2]
cars <- subset(car_diff, car_diff > 0)
for (i in 1:length(seq(Bootss))){
average_distance[i] <- length(cars)/length(total)
}
}
</code></pre>
| [
{
"answer_id": 74209026,
"author": "T.J. Crowder",
"author_id": 157247,
"author_profile": "https://Stackoverflow.com/users/157247",
"pm_score": 3,
"selected": true,
"text": "MyFunction"
},
{
"answer_id": 74209253,
"author": "caTS",
"author_id": 18244921,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12216066/"
] |
74,208,066 | <p>I'm basically writing a clean up program to make it more straight forward to access data. Anywho, I ran into possibly a nomenclature error. I want to use the "current" cell in a "for" loop to delete that row and the next 3 rows. Code looks something like this:</p>
<pre><code>For Each SingleCell In SingleSheet1.Range("a1:a40")
If SingleCell.Value = "S" Or SingleCell.Value = "B" Then
Range(SingleCell.Range, SingleCell.Range.Offset(4, 0)).EntireRow.Delete Shift:=xlUp
Else
End If
Next
</code></pre>
<p>I tried to define the range to delete as specified in the code but it gave me a runtime error</p>
| [
{
"answer_id": 74209026,
"author": "T.J. Crowder",
"author_id": 157247,
"author_profile": "https://Stackoverflow.com/users/157247",
"pm_score": 3,
"selected": true,
"text": "MyFunction"
},
{
"answer_id": 74209253,
"author": "caTS",
"author_id": 18244921,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20265106/"
] |
74,208,154 | <p>I am fairly new to programming in Maui. Previously, I wrote android applications in Xamarin. I have question. How to transfer variables between two Content Page. I try this way:</p>
<p>I have two content page, MainPage and SettingsPage. This is how I send data to SettingsPage:</p>
<pre><code>public async void goToSettingsPage_button_Clicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new DetailsPage(language));
}
</code></pre>
<p>And this is how I perceive them:</p>
<pre><code>public partial class SettingsPage : ContentPage
{
public SettingsPage(string language)
{
InitializeComponent();
String Language = language;
}
}
</code></pre>
<p>I just used Intent on xamarin. PutExtra or Intent.GetExtra. I don't know how to work in Maui. How to pass a variable back from SettingsPage to MainPage. I tried to do it in the same way as above;</p>
| [
{
"answer_id": 74210166,
"author": "FreakyAli",
"author_id": 7462031,
"author_profile": "https://Stackoverflow.com/users/7462031",
"pm_score": 1,
"selected": false,
"text": " Contact contact = new Contact\n{\n Name = \"Jane Doe\",\n Age = 30,\n Occupation = \"Developer\",\n ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7782424/"
] |
74,208,167 | <p>Iam having a code problem, that i couldn't find the solution yet, and already lost many hours reading articles and posts.
Iam getting a "ERROR: Syntax error, expecting one of the following: ',', :, FROM, NOTRIM." on my SEPARATED BY... after my ranged var col1-.
Side note, this proc are inside a macro.</p>
<pre><code>proc sql noprint;
select libname, memname, name
into: lib1-, tab1-, col1- SEPARATED BY ","
from dictionary.columns
where upcase(libname)='LIB_X'
quit;
</code></pre>
<p>I know that if i just have it alone in my INTO statment it works fine, but when i add the libname and memname it just crash.
The final ideia was getting 3 ranged vars, one with the libname, other with table, and the final one with all column names separated with ","
Further on i will use this to calculate md5 over each (table/row).</p>
| [
{
"answer_id": 74208506,
"author": "Negdo",
"author_id": 19646183,
"author_profile": "https://Stackoverflow.com/users/19646183",
"pm_score": 2,
"selected": false,
"text": "proc sql noprint;\n select libname, memname, name\n into :lib1-, :tab1-, :col1- \n from dictionary.columns\nquit;... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20294371/"
] |
74,208,175 | <p>I have a string representing seconds since epoch, and I need to convert it to a human readable string. I've seen a few posts online that suggest simply casting an integer to <code>time_t</code> as so:</p>
<pre><code>time_t time = (time_t)(atoi(secs_since_epoch_str));
</code></pre>
<p>But, if I look up the definition of time_t:</p>
<pre><code>typedef /* unspecified */ time_t;
Although not defined by the C standard, this is almost always an integral
value holding the number of seconds (not counting leap seconds) since 00:00,
Jan 1 1970 UTC, corresponding to POSIX time.
</code></pre>
<p>So, this is not guaranteed to work. I'm wondering if there's a proper way of doing this?</p>
| [
{
"answer_id": 74237930,
"author": "Luis Colorado",
"author_id": 3899431,
"author_profile": "https://Stackoverflow.com/users/3899431",
"pm_score": 0,
"selected": false,
"text": "time_t"
},
{
"answer_id": 74413214,
"author": "chux - Reinstate Monica",
"author_id": 2410359,... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8710344/"
] |
74,208,191 | <p>I am trying to identify sum of quantity for each group if date ranges are overlapping. I am using postgresql to solve for it.
For example</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>group</th>
<th>start_date</th>
<th>end_date</th>
<th>quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>a</td>
<td>2020-09-11</td>
<td>2020-10-09</td>
<td>50</td>
</tr>
<tr>
<td>1</td>
<td>a</td>
<td>2020-09-11</td>
<td>2020-10-31</td>
<td>20</td>
</tr>
<tr>
<td>1</td>
<td>a</td>
<td>2020-11-01</td>
<td>2020-12-01</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>a</td>
<td>2020-11-15</td>
<td>2020-11-20</td>
<td>6</td>
</tr>
<tr>
<td>2</td>
<td>b</td>
<td>2020-10-06</td>
<td>2020-10-30</td>
<td>10</td>
</tr>
<tr>
<td>2</td>
<td>b</td>
<td>2020-10-09</td>
<td>2022-10-17</td>
<td>5</td>
</tr>
<tr>
<td>2</td>
<td>b</td>
<td>2020-10-15</td>
<td>2022-10-26</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
<p>What I am trying to achieve is the following: <br>
Expected Output: "edited"</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>group</th>
<th>start_date</th>
<th>end_date</th>
<th>quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>a</td>
<td>2020-09-11</td>
<td>2020-10-31</td>
<td>70</td>
</tr>
<tr>
<td>1</td>
<td>a</td>
<td>2020-11-01</td>
<td>2020-12-01</td>
<td>13</td>
</tr>
<tr>
<td>2</td>
<td>b</td>
<td>2020-10-06</td>
<td>2020-10-30</td>
<td>18</td>
</tr>
</tbody>
</table>
</div>
<p>would appreciate your help!</p>
| [
{
"answer_id": 74208507,
"author": "Edouard",
"author_id": 8060017,
"author_profile": "https://Stackoverflow.com/users/8060017",
"pm_score": 2,
"selected": false,
"text": "SELECT id\n , group\n , min(start_date) AS start_date\n , max(end_date) AS end_date\n , Sum(quantity... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9554771/"
] |
74,208,216 | <p>Can someone help me with this error of matplotlib?
I'm using jupyter for some data science project from a famous book (hands-on machine learning...) but I have a problem with an unusual error.</p>
<p>This is the code:</p>
<pre><code>%matplotlib inline
import matplotlib.pyplot as plt
housing.plot(kind="scatter", x="longitude", y="latitude", alpha=0.4,
s=housing["population"]/100, label="population", figsize=(10,7),
c="median_house_value", cmap=plt.get_cmap("jet"), colorbar=True,
sharex=False)
plt.legend()
save_fig("housing_prices_scatterplot")
</code></pre>
<p>And this is the error:</p>
<pre><code>TypeError Traceback (most recent call last)
Cell In [85], line 3
1 get_ipython().run_line_magic('matplotlib', 'inline')
2 import matplotlib.pyplot as plt
----> 3 housing.plot(kind="scatter", x="longitude", y="latitude", alpha=0.4,
4 s=housing["population"]/100, label="population", figsize=(10,7),
5 c="median_house_value", cmap=plt.get_cmap("jet"), colorbar=True,
6 sharex=False)
7 plt.legend()
8 save_fig("housing_prices_scatterplot")
File ~/my_env/lib/python3.9/site-packages/pandas/plotting/_core.py:945, in PlotAccessor.__call__(self, *args, **kwargs)
943 if kind in self._dataframe_kinds:
944 if isinstance(data, ABCDataFrame):
--> 945 return plot_backend.plot(data, x=x, y=y, kind=kind, **kwargs)
946 else:
947 raise ValueError(f"plot kind {kind} can only be used for data frames")
File ~/my_env/lib/python3.9/site-packages/pandas/plotting/_matplotlib/__init__.py:71, in plot(data, kind, **kwargs)
69 kwargs["ax"] = getattr(ax, "left_ax", ax)
70 plot_obj = PLOT_CLASSES[kind](data, **kwargs)
---> 71 plot_obj.generate()
72 plot_obj.draw()
73 return plot_obj.result
File ~/my_env/lib/python3.9/site-packages/pandas/plotting/_matplotlib/core.py:452, in MPLPlot.generate(self)
450 self._compute_plot_data()
451 self._setup_subplots()
--> 452 self._make_plot()
453 self._add_table()
454 self._make_legend()
File ~/my_env/lib/python3.9/site-packages/pandas/plotting/_matplotlib/core.py:1225, in ScatterPlot._make_plot(self)
1223 if self.colormap is not None:
1224 if mpl_ge_3_6_0():
-> 1225 cmap = mpl.colormaps[self.colormap]
1226 else:
1227 cmap = self.plt.cm.get_cmap(self.colormap)
File ~/my_env/lib/python3.9/site-packages/matplotlib/cm.py:87, in ColormapRegistry.__getitem__(self, item)
85 def __getitem__(self, item):
86 try:
---> 87 return self._cmaps[item].copy()
88 except KeyError:
89 raise KeyError(f"{item!r} is not a known colormap name") from None
TypeError: unhashable type: 'LinearSegmentedColormap'
</code></pre>
<p>I just want to use matplotlib for a simple and normal graph but I can't find the problem.</p>
| [
{
"answer_id": 74250605,
"author": "chumbaloo",
"author_id": 6294483,
"author_profile": "https://Stackoverflow.com/users/6294483",
"pm_score": 2,
"selected": false,
"text": "cmap=plt.get_cmap(\"jet\")"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17233805/"
] |
74,208,227 | <p>I need to copy a file from local to remote <code>/usr/local/bin</code>. I am already using <code>paramiko</code> for some other copy actions.</p>
<p>I saw some solutions online on how to avoid the permission error:</p>
<ul>
<li><a href="https://www.google.com/search?channel=fs&client=ubuntu&q=sudo+paramiko.put" rel="nofollow noreferrer">https://www.google.com/search?channel=fs&client=ubuntu&q=sudo+paramiko.put</a></li>
<li><a href="https://stackoverflow.com/questions/6270677/how-to-run-sudo-with-paramiko-python">How to run sudo with Paramiko? (Python)</a></li>
<li><a href="https://stackoverflow.com/questions/23144286/paramiko-python-ioerror-errno-13-permission-denied">Paramiko Python: IOError: [Errno 13] Permission denied</a></li>
</ul>
<p>All these solutions:</p>
<blockquote>
<ul>
<li>changing who owns the directory</li>
<li>adding a user to the group of the directory</li>
<li>creating a new group and changing the group on the directory</li>
<li>changing the owner</li>
<li>Changing the r/w permissions of owner,group, or public.</li>
</ul>
</blockquote>
<p>Don't feel right when working with <code>/user/local/bin</code>.</p>
<p>I also have the option to just copy the file to <code>~/file</code> to later on move it using an <code>ansible</code> script (which is executed on the remote anyway), but splitting the copying process feels wrong, too.</p>
<p>Directly logging into <code>sudo</code> would be possible since I can enable remote root login, but that sounds like a security issue.</p>
| [
{
"answer_id": 74210976,
"author": "Zeitounator",
"author_id": 9401096,
"author_profile": "https://Stackoverflow.com/users/9401096",
"pm_score": 0,
"selected": false,
"text": "- name: Copy my file to root owned directory\n ansible.builtin.copy:\n src: /path/to/local-file\n dest: /... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12493545/"
] |
74,208,242 | <p>I am trying to create the following models in c# but am getting this error</p>
<blockquote>
<p>System.InvalidOperationException: 'Unable to determine the
relationship represented by navigation 'Activity.Token' of type
'Token2'. Either manually configure the relationship, or ignore this
property using the '[NotMapped]' attribute or by using
'EntityTypeBuilder.Ignore' in 'OnModelCreating'.'</p>
</blockquote>
<p>Here are my 2 models</p>
<pre><code>public class Token2
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
[ForeignKey(nameof(LastActivity))]
public long? LastActivityId { get; set; }
public Activity? LastActivity { get; set; }
public ICollection<Activity>? Activity { get; set; }
}
public partial class Activity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
public string Test { get; set; }
[ForeignKey(nameof(Token2))]
public long? TokenId { get; set; }
public Token2? Token { get; set; }
}
</code></pre>
<p>So the idea is that a Token has many activities related to it and I also want to keep that of the last activity acted on the Token.</p>
<p>And activity might be related to a Token or not, this is optional</p>
<p>How can i define this in EFCore?</p>
| [
{
"answer_id": 74208511,
"author": "Ghassen",
"author_id": 4112547,
"author_profile": "https://Stackoverflow.com/users/4112547",
"pm_score": 1,
"selected": false,
"text": "public partial class Activity\n{\n\n public long Id { get; set; }\n public string Test { get; set; }\n publ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1287072/"
] |
74,208,259 | <p>I have a table with different people that got different grades. I need to find the two persons with the highest grades. And if there is any ties, select them aswell. The only thing ive got right now is the 1st highest grade with this query:</p>
<pre><code>SELECT name,
MAX(grade) AS max_grade
FROM exercise_5
GROUP BY name
HAVING max_grade = ( SELECT MAX(grade) as max_grade
FROM exercise_5
GROUP BY name
ORDER BY max_grade DESC LIMIT 1
);
</code></pre>
<p>Anyone know how its done?</p>
| [
{
"answer_id": 74208511,
"author": "Ghassen",
"author_id": 4112547,
"author_profile": "https://Stackoverflow.com/users/4112547",
"pm_score": 1,
"selected": false,
"text": "public partial class Activity\n{\n\n public long Id { get; set; }\n public string Test { get; set; }\n publ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10781487/"
] |
74,208,282 | <p>My dataframe is like:</p>
<pre><code>df = pd.DataFrame({'a':[1,2,3], 'b':["{'c':1}", "{'d':3}", "{'c':5, 'd':6}"]})
</code></pre>
<p>Expected output:</p>
<pre><code> a c d
0 1 1.0 NaN
1 2 NaN 3.0
2 3 5.0 6.0
</code></pre>
<p>Working solution would be <code>df['b'].apply(pd.Series)</code> but this is not working as the b column is string but not dict. I am not defining the column structure, so can't tweak that.</p>
| [
{
"answer_id": 74208363,
"author": "Rabinzel",
"author_id": 15521392,
"author_profile": "https://Stackoverflow.com/users/15521392",
"pm_score": 2,
"selected": true,
"text": "ast.literal_eval"
},
{
"answer_id": 74208389,
"author": "bitflip",
"author_id": 20027803,
"aut... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17900863/"
] |
74,208,382 | <p>is there a way we can use when we apply a condition on a <code>df</code> and get two return values: one fulfilling the condition and the second with remaining part?</p>
<p><code>df_with_condition, df_without_condition = df.[some conditional actions]</code></p>
| [
{
"answer_id": 74208363,
"author": "Rabinzel",
"author_id": 15521392,
"author_profile": "https://Stackoverflow.com/users/15521392",
"pm_score": 2,
"selected": true,
"text": "ast.literal_eval"
},
{
"answer_id": 74208389,
"author": "bitflip",
"author_id": 20027803,
"aut... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7830427/"
] |
74,208,395 | <p>I I'm trying to use python with conda environment.
I create an environment using</p>
<pre><code> conda create -n new_env3 python=3.9
</code></pre>
<p>Then when I start python terminal (just running 'python') I get:</p>
<blockquote>
<p>Python 3.9.12 (main, Apr 5 2022, 06:56:58)<br />
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.<br />
Segmentation fault</p>
</blockquote>
<p>I tried multiple python versions and sub-versions, but all resulted in the same error</p>
| [
{
"answer_id": 74241958,
"author": "neb",
"author_id": 11075560,
"author_profile": "https://Stackoverflow.com/users/11075560",
"pm_score": 0,
"selected": false,
"text": "conda clean -a"
},
{
"answer_id": 74312952,
"author": "Shengyuan XU",
"author_id": 20414651,
"auth... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4180164/"
] |
74,208,396 | <div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Time</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>10/3/2022 18:21:40</td>
<td>correct</td>
</tr>
<tr>
<td>10/3/2022 18:22:50</td>
<td>incorrect</td>
</tr>
<tr>
<td>10/3/2022 18:28:00</td>
<td>correct</td>
</tr>
<tr>
<td>10/3/2022 18:34:00</td>
<td>incorrect</td>
</tr>
</tbody>
</table>
</div>
<p>From the above table, I want only filter out and show on the table if the time difference between "correct" and "incorrect" is > 5 minutes</p>
| [
{
"answer_id": 74241958,
"author": "neb",
"author_id": 11075560,
"author_profile": "https://Stackoverflow.com/users/11075560",
"pm_score": 0,
"selected": false,
"text": "conda clean -a"
},
{
"answer_id": 74312952,
"author": "Shengyuan XU",
"author_id": 20414651,
"auth... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17670620/"
] |
74,208,413 | <p>I have been looking for a way to find the possible combinations of a list, given a minimal distance of 3 between all the numbers.</p>
<p>Suppose we have</p>
<pre><code>list = [23, 48, 10, 55, 238, 11, 12, 23, 48, 10, 55, 238, 11, 12, 23, 48, 10, 55, 238, 11]
</code></pre>
<p>The best possible combination would be 23 + 238 + 238 + 238 = 737.</p>
<p>I've tried parsing the list and selecting each time the max of the split list[i:i+4], like so :</p>
<p>23 -skip three indexes -> max of [238, 11, 12, 23] : 238 -skip three indexes -> max of [48, 10, 55, 238] : 238 skip three indexes -> max of [48, 10, 55, 238] : 238</p>
<p>This worked with this case, but not with other lists where I couldn't compare the skipped indexes.</p>
<p>Any help would be greatly appreciated.</p>
| [
{
"answer_id": 74209712,
"author": "Swifty",
"author_id": 20267366,
"author_profile": "https://Stackoverflow.com/users/20267366",
"pm_score": 1,
"selected": false,
"text": "list = [23, 48, 10, 55, 238, 11, 12, 23, 48, 10, 55, 238, 11, 12, 23, 48, 10, 55, 238, 11]\n\ndef max_sum(list):\n ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17743805/"
] |
74,208,441 | <p>Given any word, swap the first and the last letter's position then return the new string. If that is a one-letter word, return the word. I'm aware the fastest way to do this is to use slicing, or join but I want to try a new approach using replace.</p>
<pre><code>def front_back(any_string):
if len(any_string) <= 1:
return any_string
else:
temp = any_string.replace(any_string[0],list(any_string)[-1])
final_str = temp.replace(temp[-1],list(any_string)[0])
print(final_str)
front_back('line')
</code></pre>
<p>Instead of "einl", it returns "linl".</p>
| [
{
"answer_id": 74209712,
"author": "Swifty",
"author_id": 20267366,
"author_profile": "https://Stackoverflow.com/users/20267366",
"pm_score": 1,
"selected": false,
"text": "list = [23, 48, 10, 55, 238, 11, 12, 23, 48, 10, 55, 238, 11, 12, 23, 48, 10, 55, 238, 11]\n\ndef max_sum(list):\n ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339735/"
] |
74,208,447 | <p>I have a list of cards, when you click on a card, it opens and a class "opened" is added to it. How to make it so that when all the cards are opened a button will appear (does not matter the button or some other action);</p>
<p>HTML when the program starts:</p>
<pre><code><ul id='container'>
<li class='card'></li>
<li class='card'></li>
<li class='card'></li>
<li class='card'></li>
<li class='card'></li>
</ul>
</code></pre>
<p>When all cards opened:</p>
<pre><code><ul id='container'>
<li class='card opened'></li>
<li class='card opened'></li>
<li class='card opened'></li>
<li class='card opened'></li>
<li class='card opened'></li>
</ul>
<button class='btn-restart'>Restart</button>
</code></pre>
<p>EDITED:</p>
<p>for some reason, even when i make the button appear when at least 1 card has a class 'opened', nothing happens</p>
<p>JS:</p>
<pre><code>function couplesApp() {
const container = document.getElementById('container');
const buttonRestart = createRestartButton();
// some other essential stuff i didn't include
const cards = document.getElementsByClassName('card');
for (let i = 0; i < cards.length; i++) {
if (cards[i].classList.contains('opened')) {
container.append(buttonRestart);
};
};
</code></pre>
<p>EDITED (2):</p>
<p>SOLUTION IS:</p>
<pre><code>document.querySelector('#container').addEventListener('click', () => {
const cards = document.getElementsByClassName('card');
for (let i = 0; i < cards.length; i++) {
if (cards.length === document.querySelectorAll('.card.opened').length){
container.append(buttonRestart);
};
};
});
</code></pre>
<p>Thanks to Scott Marcus.</p>
| [
{
"answer_id": 74208647,
"author": "Pedro Ribeiro",
"author_id": 8559424,
"author_profile": "https://Stackoverflow.com/users/8559424",
"pm_score": 0,
"selected": false,
"text": "if (document.getElementsByClassName(\"opened\").length === 5) { }"
},
{
"answer_id": 74208659,
"au... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19463106/"
] |
74,208,465 | <p>I am trying to find the mean of the variable <code>disp</code> in mtcars dataset after nesting it by <code>cyl</code>. I am able to get the result after <code>nest_by</code> but not with <code>group_nest</code>. Please explain what the <code>rowwise</code> is doing it differently here.</p>
<pre class="lang-r prettyprint-override"><code>require(tidyverse)
# working
mtcars %>% nest_by(cyl) %>% mutate(avg = mean(data$disp))
#> # A tibble: 3 × 3
#> # Rowwise: cyl
#> cyl data avg
#> <dbl> <list<tibble[,10]>> <dbl>
#> 1 4 [11 × 10] 105.
#> 2 6 [7 × 10] 183.
#> 3 8 [14 × 10] 353.
# not working
mtcars %>% group_nest(cyl) %>%
mutate(avg = mean(data$disp))
#> Error in `mutate()`:
#> ! Problem while computing `avg = mean(data$disp)`.
#> Caused by error:
#> ! Corrupt x: no names
#> Backtrace:
#> ▆
#> 1. ├─mtcars %>% group_nest(cyl) %>% mutate(avg = mean(data$disp))
#> 2. ├─dplyr::mutate(., avg = mean(data$disp))
#> 3. ├─dplyr:::mutate.data.frame(., avg = mean(data$disp))
#> 4. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), caller_env = caller_env())
#> 5. │ ├─base::withCallingHandlers(...)
#> 6. │ └─mask$eval_all_mutate(quo)
#> 7. ├─base::mean(data$disp)
#> 8. ├─data$disp
#> 9. ├─vctrs:::`$.vctrs_list_of`(data, disp)
#> 10. └─base::.handleSimpleError(`<fn>`, "Corrupt x: no names", base::quote(NULL))
#> 11. └─dplyr (local) h(simpleError(msg, call))
#> 12. └─rlang::abort(...)
</code></pre>
<p><sup>Created on 2022-10-26 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p>
| [
{
"answer_id": 74208935,
"author": "ejneer",
"author_id": 8827325,
"author_profile": "https://Stackoverflow.com/users/8827325",
"pm_score": 2,
"selected": false,
"text": "rowwise"
},
{
"answer_id": 74208944,
"author": "akrun",
"author_id": 3732271,
"author_profile": "... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2890129/"
] |
74,208,495 | <p>Apologies in advance if this long question seems quite basic!</p>
<p><strong>Given</strong>:</p>
<p>search query <a href="https://digi.kansalliskirjasto.fi/search?query=economic%20crisis&orderBy=RELEVANCE" rel="nofollow noreferrer">link</a> in a library website:</p>
<pre><code>url = 'https://digi.kansalliskirjasto.fi/search?query=economic%20crisis&orderBy=RELEVANCE'
</code></pre>
<p>I'd like to extract all useful information for each individual search result (total 20 in 1 page) of this specific query as depicted by red rectangles in this figure:</p>
<p><a href="https://i.stack.imgur.com/fWRCD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fWRCD.png" alt="enter image description here" /></a></p>
<p>currently, I have the following code:</p>
<pre><code>from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
def run_selenium(URL):
options = Options()
options.add_argument("--remote-debugging-port=9222"),
options.headless = True
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get(URL)
pt = "//app-digiweb/ng-component/section/div/div/app-binding-search-results/div/div"
medias = driver.find_elements(By.XPATH, pt) # expect to obtain a list with 20 elements!!
print(medias) # >>>>>> result: []
print("#"*100)
for i, v in enumerate(medias):
print(i, v.get_attribute("innerHTML"))
if __name__ == '__main__':
url = 'https://digi.kansalliskirjasto.fi/search?query=economic%20crisis&orderBy=RELEVANCE'
run_selenium(URL=url)
</code></pre>
<p><strong>Problem</strong>:</p>
<p>Having a look at part of the inspect in chrome:</p>
<p><a href="https://i.stack.imgur.com/X9V6h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X9V6h.png" alt="enter image description here" /></a></p>
<p>I have tried several xpath generated by Chrome Extensions <code>XPath Helper</code> and <code>SelectorsHub</code> to produce XPath and use it as <code>pt</code> variable in my python code this library search engine, but the result is <code>[]</code> or simply nothing.</p>
<p>Using <code>SelectorsHub</code> and hovering the mouse over <code>Rel XPath</code>, I get this warning: <code>id & class both look dynamic. Uncheck id & class checkbox to generate rel xpath without them if it is generated with them.</code></p>
<p><strong>Question</strong>:</p>
<p>Assuming <code>selenium</code> as a tool for web scraping with dynamic attributes instead of <code>BeautifulSoup</code> as recommended <a href="https://stackoverflow.com/questions/44867425/beautiful-soup-cant-find-tags">here</a> and <a href="https://stackoverflow.com/questions/8049520/web-scraping-javascript-page-with-python">here</a>, shouldn't <code>driver.find_elements()</code>, return a list of 20 elements each of which containing all info and to be extracted?</p>
| [
{
"answer_id": 74209497,
"author": "JaSON",
"author_id": 10682289,
"author_profile": "https://Stackoverflow.com/users/10682289",
"pm_score": 2,
"selected": true,
"text": "find_elements"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5437090/"
] |
74,208,504 | <p>When I click I want to smoothly add segments to the progress bar. They are added but instantly. What could be the problem?</p>
<p><a href="https://i.stack.imgur.com/kDwPM.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kDwPM.gif" alt="demonstration of problem" /></a></p>
<p>I tried to implement a smooth animation with <code>setInterval</code>, but nothing comes out. Percentages are also added instantly.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let progressBar = document.querySelector(".progressbar");
let progressBarValue = document.querySelector(".progressbar__value");
const body = document.querySelector("body");
let progressBarStartValue = 0;
let progressBarEndValue = 100;
let speed = 50;
body.addEventListener("click", function(e) {
if (progressBarStartValue === progressBarEndValue) {
alert("you have completed all the tasks");
} else {
let progress = setInterval(() => {
if (progressBarStartValue != 100) {
progressBarStartValue += 10;
clearInterval(progress);
}
progressBarValue.textContent = `${progressBarStartValue}%`;
progressBar.style.background = `conic-gradient(
#FFF ${progressBarStartValue * 3.6}deg,
#262623 ${progressBarStartValue * 3.6}deg
)`;
}, speed);
}
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.progressbar {
position: relative;
height: 150px;
width: 150px;
background-color: #262623;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.progressbar::before {
content: "";
position: absolute;
height: 80%;
width: 80%;
background-color: #0f0f0f;
border-radius: 50%;
}
.progressbar__value {
color: #fff;
z-index: 9;
font-size: 25px;
font-weight: 600;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><main class="main">
<section class="statistic">
<div class="container">
<div class="statistic__inner">
<div class="statistic__text">
<h2 class="statistic__title">You're almost there!</h2>
<p class="statistic__subtitle">keep up the good work</p>
</div>
<div class="progressbar"><span class="progressbar__value">0%</span></div>
</div>
</div>
</section>
</main></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74209679,
"author": "andrilla",
"author_id": 14802731,
"author_profile": "https://Stackoverflow.com/users/14802731",
"pm_score": 2,
"selected": true,
"text": "conic-gradient()"
},
{
"answer_id": 74209956,
"author": "Mad7Dragon",
"author_id": 6467902,
"a... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19810807/"
] |
74,208,549 | <p>in order to learn Rust, I try to create small snippets to apply what we learn in the Rust book and implement good practices.</p>
<p>Have a small function to list content of a repository :</p>
<pre><code>use std::{io, fs, path::PathBuf, path::Path};
pub fn get_directory_content(path: &str) -> Result<Vec<PathBuf>, io::Error> {
let _path: bool = Path::new(path).is_dir();
match _path {
true => {
let mut result = vec![];
for file in fs::read_dir(path).unwrap() {
result.push(file.unwrap().path());
}
Ok(result)
},
false => Err(io::Error::new(io::ErrorKind::Other, " is not a directory")),
}
}
</code></pre>
<p>my goal is to be able to catch the error if the folder does not exist without triggering a panic.</p>
<p>in main.rs :</p>
<pre><code>mod utils;
fn main() {
let directory = "./qsdsqd";
let test = utils::get_directory_content(directory).unwrap();
println!("{:?}", a);
}
</code></pre>
<p>if directory exist : ok, unwrap is happy. But does anyone know a "trick" for get the content of the error in var test ? Also, can we put the name of a variable in io::ErrorKind::Other to get more precision (here : &path) ?</p>
<p>Next try</p>
<pre><code>fn main() {
let directory = "./qsdqsd";
let a = match utils::get_directory_content(directory){
Err(e) => println!("an error: {:?}", e),
Ok(c) => println!("{:?}", c),
};
println!("{:?}", a);
}
</code></pre>
<p>When error, ok, we have message, but here, if we put a correct folder : a "just" print result but content is empty, and we can't say Ok(c) => c for just return Ok content from function :/</p>
| [
{
"answer_id": 74209230,
"author": "Finomnis",
"author_id": 2902833,
"author_profile": "https://Stackoverflow.com/users/2902833",
"pm_score": 1,
"selected": false,
"text": "c"
},
{
"answer_id": 74209247,
"author": "Masklinn",
"author_id": 8182118,
"author_profile": "h... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10511614/"
] |
74,208,581 | <p>I have a large PostgreSQL DB table. From this table I need to take rows grouped by <code>Car_id</code> and <code>position</code> columns.
The problem is that I have a lot of duplicates and need to take one row with the best <code>position</code>.
I wrote a sql example that gave me the correct results, but it needs to be modified. Or how can I do it in a cleaner way?</p>
<p>And I need to choose a unique car_id, with a minimum position, last by date of scrape, of all passed license plate numbers, I am not interested in what particular license plate number will be.</p>
<p>Example of SQL:</p>
<pre><code>select
"eventDate",
"Car_id",
min("position") as "carPosition",
groupArray(concat(toString("scrapedAt"), '_', toString("position"))) as "scrapedAtByPosition",
groupArray(concat("licensePlate", '_', toString("position"))) as "licensePlateByPosition",
groupArray(concat(toString("amazonChoice"), '_', toString("position"))) as "amazonChoicesByPosition",
'organic' as "matchType"
from "Car1_ScrapeHistoryLicensePlate"
inner join (
select "Car_id", max("scrapedAt") as "scrapedAt"
from "Car1_ScrapeHistoryLicensePlate"
where "licensePlate" IN ('ALPR912', 'JGPD831') and "eventDate" between '2022-08-12' and '2022-09-12'
group by "Car_id", "eventDate"
) as t1 USING ("Car_id", "scrapedAt")
where "licensePlate" IN ('ALPR912', 'JGPD831') and "eventDate" between '2022-08-12' and '2022-09-12'
group by "eventDate", "Car_id"
order by "eventDate" desc;
</code></pre>
<p>Database records:</p>
<pre><code>eventDate Car_id licensePlate position scrapedAt
---------- ------ ------------ ------- ---------
2022-09-10, 1, APRJSC512, 1, 1660000001
2022-09-10, 1, APRJSC512, 1, 1660000002
2022-09-10, 1, PLBQWN035, 1, 1660000003
2022-09-10, 1, PLBQWN035, 1, 1660000004
2022-09-10, 1, PLBQWN035, 2, 1660000002
2022-09-11, 2, APRJSC512, 1, 1660000011
2022-09-11, 2, APRJSC512, 2, 1660000022
2022-09-11, 2, PLBQWN035, 1, 1660000033
2022-09-11, 2, PLBQWN035, 2, 1660000044
2022-09-11, 2, PLBQWN035, 5, 1660000022
2022-09-12, 3, APRJSC512, 3, 1660000111
2022-09-12, 3, PLBQWN035, 3, 1660000222
2022-09-13, 4, PLBQWN035, 4, 1660001111
2022-09-14, 5, PLBQWN035, 5, 1660011111
</code></pre>
<p>Expected result:</p>
<pre><code>eventDate Car_id licensePlate position scrapedAt
---------- ------ ------------ ------- ---------
2022-09-10, 1, PLBQWN035, 1, 1660000004
2022-09-11, 2, PLBQWN035, 1, 1660000033
2022-09-12, 3, PLBQWN035, 3, 1660000222
</code></pre>
| [
{
"answer_id": 74209179,
"author": "DannySlor",
"author_id": 19174570,
"author_profile": "https://Stackoverflow.com/users/19174570",
"pm_score": 1,
"selected": false,
"text": "select eventDate\n ,Car_id \n ,licensePlate \n ,position \n ,scrapedAt\nfrom\n(\nselect... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9669394/"
] |
74,208,584 | <p>How would it be possible to seperate a string of values (in my case, only corresponding to roman numeral values) into elements of a list?</p>
<p><code>'10010010010100511' -> [100, 100, 100, 10, 100, 5, 1, 1,]</code></p>
<p>I want to create something that goes like:
if it is a zero add it to side
if it's not a zero create a new element for it</p>
| [
{
"answer_id": 74209179,
"author": "DannySlor",
"author_id": 19174570,
"author_profile": "https://Stackoverflow.com/users/19174570",
"pm_score": 1,
"selected": false,
"text": "select eventDate\n ,Car_id \n ,licensePlate \n ,position \n ,scrapedAt\nfrom\n(\nselect... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339851/"
] |
74,208,587 | <p>I have some records in database that are containing Serbian latin letters (ć, č, đ, ž, š).</p>
<p>I've done search functionality in backend (nestjs) to search all columns in table that contain typed characters on frontend (react).</p>
<p>How could I search these latin letters when typed character is for example c (this should look for all 3 characters with same "base" -> c, č, ć). Same should be done with the others.</p>
<p>I tried some regex, but never got desired result.</p>
<p>Any basic ideas how should I do this?</p>
| [
{
"answer_id": 74208975,
"author": "Apostolos",
"author_id": 1121008,
"author_profile": "https://Stackoverflow.com/users/1121008",
"pm_score": 0,
"selected": false,
"text": "postgres"
},
{
"answer_id": 74208978,
"author": "R4ncid",
"author_id": 14326899,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12853329/"
] |
74,208,599 | <p>I configured <code>Coverity</code> with</p>
<p><a href="https://i.stack.imgur.com/G4MGv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G4MGv.png" alt="enter image description here" /></a></p>
<p>The build is successful, but I receive <code>Recoverable errors</code> in the system headers (see build-log.txt)</p>
<p><a href="https://i.stack.imgur.com/b6xuQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b6xuQ.png" alt="enter image description here" /></a></p>
<p>For me it’s not clear why these errors occur (build is successful) and how to configure <code>Coverity</code> that these errors don’t occur at all?</p>
<pre><code>2022-10-20T13:38:11.227719Z|cov-build|66594|info|> cov-build 2022.3.3 (build d37b3c67c6 p-2022.3-push-69)
2022-10-20T13:38:11.227742Z|cov-build|66594|info|> Coverity Build Capture (64-bit) version 2022.3.3 on Linux 5.15.0-48-generic x86_64
2022-10-20T13:38:11.227742Z|cov-build|66594|info|> Internal version numbers: d37b3c67c6 p-2022.3-push-69
2022-10-20T13:38:11.227742Z|cov-build|66594|info|>
2022-10-20T13:38:11.227757Z|cov-build|66594|info|> Dumping from hostname : ci
2022-10-20T13:38:11.227757Z|cov-build|66594|info|>
2022-10-20T13:38:11.227764Z|cov-build|66594|info|> Platform info:
2022-10-20T13:38:11.227764Z|cov-build|66594|info|> Sysname = Linux
2022-10-20T13:38:11.227764Z|cov-build|66594|info|> Release = 5.15.0-48-generic
2022-10-20T13:38:11.227764Z|cov-build|66594|info|> Machine = x86_64
2022-10-20T13:38:11.227764Z|cov-build|66594|info|>
2022-10-20T13:38:11.227764Z|cov-build|66594|info|>
2022-10-20T13:38:11.227780Z|cov-build|66594|info|> cov-build command: cov-build --dir build/test/icc cmake --build .
2022-10-20T13:38:11.227786Z|cov-build|66594|info|> cov-build expanded command: cov-build --dir build/test/icc cmake --build .
2022-10-20T13:38:11.227957Z|cov-build|66594|info|> build command: /usr/bin/cmake --build .
2022-10-20T13:38:11.227966Z|cov-build|66594|info|> thunk command: /opt/coverity/cov-analysis-2022-3/bin/cov-internal-thunk.sh cmake --build .
2022-10-20T13:38:11.227966Z|cov-build|66594|info|>
2022-10-20T13:38:11.227974Z|cov-build|66594|info|> Set UseSharedCompilation to false.
2022-10-20T13:38:11.227982Z|cov-build|66594|info|> Set COVERITY_BIN to /opt/coverity/cov-analysis-2022-3/bin
2022-10-20T13:38:11.227993Z|cov-build|66594|info|> Set COVERITY_SITE_CC to iccarm
2022-10-20T13:38:11.227999Z|cov-build|66594|info|> Set COVERITY_SITE_CC_CAPTURE_DESCENDANTS to
2022-10-20T13:38:11.228005Z|cov-build|66594|info|> Set COVERITY_TEMP to /tmp/cov-repo/61cbee90e75bbbfcd24d03a3fa896a77
2022-10-20T13:38:11.228015Z|cov-build|66594|info|> Set COVERITY_COMMON_TEMP to /tmp
2022-10-20T13:38:11.228023Z|cov-build|66594|info|> Set COVERITY_IDIR to /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc
2022-10-20T13:38:11.228048Z|cov-build|66594|info|> Set COVERITY_OUTPUT to /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/build-log.txt
2022-10-20T13:38:11.228053Z|cov-build|66594|info|> Set COVERITY_LOG to /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/build-log.txt
2022-10-20T13:38:11.228061Z|cov-build|66594|info|> Set COVERITY_OUTPUT_ENCODING to US-ASCII
2022-10-20T13:38:11.228066Z|cov-build|66594|info|> Set COVERITY_SYSTEM_ENCODING to US-ASCII
2022-10-20T13:38:11.228073Z|cov-build|66594|info|> Set COVERITY_EMIT to /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/emit
2022-10-20T13:38:11.228095Z|cov-build|66594|info|> Set COVERITY_IS_COMPILER to 0
2022-10-20T13:38:11.228100Z|cov-build|66594|info|> Set COVERITY_TOP_PROCESS to 0
2022-10-20T13:38:11.228103Z|cov-build|66594|info|> Set COVERITY_IS_COMPILER_DESCENDANT to 0
2022-10-20T13:38:11.228107Z|cov-build|66594|info|> Set COVERITY_DISENGAGE_EXES to "qemuwrapper;qemu-aarch64;qemu-alpha;qemu-arm;qemu-armeb;qemu-cris;qemu-i386;qemu-m68k;qemu-microblaze;qemu-mips;qemu-mipsel;qemu-nios2;qemu-ppc;qemu-ppc64;qemu-ppc64abi32;qemu-sh4;qemu-sh4eb;qemu-sparc;qemu-sparc32plus;qemu-sparc64;qemu-x86_64"
2022-10-20T13:38:11.228123Z|cov-build|66594|info|>
2022-10-20T13:38:11.228123Z|cov-build|66594|info|>
2022-10-20T13:38:11.228123Z|cov-build|66594|info|> Dumping Environment Variables:
2022-10-20T13:38:11.228123Z|cov-build|66594|info|>
2022-10-20T13:38:11.228142Z|cov-build|66594|info|> JENKINS_HOME=/home/repo/.jenkins
2022-10-20T13:38:11.228146Z|cov-build|66594|info|> GIT_PREVIOUS_SUCCESSFUL_COMMIT=5ecdaedd1ad5f4173cc5aa22a7ff06a2d7aa659b
2022-10-20T13:38:11.228151Z|cov-build|66594|info|> CI=true
2022-10-20T13:38:11.228154Z|cov-build|66594|info|> RUN_CHANGES_DISPLAY_URL=http://unconfigured-jenkins-location/job/xxx/324/display/redirect?page=changes
2022-10-20T13:38:11.228158Z|cov-build|66594|info|> HOSTNAME=ci
2022-10-20T13:38:11.228167Z|cov-build|66594|info|> NODE_LABELS=built-in
2022-10-20T13:38:11.228171Z|cov-build|66594|info|> GIT_COMMIT=c8902b01612b12a90701b3949e8be64e65775ba7
2022-10-20T13:38:11.228175Z|cov-build|66594|info|> HOME=/home/repo
2022-10-20T13:38:11.228179Z|cov-build|66594|info|> HUDSON_COOKIE=94d36788-17b8-4a07-a30e-6e22a28d86dc
2022-10-20T13:38:11.228183Z|cov-build|66594|info|> JENKINS_SERVER_COOKIE=durable-d67ab9cc6fd15cde89a20cb1f752777478da5dc72dc942e65e59bab789c478c1
2022-10-20T13:38:11.228187Z|cov-build|66594|info|> WORKSPACE=/home/repo/.jenkins/workspace/xxx
2022-10-20T13:38:11.228190Z|cov-build|66594|info|> CROSS_ROOT=/opt/iarsystems/bxarm-9.30.1/arm
2022-10-20T13:38:11.228194Z|cov-build|66594|info|> NODE_NAME=built-in
2022-10-20T13:38:11.228198Z|cov-build|66594|info|> RUN_ARTIFACTS_DISPLAY_URL=http://unconfigured-jenkins-location/job/xxx/324/display/redirect?page=artifacts
2022-10-20T13:38:11.228201Z|cov-build|66594|info|> ASM=iasmarm
2022-10-20T13:38:11.228205Z|cov-build|66594|info|> STAGE_NAME=Icc Arm + Coverity
2022-10-20T13:38:11.228209Z|cov-build|66594|info|> EXECUTOR_NUMBER=0
2022-10-20T13:38:11.228213Z|cov-build|66594|info|> GIT_BRANCH=origin/master
2022-10-20T13:38:11.228217Z|cov-build|66594|info|> TERM=xterm
2022-10-20T13:38:11.228220Z|cov-build|66594|info|> RUN_TESTS_DISPLAY_URL=http://unconfigured-jenkins-location/job/xxx/324/display/redirect?page=tests
2022-10-20T13:38:11.228224Z|cov-build|66594|info|> BUILD_DISPLAY_NAME=#324
2022-10-20T13:38:11.228228Z|cov-build|66594|info|> HUDSON_HOME=/home/repo/.jenkins
2022-10-20T13:38:11.228232Z|cov-build|66594|info|> JOB_BASE_NAME=xxx
2022-10-20T13:38:11.228236Z|cov-build|66594|info|> PATH=/opt/coverity/cov-analysis-2022-3/bin:/opt/SEGGER/JLink_V766:/opt/iarsystems/bxarm-9.30.1/common/bin:/opt/iarsystems/bxarm-9.30.1/arm/bin:/opt/gcc-arm-none-eabi-10.3-2021.07/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2022-10-20T13:38:11.228240Z|cov-build|66594|info|> TOOLCHAIN_FILE=../../../cmake/platforms/$TOOLCHAIN_FILENAME
2022-10-20T13:38:11.228244Z|cov-build|66594|info|> BUILD_ID=324
2022-10-20T13:38:11.228247Z|cov-build|66594|info|> BUILD_TAG=jenkins-xxx-324
2022-10-20T13:38:11.228251Z|cov-build|66594|info|> GIT_URL=file:///home/repo/repository
2022-10-20T13:38:11.228255Z|cov-build|66594|info|> BUILD_NUMBER=324
2022-10-20T13:38:11.228259Z|cov-build|66594|info|> JENKINS_NODE_COOKIE=a1e213c4-5eae-41f4-bff8-c26bcc76eacd
2022-10-20T13:38:11.228262Z|cov-build|66594|info|> CXX=iccarm
2022-10-20T13:38:11.228266Z|cov-build|66594|info|> RUN_DISPLAY_URL=http://unconfigured-jenkins-location/job/xxx/324/display/redirect
2022-10-20T13:38:11.228270Z|cov-build|66594|info|> HUDSON_SERVER_COOKIE=e67de7100ca0e18a
2022-10-20T13:38:11.228274Z|cov-build|66594|info|> JOB_DISPLAY_URL=http://unconfigured-jenkins-location/job/xxx/display/redirect
2022-10-20T13:38:11.228278Z|cov-build|66594|info|> JOB_NAME=xxx
2022-10-20T13:38:11.228282Z|cov-build|66594|info|> PWD=/home/repo/.jenkins/workspace/xxx/build/test/icc
2022-10-20T13:38:11.228286Z|cov-build|66594|info|> GIT_PREVIOUS_COMMIT=6ec26434a11544368ba767770e88c74dd3391906
2022-10-20T13:38:11.228290Z|cov-build|66594|info|> WORKSPACE_TMP=/home/repo/.jenkins/workspace/xxx@tmp
2022-10-20T13:38:11.228293Z|cov-build|66594|info|> CC=iccarm
2022-10-20T13:38:11.228297Z|cov-build|66594|info|> TOOLCHAIN_FILENAME=toolchain-iar-iccarm.cmake
2022-10-20T13:38:11.228301Z|cov-build|66594|info|> COVERITY_PREV_XML_CATALOG_FILES=
2022-10-20T13:38:11.228305Z|cov-build|66594|info|> COVERITY_TOP_CONFIG=/tmp/cov-repo/61cbee90e75bbbfcd24d03a3fa896a77/cov-configure/coverity_config.xml
2022-10-20T13:38:11.228309Z|cov-build|66594|info|> COVERITY_BUILD_INVOCATION_ID=1
2022-10-20T13:38:11.228313Z|cov-build|66594|info|> COVERITY_CONFIG_FILE=/opt/coverity/cov-analysis-2022-3/config/coverity_config.xml
2022-10-20T13:38:11.228317Z|cov-build|66594|info|> UseSharedCompilation=false
2022-10-20T13:38:11.228321Z|cov-build|66594|info|> COVERITY_BIN=/opt/coverity/cov-analysis-2022-3/bin
2022-10-20T13:38:11.228325Z|cov-build|66594|info|> COVERITY_SITE_CC=iccarm
2022-10-20T13:38:11.228332Z|cov-build|66594|info|> COVERITY_SITE_CC_CAPTURE_DESCENDANTS=
2022-10-20T13:38:11.228336Z|cov-build|66594|info|> COVERITY_TEMP=/tmp/cov-repo/61cbee90e75bbbfcd24d03a3fa896a77
2022-10-20T13:38:11.228340Z|cov-build|66594|info|> COVERITY_COMMON_TEMP=/tmp
2022-10-20T13:38:11.228344Z|cov-build|66594|info|> COVERITY_IDIR=/home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc
2022-10-20T13:38:11.228348Z|cov-build|66594|info|> COVERITY_REWRITE_FROM=
2022-10-20T13:38:11.228352Z|cov-build|66594|info|> COVERITY_REWRITE_TO=
2022-10-20T13:38:11.228356Z|cov-build|66594|info|> COVERITY_ENABLE_JAVA_ANNOTATION_FRAMEWORK_SUPPORT=1
2022-10-20T13:38:11.228360Z|cov-build|66594|info|> COVERITY_OUTPUT=/home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/build-log.txt
2022-10-20T13:38:11.228364Z|cov-build|66594|info|> COVERITY_LOG=/home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/build-log.txt
2022-10-20T13:38:11.228367Z|cov-build|66594|info|> COVERITY_OUTPUT_ENCODING=US-ASCII
2022-10-20T13:38:11.228371Z|cov-build|66594|info|> COVERITY_SYSTEM_ENCODING=US-ASCII
2022-10-20T13:38:11.228375Z|cov-build|66594|info|> COVERITY_EMIT=/home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/emit
2022-10-20T13:38:11.228379Z|cov-build|66594|info|> COVERITY_IS_COMPILER=0
2022-10-20T13:38:11.228383Z|cov-build|66594|info|> COVERITY_TOP_PROCESS=0
2022-10-20T13:38:11.228387Z|cov-build|66594|info|> COVERITY_IS_COMPILER_DESCENDANT=0
2022-10-20T13:38:11.228390Z|cov-build|66594|info|> COVERITY_DISENGAGE_EXES=qemuwrapper;qemu-aarch64;qemu-alpha;qemu-arm;qemu-armeb;qemu-cris;qemu-i386;qemu-m68k;qemu-microblaze;qemu-mips;qemu-mipsel;qemu-nios2;qemu-ppc;qemu-ppc64;qemu-ppc64abi32;qemu-sh4;qemu-sh4eb;qemu-sparc;qemu-sparc32plus;qemu-sparc64;qemu-x86_64
2022-10-20T13:38:11.228395Z|cov-build|66594|info|> COVERITY_COMPILER_PATH_MISMATCH_FILE=/home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/has_path_mismatches
2022-10-20T13:38:11.228399Z|cov-build|66594|info|> COVERITY_PATHLESS_CONFIGS_FILE=/home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/has_pathless_configs
2022-10-20T13:38:11.228405Z|cov-build|66594|info|>
2022-10-20T13:38:11.228405Z|cov-build|66594|info|>
2022-10-20T13:38:11.228405Z|cov-build|66594|info|> Dumping configuration:
2022-10-20T13:38:11.228405Z|cov-build|66594|info|>
2022-10-20T13:38:11.228415Z|cov-build|66594|info|> User/default configuration:
2022-10-20T13:38:11.228415Z|cov-build|66594|info|>
2022-10-20T13:38:11.228421Z|cov-build|66594|info|> Configuration read from: command-line
2022-10-20T13:38:11.228421Z|cov-build|66594|info|> Node: coverity
2022-10-20T13:38:11.228421Z|cov-build|66594|info|> Node: config
2022-10-20T13:38:11.228421Z|cov-build|66594|info|> Node: include Value: /opt/coverity/cov-analysis-2022-3/config/coverity_config.xml
2022-10-20T13:38:11.228421Z|cov-build|66594|info|> Node: config
2022-10-20T13:38:11.228421Z|cov-build|66594|info|> Node: prevent
2022-10-20T13:38:11.228421Z|cov-build|66594|info|> Node: dir Value: /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc
2022-10-20T13:38:11.228421Z|cov-build|66594|info|>
2022-10-20T13:38:11.228444Z|cov-build|66594|info|> Configuration read from: /opt/coverity/cov-analysis-2022-3/config/coverity_config.xml
2022-10-20T13:38:11.228444Z|cov-build|66594|info|> Node: coverity
2022-10-20T13:38:11.228444Z|cov-build|66594|info|> Node: cit_version Value: 1
2022-10-20T13:38:11.228444Z|cov-build|66594|info|> Node: config
2022-10-20T13:38:11.228444Z|cov-build|66594|info|> Node: include Value: /opt/coverity/cov-analysis-2022-3/config/template-iar_cxx_arm-config-0/coverity_config.xml
2022-10-20T13:38:11.228444Z|cov-build|66594|info|>
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Configuration read from: /opt/coverity/cov-analysis-2022-3/config/template-iar_cxx_arm-config-0/coverity_config.xml
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: coverity
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: cit_version Value: 1
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: config
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: build
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: compiler
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: template_compiler Value: true
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: comp_name Value: iccarm
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: comp_translator Value: iar_cxx:arm
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: comp_lang Value: C++
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: comp_generic Value: iar/arm
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: options
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: id Value: iar_cxx:arm-iccarm-.*
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: opt_preinclude_file Value: /opt/coverity/cov-analysis-2022-3/config/template-iar_cxx_arm-config-0/../user_nodefs.h
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: begin_command_line_config
2022-10-20T13:38:11.228461Z|cov-build|66594|info|> Node: md5 Value: 5f6642eb878a88db1dfb16309fb4338b
2022-10-20T13:38:11.228461Z|cov-build|66594|info|>
2022-10-20T13:38:11.230365Z|cov-build|66594|info|> Using LD_PRELOAD =
/opt/coverity/cov-analysis-2022-3/bin/libcapture-linux64-${PLATFORM}.so
[73713] EXECUTING: /opt/iarsystems/bxarm-9.30.1/arm/bin/ielfdumparm --source test.out
...
[73394] EXECUTING: grep dev
[STATUS] Compiling /home/repo/.jenkins/workspace/xxx/src/nodynalloc/new_del.cpp
/opt/coverity/cov-analysis-2022-3/bin/cov-emit --dir=/home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc --ignore_path=/tmp/cov-repo/61cbee90e75bbbfcd24d03a3fa896a77/cov-configure --ignore_path=/tmp/cov-repo/61cbee90e75bbbfcd24d03a3fa896a77/cov-repo/ab3163e8db5f4764170d37b222c3d703 --pre_preinclude /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/emit/ci/config/5092253b194ec0553c3a9de3b66cf08a/iar_cxx_arm-config-0/coverity-macro-compat.h --pre_preinclude /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/emit/ci/config/5092253b194ec0553c3a9de3b66cf08a/iar_cxx_arm-config-0/coverity-compiler-compat.h --c++ --dollar --allow_qualified_anonymous_unions --allow_global_anonymous_union --no_const_string_literals --unsigned_chars --trigraphs --enable_user_sections --add_type_modifier=__absolute,__big_endian --add_type_modifier=__little_endian --add_type_modifier=__packed,__pcrel --add_type_modifier=__sbrel,__global_reg --add_type_modifier=__coverity_16bit_float --allow_qualified_operator_new_return --lazy_hex_pp_number --short_enums --user_defined_literals --macro_preempts_udl_suffix --ppp_translator "replace/_Mem \*operator new(\[\])? _Mem/*operator new$1" --ppp_translator "replace/operator new mem/operator new" --ppp_translator replace/0.Infinity/1.0\/0.0 --ppp_translator replace/0.Na[Nn]/0.0\/0.0 --allow_injected_template_symbol --arg_dependent_overload --class_scope_noexcept --no_predefined_cplusplus -w --no_predefines --comp_ver 9030001 --char_bit_size=8 --wchar_t_keyword --no_multiline_string --ignore_calling_convention --no_enable_80bit_float --no_enable_128bit_float --macro_stack_pragmas --type_traits_helpers --rtti --inline_keyword --has_include_macro --has_include_next_macro --has_cpp_attribute_macro --no_predefines --preinclude /opt/coverity/cov-analysis-2022-3/config/template-iar_cxx_arm-config-0/../user_nodefs.h --c++17 --c++17 --no_rtti --no_exceptions --short_enums --gnu_version=50400 --macro_stack_pragmas --add_type_modifier=__data:1,__code --no_stdarg_builtin --sys_include /opt/iarsystems/bxarm-9.30.1/arm/inc/c --sys_include /opt/iarsystems/bxarm-9.30.1/arm/inc/c/aarch32 --sys_include /opt/iarsystems/bxarm-9.30.1/arm/inc/cpp --ppp_translator replace/(#include\s+)u8/$1 --ppp_translator replace/(#define\s+_DLIB_CONFIG_FILE_HEADER_NAME\s+)u8/$1 --ppp_translator replace/(#define\s+_DLIB_CONFIG_FILE_STRING\s+)u8/$1 --ppp_translator replace/(typedef\s+_Align_type<)::/$1 -DNDEBUG -U__EXCEPTIONS -D__coverity_undefine___EXCEPTIONS -D__FAR_RUNTIME_ATTRIBUTE__=__near_func -U__FOR_DEBUG__ -D__coverity_undefine___FOR_DEBUG__ -D__LITTLE_ENDIAN__=1 -U__PLACEMENT_DELETE -D__coverity_undefine___PLACEMENT_DELETE -U__RTTI -D__coverity_undefine___RTTI -U__STDC_VERSION__ -D__coverity_undefine___STDC_VERSION__ -U__coverity_undefine___STDC_VERSION__ -D__coverity_undefine___coverity_undefine___STDC_VERSION__ -U__cpp_exceptions -D__coverity_undefine___cpp_exceptions -U__cpp_rtti -D__coverity_undefine___cpp_rtti --type_sizes=dex8Pfilw4s2 --type_alignments=dex8Pfilw4s2 --size_t_type=j --ptrdiff_t_type=i /home/repo/.jenkins/workspace/xxx/src/nodynalloc/new_del.cpp
[73393] EXECUTING: /bin/mount
"/opt/iarsystems/bxarm-9.30.1/arm/inc/c/xstddef0", line 16: warning #59:
function call is not allowed in a constant expression
#if _HAS_NOEXCEPT || !_HAS_EXCEPTIONS
^
[73399] EXECUTING: grep dev
"/opt/iarsystems/bxarm-9.30.1/arm/inc/c/xstddef0", line 16: warning #59:
function call is not allowed in a constant expression
#if _HAS_NOEXCEPT || !_HAS_EXCEPTIONS
^
[73398] EXECUTING: /bin/mount
"/opt/iarsystems/bxarm-9.30.1/arm/inc/c/xstddef0", line 16: warning #59:
function call is not allowed in a constant expression
#if _HAS_NOEXCEPT || !_HAS_EXCEPTIONS
^
"/opt/iarsystems/bxarm-9.30.1/arm/inc/c/yvals.h", line 159: warning #59:
function call is not allowed in a constant expression
#if _HAS_NOEXCEPT
^
"/opt/iarsystems/bxarm-9.30.1/arm/inc/c/xstddef0", line 16: warning #59:
function call is not allowed in a constant expression
#if _HAS_NOEXCEPT || !_HAS_EXCEPTIONS
^
"/opt/iarsystems/bxarm-9.30.1/arm/inc/c/xmemnew", line 7: warning #59: function
call is not allowed in a constant expression
#if __has_feature(cxx_noexcept)
^
"/opt/iarsystems/bxarm-9.30.1/arm/inc/c/xmemnew", line 7: warning #59: function
call is not allowed in a constant expression
#if __has_feature(cxx_noexcept)
^
[73403] EXECUTING: /bin/mount
[73404] EXECUTING: grep dev
"/opt/iarsystems/bxarm-9.30.1/arm/inc/c/xmemnew", line 7: warning #59: function
call is not allowed in a constant expression
#if __has_feature(cxx_noexcept)
...
2022-10-20T13:38:39.392031Z|cov-build|66594|info|> Invoking cov-security-da with commands: /opt/coverity/cov-analysis-2022-3/bin/cov-security-da --dir /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc
2022-10-20T13:38:39.401624Z|cov-build|66594|info|> Dynamic analyzer took 9 ms
2022-10-20T13:38:39.401624Z|cov-build|66594|info|> Build time (cov-build overall): 00:00:28.195804
2022-10-20T13:38:39.401624Z|cov-build|66594|info|>
2022-10-20T13:38:39.402216Z|cov-build|66594|info|> Build time (C/C++ emits total): 00:06:17.288925
2022-10-20T13:38:39.402216Z|cov-build|66594|info|>
2022-10-20T13:38:39.402216Z|cov-build|66594|info|>
2022-10-20T13:38:39.402240Z|cov-build|66594|info|> Emitted 15 C/C++ compilation units (100%) successfully
2022-10-20T13:38:39.402240Z|cov-build|66594|info|> [WARNING] Recoverable errors were encountered during 12 of these C/C++ compilation units.
2022-10-20T13:38:39.402240Z|cov-build|66594|info|>
2022-10-20T13:38:39.402240Z|cov-build|66594|info|> 15 C/C++ compilation units (100%) are ready for analysis
2022-10-20T13:38:39.402240Z|cov-build|66594|info|> For more details, please look at:
2022-10-20T13:38:39.402240Z|cov-build|66594|info|> /home/repo/.jenkins/workspace/xxx/build/test/icc/build/test/icc/build-log.txt
</code></pre>
| [
{
"answer_id": 74208975,
"author": "Apostolos",
"author_id": 1121008,
"author_profile": "https://Stackoverflow.com/users/1121008",
"pm_score": 0,
"selected": false,
"text": "postgres"
},
{
"answer_id": 74208978,
"author": "R4ncid",
"author_id": 14326899,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7200859/"
] |
74,208,618 | <p>I've a dynamic dataframe of the following pattern:</p>
<pre><code>structure(list(Date = structure(c(19304, 19305, 19311,
19311, 19312), class = "Date"), Category = c("4",
"6", "1", "0", "3"), Units_Sold = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_), Raised = c(NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_), Method = c("Trad",
"Trad", "Unknown", "Trad", "Unknown"), Day = c(8, 9, 15, 15, 16)), row.names = c(NA,
-5L), class = c("tbl_df", "tbl", "data.frame"))
</code></pre>
<p>As you can probably see, there's two categories that have the same date. What I'd like to do is create a condition: if there are two rows with the same date, the df will be subsetted (say call it df_copy), and in that new df, one of the rows will be dropped and the contents of the "Category" column will be changed to say "Check Dataframe", and the "Method" column will be changed to say "Attention". Any advice most appreciated.</p>
<p>In answer to the question, I'd the dataframe to look something like this:</p>
<pre><code>tibble [5 x 6] (S3: tbl_df/tbl/data.frame)
$ Date : Date[1:5], format: "2022-11-08" "2022-11-09" "2022-11-15" "2022-11-16"
$ Category: chr [1:5] "4" "6" "Check Dataframe" "3"
$ Units_Sold: num [1:5] NA NA NA NA
$ Raised: num [1:5] NA NA NA NA
$ Method : chr [1:5] "Trade" "Trad" "Attention" "Unknown"
$ Day: num [1:5] 8 9 15 15 16
</code></pre>
<p>If possible would it be possible to create a bool object to check against, so if there is more than 1 row with the same date, a 'checker' object will = 1?</p>
| [
{
"answer_id": 74208888,
"author": "akrun",
"author_id": 3732271,
"author_profile": "https://Stackoverflow.com/users/3732271",
"pm_score": 2,
"selected": false,
"text": "if/else"
},
{
"answer_id": 74208889,
"author": "zephryl",
"author_id": 17303805,
"author_profile":... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17081051/"
] |
74,208,638 | <p>This is what it looks like, and the arrow kind of shows where I wish for the image to be.
<a href="https://i.stack.imgur.com/XKIdQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XKIdQ.png" alt="What it looks like" /></a></p>
<p>my html code</p>
<pre><code> <section class="box2">
<h1 class="underline"><b>Husk dit helbred!</b></h1>
<p>Projekt arbejde er vigtigt, men ikke lige så vigtigt som dit helbred! Husk at drikke vand, at spise noget og at tage en masse pauser. Du bliver mere produktiv, hvis du skaber et sundt forhold til dit studie arbejde og helbred. Det var alt fra mig, held og lykke med jeres mange fremtide projekter!</p>
<img src="images/emilybillede.jpg" alt="">
</code></pre>
<p>my css code</p>
<pre><code>.underline {
text-decoration: underline;
}
.box2 img{
position: right;
width: 200px;
height: 200px;
}
.box2 {
margin: 0 auto;
margin-right: 20%;
margin-left: 20%;
margin-top: 20px;
background-color: rgb(255, 255, 255);
padding: 15px;
height: 50%;
}
p {
width: 300px;
}
</code></pre>
<p>I tried float as well but that takes it out of the padding.
<a href="https://i.stack.imgur.com/tq1or.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tq1or.png" alt="float right" /></a>
I also tried vertical align
<a href="https://i.stack.imgur.com/k0zvR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k0zvR.png" alt="result of vertical-align" /></a></p>
| [
{
"answer_id": 74208888,
"author": "akrun",
"author_id": 3732271,
"author_profile": "https://Stackoverflow.com/users/3732271",
"pm_score": 2,
"selected": false,
"text": "if/else"
},
{
"answer_id": 74208889,
"author": "zephryl",
"author_id": 17303805,
"author_profile":... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10727168/"
] |
74,208,663 | <p>I am new to PSQL so I am sorry if it's a silly mistake, but I am having the following problem.
I am trying to make a list that show the user and the places that they haven't gone to in at least 6 months.
Here is the code that I am using:</p>
<pre><code>SELECT pk_user_id,pk_place_id,
AGE('2023-05-26',date) AS test
FROM visit
WHERE test > 6;
</code></pre>
<p>I also tried this one:</p>
<pre><code>
SELECT pk_user_id,pk_place_id,
AGE('2023-05-26',date) AS test
FROM visit
HAVING test > 6;
</code></pre>
<p>And here is the code for the table:</p>
<pre><code>CREATE SCHEMA code
CREATE TABLE code.place (
pk_place_id VARCHAR(8),
place_name VARCHAR (50),
CONSTRAINT pk_place_id PRIMARY KEY (pk_place_id)
);
CREATE TABLE code.user (
pk_user_id VARCHAR(3),
user_name VARCHAR (50),
CONSTRAINT pk_user_id PRIMARY KEY (pk_user_id)
);
CREATE TABLE code.visit (
pk_user_id VARCHAR(3),
pk_place_id VARCHAR(8),
data DATE,
CONSTRAINT pk_user_id FOREIGN KEY (pk_user_id) REFERENCES code.user,
CONSTRAINT pk_place_id FOREIGN KEY (pk_place_id) REFERENCES code.place
);
</code></pre>
<p>The problem is that when I use this code it says that the column test doesn't exist.</p>
| [
{
"answer_id": 74208888,
"author": "akrun",
"author_id": 3732271,
"author_profile": "https://Stackoverflow.com/users/3732271",
"pm_score": 2,
"selected": false,
"text": "if/else"
},
{
"answer_id": 74208889,
"author": "zephryl",
"author_id": 17303805,
"author_profile":... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20333201/"
] |
74,208,678 | <p>I want to split an array to sets of 2, having <code>teachers</code> in own chunk if it exist and never have a single item chunk at the end.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const perChunk = 2 // items per chunk
const inputArray = ['teachers', 'art', 'science', 'math', 'language', 'culture']
const result = inputArray.reduce((resultArray, item, index) => {
const chunkIndex = Math.floor(index/perChunk)
if(!resultArray[chunkIndex]) {
resultArray[chunkIndex] = [] // start a new chunk
}
resultArray[chunkIndex].push(item)
return resultArray
}, [])
console.log(result);</code></pre>
</div>
</div>
</p>
<p>for example:</p>
<pre><code>['teachers']
['art', 'science']
['math', 'language', 'culture']
</code></pre>
| [
{
"answer_id": 74209070,
"author": "Woohaik",
"author_id": 17200950,
"author_profile": "https://Stackoverflow.com/users/17200950",
"pm_score": 2,
"selected": true,
"text": "const inputArray = ['teachers', 'art', 'science', 'math', 'language', 'culture']\n\nconst arrDivider = (arr, perChu... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4576720/"
] |
74,208,679 | <p>I'm trying to simplify the code of threads below:</p>
<pre class="lang-py prettyprint-override"><code>import threading
def test1():
print("test1")
def test2():
print('test2')
thread1 = threading.Thread(target=test1)
thread2 = threading.Thread(target=test2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
</code></pre>
<p>So, I want to simplify this part of code below to:</p>
<pre class="lang-py prettyprint-override"><code># ...
thread1 = threading.Thread(target=test1)
thread2 = threading.Thread(target=test2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
</code></pre>
<p>Something like one line of code below:</p>
<pre class="lang-py prettyprint-override"><code># ...
threading.Threads(test1, test2).start().join()
</code></pre>
<p>Are there any ways to do this? and it's ok if it's not one line of code as long as it's simpler.</p>
| [
{
"answer_id": 74208786,
"author": "Omer Dagry",
"author_id": 15010874,
"author_profile": "https://Stackoverflow.com/users/15010874",
"pm_score": 0,
"selected": false,
"text": "import threading\n\nthreads_list = []\nfor i in range(thread_count)\n thread = threading.Thread(target=targe... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8172439/"
] |
74,208,685 | <p>I am getting data from a table in my database and rendering it onto the screen as cards. However, the cards are all appearing on the left side of the screen in one long column instead of in 3s in a row as I would like them to appear.</p>
<p>My current code is here:</p>
<p>I've tried using <code>card-deck</code> which made it so that the cards were 3 in a row, but the cards were repeated (i.e. the data they held was repeated). I would like the data to not repeat, how can I achieve this?</p>
| [
{
"answer_id": 74208786,
"author": "Omer Dagry",
"author_id": 15010874,
"author_profile": "https://Stackoverflow.com/users/15010874",
"pm_score": 0,
"selected": false,
"text": "import threading\n\nthreads_list = []\nfor i in range(thread_count)\n thread = threading.Thread(target=targe... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20198370/"
] |
74,208,715 | <p>I try to create a task from a MailItem using VBA in Outlook 2019.
According to the <a href="https://learn.microsoft.com/en-us/office/vba/api/outlook.attachments.add" rel="nofollow noreferrer">docu for Attachment.Add</a>:</p>
<blockquote>
<p>Position Optional Long: This parameter applies only to email
messages using the Rich Text format: it is the position where the
attachment should be placed within the body text of the message. A
value of 1 for the Position parameter specifies that the attachment
should be positioned at the beginning of the message body. A value 'n'
greater than the number of characters in the body of the email item
specifies that the attachment should be placed at the end. A value of
0 makes the attachment hidden.</p>
</blockquote>
<p>However, if I use position 1 (see below), the icon with the link to the original mail will still be at the end of the body instead at beginning. Am I missing something?</p>
<pre><code>Sub CreateTask()
Set olApp = Outlook.Application
Set Msg = olApp.ActiveExplorer.Selection.Item(1)
Dim olTask As TaskItem
Set olTask = olApp.CreateItem(olTaskItem)
With olTask
.Subject = Msg.Subject
.RTFBody = Msg.RTFBody
.Attachments.Add Msg, , 1 ' For some reasone position argument not working :(
'.Save
.Display
End With
End If
</code></pre>
| [
{
"answer_id": 74209746,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 0,
"selected": false,
"text": "MailItem"
},
{
"answer_id": 74210161,
"author": "niton",
"author_id": 1571407,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1627996/"
] |
74,208,726 | <p>This question is related to Neo4j databases. Suppose I have a relationship (employee)-[WORKS-IN]->(company).. Imagine an employee works in multiple companies. I should be able to find the companies that a specific employee is working using full text search in neo4j. I'll be searching from the users name and I should be able to return company nodes..how to do that??</p>
<p>Full text search must be used.</p>
| [
{
"answer_id": 74209746,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 0,
"selected": false,
"text": "MailItem"
},
{
"answer_id": 74210161,
"author": "niton",
"author_id": 1571407,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339889/"
] |
74,208,732 | <p>I have a SQL query which I am trying to convert into PySpark. In SQL query, we are joining <em>three</em> tables and updating a column where there's a match. The SQL query looks like this:</p>
<pre class="lang-sql prettyprint-override"><code>UPDATE [DEPARTMENT_DATA]
INNER JOIN ([COLLEGE_DATA]
INNER JOIN [STUDENT_TABLE]
ON COLLEGE_DATA.UNIQUEID = STUDENT_TABLE.PROFESSIONALID)
ON DEPARTMENT_DATA.PUBLICID = COLLEGE_DATA.COLLEGEID
SET STUDENT_TABLE.PRIVACY = "PRIVATE"
</code></pre>
<p>The logic I have tried:</p>
<pre class="lang-py prettyprint-override"><code>df_STUDENT_TABLE = (
df_STUDENT_TABLE.alias('a')
.join(
df_COLLEGE_DATA('b'),
on=F.col('a.PROFESSIONALID') == F.col('b.UNIQUEID'),
how='left',
)
.join(
df_DEPARTMENT_DATA.alias('c'),
on=F.col('b.COLLEGEID') == F.col('c.PUBLICID'),
how='left',
)
.select(
*[F.col(f'a.{c}') for c in df_STUDENT_TABLE.columns],
F.when(
F.col('b.UNIQUEID').isNotNull() & F.col('c.PUBLICID').isNotNull()
F.lit('PRIVATE')
).alias('PRIVACY')
)
)
</code></pre>
<p>This code is adding a new column "PRIVACY", but giving null values after running.</p>
| [
{
"answer_id": 74209746,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 0,
"selected": false,
"text": "MailItem"
},
{
"answer_id": 74210161,
"author": "niton",
"author_id": 1571407,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20216373/"
] |
74,208,798 | <p>When using std::async, what is the best way to set priority? I realize this is platform dependent, but with a posix compliant operating system, would this work?</p>
<pre><code>// Launch task with priority 8
auto future = std::async(std::launch::async, // async policy required
[] ()
{
pthread_setschedprio(pthread_self(), 8);
// do work
});
</code></pre>
<p>I've found answers about std::thread, but not for std::async.</p>
<p><strong>Edit</strong>. In my case I am on a QNX operating system. So I believe setting the priority like I've done above is valid. However, it does seem like there are valid concerns raised about whether or not the priority will persist after the async task is complete (depending how async is implemented).</p>
<p><strong>Edit2</strong> Potential options seem to be...</p>
<ul>
<li>Leverage std::thread (perhaps with a thread pool) to keep explicitly managed threads at a given priority</li>
<li>Justify in my situation that setting the priority is not necessary.</li>
<li>Create an RAII class to change priority back to the original at the end of the async launched lambda.</li>
</ul>
| [
{
"answer_id": 74209746,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 0,
"selected": false,
"text": "MailItem"
},
{
"answer_id": 74210161,
"author": "niton",
"author_id": 1571407,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74208798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5374468/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.