qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,294,299 | <p>I am reading "Category Theory for Programmers" By Bartosz Milewski and on pg. 164 he introduces a natural transformation for the Reader Functor:</p>
<pre><code>newtype Reader e a = Reader (e -> a)
instance Functor (Reader e) where
fmap f (Reader g) = Reader (\x -> f (g x))
</code></pre>
<p>I am having a difficult time understanding the type signature of this transformation.</p>
<p>My best guess is something like:</p>
<pre><code>fmap :: (a -> b) -> (Reader e -> a) -> (Reader e -> b)
</code></pre>
<p>I am confused that the functor is declared with Reader partially applied <code>Reader e</code> and then on line two there <code>f</code> and <code>g</code> which are the two function arguments. Then, there is a lambda expression with <code>x</code>. Since there is no value for <code>x</code>, I assume the <code>Reader(\x -> ....)</code> lambda expression is partially applied. Does <code>x</code> refer to some outside value? Where does <code>e</code> come into play?</p>
<p>So, how does the fmap instance satisfy <code>fmap => (a->b) -> f a -> f b</code>?</p>
| [
{
"answer_id": 74294435,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 2,
"selected": false,
"text": "f ~ Reader e"
},
{
"answer_id": 74294484,
"author": "chepner",
"author_id": 1126841,
"author_profile": "https://Stackoverflow.com/users/1126841",
"pm_score": 4,
"selected": true,
"text": "Reader"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18943614/"
] |
74,294,302 | <p>I am trying to build a table in Latex that one column which in my case in "Factor Loading" has three subcolumns, and also text in the "Item" column to be wrapped if it too big.</p>
<p><a href="https://i.stack.imgur.com/Wbhxn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wbhxn.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74294435,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 2,
"selected": false,
"text": "f ~ Reader e"
},
{
"answer_id": 74294484,
"author": "chepner",
"author_id": 1126841,
"author_profile": "https://Stackoverflow.com/users/1126841",
"pm_score": 4,
"selected": true,
"text": "Reader"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19384556/"
] |
74,294,327 | <p>To be honest, I have no idea why the variable is being set to null. The object is set, then once I go through the DisplayPromptAsync, it sets the object to null.</p>
<p>I'm not sure what to try as I've never come across this issue.</p>
<p>Here's a gif of the issue. Once I enter into the field and press submit, an object gets reset.
<a href="https://i.stack.imgur.com/WR3b9.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WR3b9.gif" alt="enter image description here" /></a></p>
<pre><code>async void OpenContainerItem()
{
// Pause the timer
blnTimerActive = false;
if (SelectedItem != null)
{
if (SelectedItem.intQuanChecked == SelectedItem.intQuantity)
return;
try
{
int intQuantity = 0;
// Ask for quantity
string result = await Application.Current.MainPage.DisplayPromptAsync("Quantity",
"How many " + SelectedItem.objItem.strItemName + " did you count?",
"Okay", cancel: "Cancel",
placeholder: "Quantity",
keyboard: Keyboard.Numeric);
// Check if it's been cancelled
if (result != null)
{
// check if theres nothing entered
if (result == "")
{
// Why tho?
await Application.Current.MainPage.DisplayAlert("Error", "Please enter a quantity.", "Okay");
}
else
{
intQuantity = int.Parse(result);
if (0 > ((SelectedItem.intQuantity - SelectedItem.intQuanChecked) - intQuantity))
{
Application.Current.MainPage.DisplayAlert("Error", "Thats too many items!", "Okay");
Reload();
blnTimerActive = true;
return;
}
modDatabaseUtilities.ContainerItemsPreCheck(SelectedItem.intContainerItemID, intQuantity, strCurrentUser);
Reload();
}
}
}
catch(Exception ex)
{
Application.Current.MainPage.DisplayAlert("Error", "Couldn't process this change. Please try again.", "Okay");
}
}
</code></pre>
| [
{
"answer_id": 74294435,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 2,
"selected": false,
"text": "f ~ Reader e"
},
{
"answer_id": 74294484,
"author": "chepner",
"author_id": 1126841,
"author_profile": "https://Stackoverflow.com/users/1126841",
"pm_score": 4,
"selected": true,
"text": "Reader"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8436138/"
] |
74,294,345 | <p>I'm trying to make a scan of an array where it follows the index with the numbers inside and I don't understand why it gives me this exception. I cant add any more details its a pretty straight forward question.
<a href="https://i.stack.imgur.com/1Gxp3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Gxp3.png" alt="this is a perfect scan for exsample" /></a>
<a href="https://i.stack.imgur.com/NZ3EG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NZ3EG.png" alt="this is NOT a perfect scan" /></a></p>
<pre><code>using System;
public class Program
{
public static bool IsPerfect(int[] arr)
{
int next=0, done=0,i;
while (done == 0)
{
i = arr[next];
arr[next] = 10;
next = arr[i];
if (i == 0)
done = 1;
}
for(int j = 0; j < arr.Length; j++)
if (arr[j] != 10)
return false;
return true;
}
public static void Main()
{
int[] arr = { 3, 0, 1, 4, 2 };
if (IsPerfect(arr) == true)
Console.WriteLine("is perfect");
if (IsPerfect(arr) == false)
Console.WriteLine("boooo");
}
}
</code></pre>
| [
{
"answer_id": 74294435,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 2,
"selected": false,
"text": "f ~ Reader e"
},
{
"answer_id": 74294484,
"author": "chepner",
"author_id": 1126841,
"author_profile": "https://Stackoverflow.com/users/1126841",
"pm_score": 4,
"selected": true,
"text": "Reader"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16028638/"
] |
74,294,361 | <p>I can define an interval with <code>start</code> and <code>end</code> in the format <code>YYMMDD</code>, but they can also be partial/periodic - meaning some elements (day, month or year) can be left blank.</p>
<p>For example, <code>start = " 1115"</code> and <code>end = " 0115"</code> the interval is 15th nov to 15th jan every year.</p>
<p>I want to check if a non-partial date is in the interval.</p>
<pre class="lang-cpp prettyprint-override"><code>int compareParial(const char* first, const char* second)
{
for (int i = 0; i < 6; ++i)
{
if (first[i] != ' ' && second[i] != ' ' && first[i] != second[i])
return first[i] > second[i] ? 1 : -1;
}
return 0;
}
bool isDateInInterval(const char* start, const char* end, const char* searchDate)
{
int firstCompare = compareParial(start, searchDate);
int endCompare = compareParial(end, searchDate);
if (firstCompare <= 0 && endCompare >= 0)
return true;
// the date can still be in the interval if the start of the interval is in one year, but end in the next year
bool switched = 0 < compareParial(start, end);
if (switched && (firstCompare <= 0) != (endCompare >= 0))
return true;
return false;
}
int main()
{
cout << boolalpha << isDateInInterval(" 1115", " 0115", "251110") << endl;
return 0;
}
</code></pre>
<p>Update: If the dates are reversed check again if <code>searchDate</code> is in.</p>
<p>A problem I notice is what if <code>start</code> and <code>end</code> are reversed but the year is provided. For example: <code>isDateInInterval("200105", "190601", "251110")</code> would be <code>true</code></p>
| [
{
"answer_id": 74296832,
"author": "Howard Hinnant",
"author_id": 576911,
"author_profile": "https://Stackoverflow.com/users/576911",
"pm_score": 2,
"selected": false,
"text": "year"
},
{
"answer_id": 74393366,
"author": "Miklos",
"author_id": 5996671,
"author_profile": "https://Stackoverflow.com/users/5996671",
"pm_score": 0,
"selected": false,
"text": "bool switched = 0 < compareParial(start, end);\nif (start[0]==' ' && switched && (firstCompare <= 0) != (endCompare >= 0))\n return true;\n\nreturn false;\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7162318/"
] |
74,294,377 | <p>I am using SpaCy and SpaCy Stanza in Jupyter notebook with python 3, and I get the following error</p>
<pre><code>OSError: /opt/conda/lib/python3.7/site-packages/torch/lib/../../nvidia/cublas/lib/libcublas.so.11: undefined symbol: cublasLtHSHMatmulAlgoInit, version libcublasLt.so.11
</code></pre>
<p>can anybody help me?</p>
<p>I tried update</p>
<pre><code>pip install --user nvidia-pyindexpip install --user nvidia-tensorflow
</code></pre>
<p>but the error remains, How can I fix it?</p>
| [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14803530/"
] |
74,294,389 | <p>I need to recreate a function in R that creates a matrix out of a vector, given columns/rows and columnnames/rownames without using the characteristics of matrix().</p>
<p>I also need to add that if only a singular number is passed as a vector a matrix of given rows and columns is created with each entry being the passed number.</p>
<p>I tried using the dim() function but I'm not very familiar with it's usage. For example the function does not work if 1 is passed as the amount of rows or columns. My code looks the following:</p>
<pre><code>matrix_by_hand <- function(v, nrow = NULL, ncol = NULL, row_names = NULL, col_names = NULL) {
if (is.null(nrow)) {
dim(v) <- (length(v)/ncol):ncol
} else if (is.null(ncol)) {
dim(v) <- (nrow:(length(v)/nrow))
}
if (!is.null(row_names)) {
rownames(v) <- row_names
}
if (!is.null(col_names)) {
colnames(v) <- col_names
}
print(v)
}
</code></pre>
| [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12020902/"
] |
74,294,395 | <p>I created both client and server certificates:</p>
<pre class="lang-bash prettyprint-override"><code># client
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out ssl/client.crt -keyout ssl/client.key
# server
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out ssl/server.crt -keyout ssl/server
</code></pre>
<p>Then with python I have the following:</p>
<pre class="lang-py prettyprint-override"><code>import requests
response = requests.get(
"https://localhost:8080/",
verify="ssl/server.crt",
cert=("ssl/client.crt", "ssl/client.key")
)
</code></pre>
<p>I also have a <code>gunicorn</code> server running with the server self signed certificate.</p>
<p>The code snippet is throwing me the following error:</p>
<pre><code>requests.exceptions.SSLError: HTTPSConnectionPool(host='localhost', port=8080): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:2633)')))
</code></pre>
<p>It is a self signed certificate so I am not sure what <code>CA</code> is it expecting.</p>
| [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9187350/"
] |
74,294,398 | <p>I defined a <code>display</code> function to display the content of a queue:</p>
<pre class="lang-c prettyprint-override"><code>void display(queue_t* s) {
queue_t* c = s;
int i = c->size;
while (i > 0) {
const char* elem = dequeue(c).value;
printf("Item n°%d : %s\n",i,elem);
i--;
};
};
</code></pre>
<p>where <code>queue_t</code> is defined as follow:</p>
<pre class="lang-c prettyprint-override"><code>typedef struct queue {
node_t* head;
node_t* tail;
int size;
} queue_t;
</code></pre>
<p>and <code>dequeue</code> is a function that removes a node from the queue and frees it. This function works as intended.</p>
<p>The function <code>display</code> should display the content of the queue without deleting its content but when testing it, the queue is empty if I call display before removing each element one by one by hand by calling <code>dequeue</code>. I thought that <code>queue_t* c = s;</code> would copy the element without any link between <code>c</code> and <code>s</code>.</p>
<p><strong>How can I copy the content of <code>s</code> into <code>c</code> without any link between the two variables ?</strong></p>
<hr />
<p><strong>EDIT</strong> - MWE</p>
<p>Header file - <code>queue.h</code></p>
<pre class="lang-c prettyprint-override"><code>#ifndef QUEUE_H
#define QUEUE_H
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
typedef struct element {
bool type;
const char* value;
} element_t;
typedef struct node {
element_t content;
struct node* previous;
struct node* next;
} node_t;
typedef struct queue {
node_t* head;
node_t* tail;
int size;
} queue_t;
queue_t* init_queue(void);
node_t* init_node(element_t e);
void queue(queue_t* s, element_t e);
element_t dequeue(queue_t* s);
void display(queue_t* s);
#endif
</code></pre>
<p>Source code - <code>queue.c</code></p>
<pre><code>#include "queue.h"
queue_t* init_queue(void) {
queue_t* new = (queue_t*)malloc(sizeof(queue_t));
new->head = NULL;
new->tail = NULL;
new->size = 0;
return new;
};
node_t* init_node(element_t e) {
node_t* new = (node_t*)malloc(sizeof(node_t));
new->content = e;
new->next = NULL;
new->previous = NULL;
return new;
};
void queue(queue_t* s, element_t e) {
node_t* n = init_node(e);
if (s->size == 0) {
s->head = n;
s->tail = n;
s->size = 1;
} else {
n->previous = s->tail;
s->tail = n;
s->size++;
};
};
element_t dequeue(queue_t* s) {
if (s->size == 0) {
element_t empty;
empty.type = true;
empty.value = "0";
return empty;
} if (s->size == 1) {
element_t c = s->head->content;
node_t* old = s->head;
s->head = NULL;
s->size = 0;
s->tail = NULL;
free(old);
return c;
} else {
element_t c = s->tail->content;
node_t* old = s->tail;
s->tail = s->tail->previous;
s->tail->next = NULL;
s->size--;
free(old);
return c;
};
};
void display(queue_t* s) {
queue_t* c = s;
int i = c->size;
while (i > 0) {
const char* elem = dequeue(c).value;
printf("Item n°%d : %s\n",i,elem);
i--;
};
};
</code></pre>
<p>Test file - <code>test.c</code></p>
<pre class="lang-c prettyprint-override"><code>#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include "queue.h"
int main(void) {
element_t e1 = {.type = false, .value = "1"};
element_t e2 = {.type = false, .value = "5"};
element_t e3 = {.type = false, .value = "10"};
queue_t* test = init_queue();
queue(test,e1);
queue(test,e2);
queue(test,e3);
display(test);
element_t e4 = dequeue(test);
printf("%s\n",e4.value);
element_t e5 = dequeue(test);
printf("%s\n",e5.value);
element_t e6 = dequeue(test);
printf("%s\n",e6.value);
element_t e7 = dequeue(test);
printf("%s\n",e7.value);
return 0;
}
</code></pre>
<p>Run the test file using</p>
<pre class="lang-bash prettyprint-override"><code>gcc -g -std=c99 -Wall -o test.o -c test.c
gcc -g -std=c99 -Wall -o queue.o -c queue.c
gcc -g -std=c99 -Wall -o test queue.o test.o
</code></pre>
| [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16585917/"
] |
74,294,413 | <p>I have a list of objects in an array. Each object has an email.</p>
<p>The array could have duplicate emails and I want to keep them.</p>
<p>I want to give a number let's say 4 and it should split the emails into groups of 4 emails into a map where the key is like group-1 ... and the value 4 unique emails in each key
in this case I will have a map of 5 keys</p>
<pre><code>const emails=[{userId:'someuserid',email:'email1@gmail.com',password:'password1',recovery:'recovery1@gmail.com'},{userId:'someuserid',email:'email1@gmail.com',password:'password1',recovery:'recovery1@gmail.com'},{userId:'someuserid',email:'email10@gmail.com',password:'password10',recovery:'recovery10@gmail.com'},{userId:'someuserid',email:'email10@gmail.com',password:'password10',recovery:'recovery10@gmail.com'},{userId:'someuserid',email:'email2@gmail.com',password:'password2',recovery:'recovery2@gmail.com'},{userId:'someuserid',email:'email2@gmail.com',password:'password2',recovery:'recovery2@gmail.com'},{userId:'someuserid',email:'email3@gmail.com',password:'password3',recovery:'recovery3@gmail.com'},{userId:'someuserid',email:'email3@gmail.com',password:'password3',recovery:'recovery3@gmail.com'},{userId:'someuserid',email:'email4@gmail.com',password:'password4',recovery:'recovery4@gmail.com'},{userId:'someuserid',email:'email4@gmail.com',password:'password4',recovery:'recovery4@gmail.com'},{userId:'someuserid',email:'email5@gmail.com',password:'password5',recovery:'recovery5@gmail.com'},{userId:'someuserid',email:'email5@gmail.com',password:'password5',recovery:'recovery5@gmail.com'},{userId:'someuserid',email:'email6@gmail.com',password:'password6',recovery:'recovery6@gmail.com'},{userId:'someuserid',email:'email6@gmail.com',password:'password6',recovery:'recovery6@gmail.com'},{userId:'someuserid',email:'email7@gmail.com',password:'password7',recovery:'recovery7@gmail.com'},{userId:'someuserid',email:'email7@gmail.com',password:'password7',recovery:'recovery7@gmail.com'},{userId:'someuserid',email:'email8@gmail.com',password:'password8',recovery:'recovery8@gmail.com'},{userId:'someuserid',email:'email8@gmail.com',password:'password8',recovery:'recovery8@gmail.com'},{userId:'someuserid',email:'email9@gmail.com',password:'password9',recovery:'recovery9@gmail.com'},{userId:'someuserid',email:'email9@gmail.com',password:'password9',recovery:'recovery9@gmail.com'}]
const groupsMap = new Map()
let sequence = 0
let profilePrefix = 'none'
let pivotPrefix = 0
const prefix = 'group'
const bucketSize = 4
for (let index = 0; index < emails.length; index++) {
const currentEmail = emails[index]?.email
const prevEmail = emails[index - 1]?.email
if (prevEmail && currentEmail === prevEmail) {
if (
groupsMap.has(`${prefix}-${pivotPrefix}`) &&
groupsMap.get(`${prefix}-${pivotPrefix}`).length < bucketSize &&
groupsMap
.get(`${prefix}-${pivotPrefix}`)
.findIndex((email) => currentEmail === email.email) === -1
) {
groupsMap.get(`${prefix}-${pivotPrefix}`).push(emails[index])
if (
groupsMap.get(`${prefix}-${pivotPrefix}`).length === bucketSize
) {
pivotPrefix++
}
} else {
if (pivotPrefix > 0) {
const nextPivot = pivotPrefix++
groupsMap.get(`${prefix}-${nextPivot}`).push(emails[index])
}
sequence++
profilePrefix = `${prefix}-${sequence}`
groupsMap.set(profilePrefix, [emails[index]])
}
} else {
if (groupsMap.has(`${prefix}-${pivotPrefix}`)) {
if (
groupsMap.get(`${prefix}-${pivotPrefix}`).length < bucketSize
) {
groupsMap.get(`${prefix}-${pivotPrefix}`).push(emails[index])
if (
groupsMap.get(`${prefix}-${pivotPrefix}`).length ===
bucketSize
) {
pivotPrefix++
}
} else {
sequence++
groupsMap.set(`${prefix}-${sequence}`, [emails[index]])
}
} else {
sequence++
pivotPrefix = sequence
profilePrefix = `${prefix}-${pivotPrefix}`
groupsMap.set(profilePrefix, [emails[index]])
}
}
}
console.log(groupsMap)
// desired output below
Map(6) {
'group-0' => [
{
userId: 'someuserid',
email: 'email1@gmail.com',
password: 'password1',
recovery: 'recovery1@gmail.com'
},
{
userId: 'someuserid',
email: 'email10@gmail.com',
password: 'password10',
recovery: 'recovery10@gmail.com'
},
{
userId: 'someuserid',
email: 'email2@gmail.com',
password: 'password2',
recovery: 'recovery2@gmail.com'
},
{
userId: 'someuserid',
email: 'email3@gmail.com',
password: 'password3',
recovery: 'recovery3@gmail.com'
}
],
'group-1' => [
{
userId: 'someuserid',
email: 'email1@gmail.com',
password: 'password1',
recovery: 'recovery1@gmail.com'
},
{
userId: 'someuserid',
email: 'email10@gmail.com',
password: 'password10',
recovery: 'recovery10@gmail.com'
},
{
userId: 'someuserid',
email: 'email2@gmail.com',
password: 'password2',
recovery: 'recovery2@gmail.com'
},
{
userId: 'someuserid',
email: 'email3@gmail.com',
password: 'password3',
recovery: 'recovery3@gmail.com'
}
],
'group-2' => [
{
userId: 'someuserid',
email: 'email4@gmail.com',
password: 'password4',
recovery: 'recovery4@gmail.com'
},
{
userId: 'someuserid',
email: 'email5@gmail.com',
password: 'password5',
recovery: 'recovery5@gmail.com'
},
{
userId: 'someuserid',
email: 'email6@gmail.com',
password: 'password6',
recovery: 'recovery6@gmail.com'
},
{
userId: 'someuserid',
email: 'email7@gmail.com',
password: 'password7',
recovery: 'recovery7@gmail.com'
}
],
'group-3' => [
{
userId: 'someuserid',
email: 'email4@gmail.com',
password: 'password4',
recovery: 'recovery4@gmail.com'
},
{
userId: 'someuserid',
email: 'email5@gmail.com',
password: 'password5',
recovery: 'recovery5@gmail.com'
},
{
userId: 'someuserid',
email: 'email6@gmail.com',
password: 'password6',
recovery: 'recovery6@gmail.com'
},
{
userId: 'someuserid',
email: 'email7@gmail.com',
password: 'password7',
recovery: 'recovery7@gmail.com'
}
],
'group-4' => [
{
userId: 'someuserid',
email: 'email8@gmail.com',
password: 'password8',
recovery: 'recovery8@gmail.com'
},
{
userId: 'someuserid',
email: 'email9@gmail.com',
password: 'password9',
recovery: 'recovery9@gmail.com'
}
],
'group-5' => [
{
userId: 'someuserid',
email: 'email8@gmail.com',
password: 'password8',
recovery: 'recovery8@gmail.com'
},
{
userId: 'someuserid',
email: 'email9@gmail.com',
password: 'password9',
recovery: 'recovery9@gmail.com'
}
]
}
</code></pre>
| [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18472518/"
] |
74,294,425 | <p>I have a ngFor loop and I want to assign a unique class to each element but I have an already existing ngClass condition.</p>
<pre><code> <div class="b-game-card" *ngFor="let info of list" [ngClass]="{active: isActive(info)}">
<div class="b-game-card__cover"></div>
</div>
</code></pre>
<p>I tried adding <code>[ngClass]="{active: isActive(info), info.name}"</code>
but it didn't work for me.</p>
| [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5152892/"
] |
74,294,426 | <p>I have a column, <code>duration</code>, that represents a time <code>Interval</code> in <code>Milliseconds</code>.</p>
<p>It was previously calculated and then converted to <code>BIGINT</code> using <code>to_milliseconds</code> in order to save the results, since Hive doesn't accept <code>Interval</code> type.</p>
<p>Now, I'd like to convert it back to an <code>Interval</code>. I'm aware that I can use <code>date_add('millisecond', duration, ts_col)</code>, but I'd prefer to be able to use the <code>timestamp + duration</code> format that an <code>Interval</code> allows for.</p>
<p>The workaround I came up with is: <code>parse_duration(CAST(cs.duration AS VARCHAR) || 'ms')</code>, but this seems like it'll be rather inefficient...</p>
<p>Is there a better/built-in method somewhere in the documentation that I'm missing?</p>
<hr />
<pre class="lang-sql prettyprint-override"><code>SELECT duration
--, CAST(duration AS INTERVAL MILLISECOND)
, parse_duration(CAST(duration AS VARCHAR) || 'ms') AS duration_interval
, date_add('millisecond', duration, event_start_time) AS next_event
, event_start_time + parse_duration(CAST(duration AS VARCHAR) || 'ms') AS next_event_interval
FROM events
</code></pre>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: right;">duration</th>
<th style="text-align: left;">duration_interval</th>
<th style="text-align: left;">next_event</th>
<th style="text-align: left;">next_event_interval</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">1545</td>
<td style="text-align: left;">0 00:00:01.545</td>
<td style="text-align: left;">22-10-30 01:22:33.2233</td>
<td style="text-align: left;">22-10-30 01:22:33.2233</td>
</tr>
<tr>
<td style="text-align: right;">184</td>
<td style="text-align: left;">0 00:00:00.184</td>
<td style="text-align: left;">22-10-30 01:22:34.2234</td>
<td style="text-align: left;">22-10-30 01:22:34.2234</td>
</tr>
<tr>
<td style="text-align: right;">5033</td>
<td style="text-align: left;">0 00:00:05.033</td>
<td style="text-align: left;">22-10-30 01:22:39.2239</td>
<td style="text-align: left;">22-10-30 01:22:39.2239</td>
</tr>
<tr>
<td style="text-align: right;">1592</td>
<td style="text-align: left;">0 00:00:01.592</td>
<td style="text-align: left;">22-10-30 01:22:40.2240</td>
<td style="text-align: left;">22-10-30 01:22:40.2240</td>
</tr>
<tr>
<td style="text-align: right;">1011</td>
<td style="text-align: left;">0 00:00:01.011</td>
<td style="text-align: left;">22-10-30 01:22:29.2229</td>
<td style="text-align: left;">22-10-30 01:22:29.2229</td>
</tr>
<tr>
<td style="text-align: right;">2982</td>
<td style="text-align: left;">0 00:00:02.982</td>
<td style="text-align: left;">22-10-30 01:22:32.2232</td>
<td style="text-align: left;">22-10-30 01:22:32.2232</td>
</tr>
<tr>
<td style="text-align: right;">295</td>
<td style="text-align: left;">0 00:00:00.295</td>
<td style="text-align: left;">22-10-30 01:22:28.2228</td>
<td style="text-align: left;">22-10-30 01:22:28.2228</td>
</tr>
<tr>
<td style="text-align: right;">2556</td>
<td style="text-align: left;">0 00:00:02.556</td>
<td style="text-align: left;">22-10-30 01:22:43.2243</td>
<td style="text-align: left;">22-10-30 01:22:43.2243</td>
</tr>
<tr>
<td style="text-align: right;">687</td>
<td style="text-align: left;">0 00:00:00.687</td>
<td style="text-align: left;">22-10-30 01:22:44.2244</td>
<td style="text-align: left;">22-10-30 01:22:44.2244</td>
</tr>
<tr>
<td style="text-align: right;">3635</td>
<td style="text-align: left;">0 00:00:03.635</td>
<td style="text-align: left;">22-10-30 01:22:47.2247</td>
<td style="text-align: left;">22-10-30 01:22:47.2247</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11865956/"
] |
74,294,427 | <pre><code>#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main(){
int v[5];
int a[5][5];
int i = 0, j = 0;
for (i = 0; i < 5; i++){
v[i] = 0;
for (j = 0; j < 5; j++){
a[i][j] = 0;
cout << "A[" << i << ", " << j << "] = " << endl;
cin >> a[i][j];
v[i] = v[i] + a[i][j];
}
v[i] = v[i] / 5;
}
for (i = 0; i < 30; i++){
cout << "v[" << i << "] = " << v[i] << endl;
}
}
</code></pre>
<p>When I remove the <code>v[i] = 0</code> line just under the first loop the code runs but returns very large numbers. I don't understand how this is happening. Grateful for any help.</p>
<p>Edit: thanks you for all the replies. I think I understand why I got downvotes. To clarify, this is for a beginners course and we were given the bare-bones of the language mostly to train logic. The question itself is pretty nonsensical as it asks us to declare the array as a int despite the fact that the answer is distorted by integer division.</p>
| [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400800/"
] |
74,294,430 | <p>I have a dataset that is formatted like this:</p>
<pre><code>index string
1 2008
1 2009
1 2010
2
2
2
3 2008
3 2009
3 2010
4 2008
4 2009
4 2010
5
5
5
</code></pre>
<p>I would like to fill in the missing data with the same sequence like this:</p>
<pre><code>index string
1 2008
1 2009
1 2010
2 <-2008
2 <-2009
2 <-2010
3 2008
3 2009
3 2010
4 2008
4 2009
4 2010
5 <-2008
5 <-2009
5 <-2010
</code></pre>
<p>So the final result looks like this:</p>
<pre><code>index string
1 2008
1 2009
1 2010
2 2008
2 2009
2 2010
3 2008
3 2009
3 2010
4 2008
4 2009
4 2010
5 2008
5 2009
5 2010
</code></pre>
<p>I am currently doing this in excel and it is an impossible task because of the number of rows that need to be filled.</p>
<p>I tried using fillna(method = 'ffill', limit = 2, inplace = True), but this will only fill data with what is in the previous cell. Any help is appreciated.</p>
| [
{
"answer_id": 74347139,
"author": "Adenialzz",
"author_id": 14736110,
"author_profile": "https://Stackoverflow.com/users/14736110",
"pm_score": 2,
"selected": false,
"text": "LD_LIBRARY_PATH"
},
{
"answer_id": 74427275,
"author": "oklen",
"author_id": 8096359,
"author_profile": "https://Stackoverflow.com/users/8096359",
"pm_score": 1,
"selected": false,
"text": "pip show nvidia-cudnn\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20121171/"
] |
74,294,455 | <p>I am encrypting an array of files and using node streams to encrypt a file in chunk. I want to run a function after the encryption is done of all the files in the array but my function runs before the encryption has completed. I am using preload.js to expose the encryption function.</p>
<pre class="lang-js prettyprint-override"><code>//encrypt.js
const path = require("path");
const fs = require("fs");
const { pipeline } = require("stream/promises");
const { app } = require("./app.js");
async function encrypt(file) {
const fileReadStream = fs.createReadStream(file);
const filePath = path.parse(file).dir;
const fileName = path.parse(file).name;
const fileExt = path.parse(file).ext;
const EncFile = filePath + "/" + fileName + "_enc" + fileExt;
const fileWriteStream = fs.createWriteStream(EncFile);
await pipeline(
fileReadStream,
new Transform({
transform(chunk, encoding, callback) {
const encryptedData = app.encrypt(chunk, password);
callback(null, encryptedData);
console.log("File encrypted");
},
}),
fileWriteStream
);
}
module.exports.encrypt = encrypt;
</code></pre>
<pre class="lang-js prettyprint-override"><code>//preload.js
const { encrypt } = require('./encrypt.js');
contextBridge.exposeInMainWorld('encrypt', encrypt);
</code></pre>
<pre class="lang-js prettyprint-override"><code>const para = document.querySelector('#para-info');
const btn = document.querySelector('#btn');
btn.addEventListener("click", () => {
filesList.map(file => {
window.encrypt(file, password);
});
done();
}
// function i want to run after encryption is done
function done(){
para.innerText = 'Encryption Done';
}
</code></pre>
| [
{
"answer_id": 74294515,
"author": "David",
"author_id": 328193,
"author_profile": "https://Stackoverflow.com/users/328193",
"pm_score": 2,
"selected": true,
"text": "async"
},
{
"answer_id": 74294706,
"author": "Lureout",
"author_id": 8309111,
"author_profile": "https://Stackoverflow.com/users/8309111",
"pm_score": 0,
"selected": false,
"text": "const para = document.querySelector('#para-info');\nconst btn = document.querySelector('#btn');\nbtn.addEventListener(\"click\", async () => {\n const promises = filesList.map(file => window.encrypt(file, password);\n // Waits for every promise in list\n await Promise.all(promises);\n\n done();\n}\n\n// function i want to run after encryption is done\nfunction done(){\n para.innerText = 'Encryption Done';\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19556035/"
] |
74,294,458 | <p>Currently i am running a fetch call like this</p>
<pre class="lang-js prettyprint-override"><code>const url = "https://urlhere.com/initAPP/oauth2/authorize";
fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
"client_id": process.env.REACT_APP_CLIENT_ID,
"response_type": "code",
"provision_key": process.env.REACT_APP_PROVISION_KEY,
"authenticated_userid": process.env.REACT_APP_AUTHENTICATED_USERID
})
})
.then((response) => response.json())
.then((data) => {
console.log(data);
const redirect_uri = data.redirect_uri.toString();
const urlParams = new URLSearchParams(redirect_uri);
const code = urlParams.get('code')
}
)
</code></pre>
<p>so it all works fine until we try the url params. when i console log Data it returns like this:</p>
<pre><code>redirect_uri : "https://sitehere.sitehere.com?code=U78StlK6sN3hD9CO4ZogvpXvxezFSGU0"
</code></pre>
<p>when i console log the <code>redirect_uri</code> variable it prints out only the URL so that works fine</p>
<p>but when i try to deconstruct that URL that is returned with the <code>url params</code> part and try to get the CODE parameter in that url it just returns null. How can i get that specific parameter? am i not using the right variable?</p>
<p>Thanks!</p>
| [
{
"answer_id": 74294515,
"author": "David",
"author_id": 328193,
"author_profile": "https://Stackoverflow.com/users/328193",
"pm_score": 2,
"selected": true,
"text": "async"
},
{
"answer_id": 74294706,
"author": "Lureout",
"author_id": 8309111,
"author_profile": "https://Stackoverflow.com/users/8309111",
"pm_score": 0,
"selected": false,
"text": "const para = document.querySelector('#para-info');\nconst btn = document.querySelector('#btn');\nbtn.addEventListener(\"click\", async () => {\n const promises = filesList.map(file => window.encrypt(file, password);\n // Waits for every promise in list\n await Promise.all(promises);\n\n done();\n}\n\n// function i want to run after encryption is done\nfunction done(){\n para.innerText = 'Encryption Done';\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12727419/"
] |
74,294,486 | <p>I am trying to write a python script, using selenium, to go into a website (Salesforce.com) and change various input fields and take screenshots. However, I am running into issues when it comes to my organization's SSO interface. My URL redirects me first, to a sign-on page (which asks for org email), followed by a page that requires login credentials before I can access the dashboard I am looking for.</p>
<p>For the purpose of this dicsussion, I will call the sign-on page, page #1, and the login-in redirect page, page #2.</p>
<p>My selenium script is able to click on element in page #1 but is unable to do anything on page #2. I have already experimented with explicit and implicit waits. But I think the issue has to do with the redirect, which occurs in the same window/tab, and not a 'waiting' period for the page to load.</p>
<p>Here is my code:</p>
<pre><code>url = someurl.com
class MyTest(object):
def __init__(self):
self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
def login_process(self):
self.driver.get(url)
element = self.driver.find_element(By.ID, 'idp-discovery-username')
element.clear()
element.send_keys("israo@cisco.com")
self.driver.find_element(By.ID, 'idp-discovery-submit').submit()
self.driver.implicitly_wait(10)
# login_button = WebDriverWait(self.driver, 20).until(
# EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe[id$='IFrame_htmIFrame']"))
# )
def query(self):
self.driver.find_element(By.XPATH, '/html/body/div/div[2]/div[2]/article/form/input[6]')
test = MyTest()
test.login_process()
test.query()
</code></pre>
<p>I will also link inspected elements of both pages to help find a solution.</p>
<p>Thanks in advance.</p>
<p>Page #1, inspected
<img src="https://i.stack.imgur.com/z45d3.png" alt="" /></p>
<p>Page #2, inspected
<img src="https://i.stack.imgur.com/tYYPV.png" alt="" /></p>
<p>In the second image, the green box is what I am trying to access with:</p>
<p><code>self.driver.find_element(By.XPATH, '/html/body/div/div[2]/div[2]/article/form/input[6]'</code>)</p>
| [
{
"answer_id": 74294795,
"author": "Eugeny Okulik",
"author_id": 12023661,
"author_profile": "https://Stackoverflow.com/users/12023661",
"pm_score": 2,
"selected": true,
"text": "self.driver.implicitly_wait(10)"
},
{
"answer_id": 74294830,
"author": "raoyourboat",
"author_id": 13132761,
"author_profile": "https://Stackoverflow.com/users/13132761",
"pm_score": 0,
"selected": false,
"text": "self.driver.implicitly_wait(10)\n# login_button = WebDriverWait(self.driver, 20).until(\n# EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, \"iframe[id$='IFrame_htmIFrame']\"))\n# )\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13132761/"
] |
74,294,503 | <p>I am trying to use REGEX in Python to parse out a document. I want to replace all instances of * that appear within parentheses. eg ("A2OR01" * "A2OR02" * "A2OR03") to ("A2OR01" , "A2OR02" , "A2OR03").</p>
<p>So far I have tried (.+ (*) .+) but it only will match the last instance of the *. For example when I replace with the REGEX expression that I wrote I get ("A2OR01" * "A2OR02" , "A2OR03"). I need all instances of * that are surrounded by parentheses to be replaced not just the last. I want to ignore all the values between the parentheses as they can vary including whitespaces.</p>
| [
{
"answer_id": 74294795,
"author": "Eugeny Okulik",
"author_id": 12023661,
"author_profile": "https://Stackoverflow.com/users/12023661",
"pm_score": 2,
"selected": true,
"text": "self.driver.implicitly_wait(10)"
},
{
"answer_id": 74294830,
"author": "raoyourboat",
"author_id": 13132761,
"author_profile": "https://Stackoverflow.com/users/13132761",
"pm_score": 0,
"selected": false,
"text": "self.driver.implicitly_wait(10)\n# login_button = WebDriverWait(self.driver, 20).until(\n# EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, \"iframe[id$='IFrame_htmIFrame']\"))\n# )\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400649/"
] |
74,294,509 | <p>This is my first time with maps in ggplot. I need to create 90 distribution maps of plant species.</p>
<p>Thus I set the API to get the data from Plant of the World Online and the shp from World Geographical Scheme for Recording Plant Distributions <a href="https://github.com/tdwg/wgsrpd" rel="nofollow noreferrer">https://github.com/tdwg/wgsrpd</a></p>
<pre><code>require(kewr)#to connect to POWO APIs
#getting data from POWO
id.powo <- search_wcvp("Camellia japonica")
id.powo<- id.powo$results[[1]]$id
r <- lookup_powo(id.powo, distribution = TRUE)
native <- r$distribution$natives
introduced <- r$distribution$introduced
tdwg.native.name <- list()
for (i in 1:length(native)){
tdwg.native.name[[i]]<- native[[i]]$name
}
tdwg.native.name <- unlist(tdwg.native.name)
col.native <- c("#B8DE95") #pastel green for native
tdwg.introduced.name <- list()
for (i in 1:length(introduced)){
tdwg.introduced.code[[i]]<- introduced[[i]]$name
}
tdwg.introduced.name <- unlist(tdwg.introduced.code)
#col.introduced <- c("#9F6CCC") #pastel violet for introduced
#creating the map
install.packages("remotes")
remotes::install_github("barnabywalker/bazr")
library(bazr)
I downloaded the shp from https://github.com/tdwg/wgsrpd and then loaded in r
tdwg_level3.shp<- read_sf("/Users/...d/wgsrpd-master/level3/level3.shp")
tdwg_level3.shp.robinson<- st_transform(tdwg_level3.shp, crs ="+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
ggplot() +
geom_sf(data = tdwg_level3.shp.robinson)
</code></pre>
<p>From here problems starts, polygons form nord pole overlap and there is no matching
<a href="https://i.stack.imgur.com/63xdD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/63xdD.jpg" alt="enter image description here" /></a></p>
<p>In addition, the map looks crowded since the are for some region subregional division and there are isles that makes the map looks dirty. Lastly, there is no need for plotting antartica...</p>
<p>Thus, the desired output should look like this<br />
<a href="https://i.stack.imgur.com/QwQAz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QwQAz.png" alt="Distribution of the x species at country level" /></a></p>
<p>this map has been build using this script <a href="https://gist.github.com/valentinitnelav/065af8eba2d9455d9407e5d3890f6f86" rel="nofollow noreferrer">https://gist.github.com/valentinitnelav/065af8eba2d9455d9407e5d3890f6f86</a></p>
<p>I need to produce like 100 maps, one for each species. I'm going to list the code id.powo in a data frame column and looping the code then.</p>
<p>id.powo.list<- c("17414550-1", "296290-1", "263221-1")</p>
<p>Thank you</p>
| [
{
"answer_id": 74294795,
"author": "Eugeny Okulik",
"author_id": 12023661,
"author_profile": "https://Stackoverflow.com/users/12023661",
"pm_score": 2,
"selected": true,
"text": "self.driver.implicitly_wait(10)"
},
{
"answer_id": 74294830,
"author": "raoyourboat",
"author_id": 13132761,
"author_profile": "https://Stackoverflow.com/users/13132761",
"pm_score": 0,
"selected": false,
"text": "self.driver.implicitly_wait(10)\n# login_button = WebDriverWait(self.driver, 20).until(\n# EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, \"iframe[id$='IFrame_htmIFrame']\"))\n# )\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20215005/"
] |
74,294,511 | <p>I'm learning R in my Data-Driven Business course at my university, so it's brand new to me. I'm making a data project that analyzes data from a .csv file.</p>
<p>I have tried this, and it doesn't provide me with the right kind of result.</p>
<p>My problem is removing rows based on values from the column "Year_Birth".<br />
I have tried:</p>
<pre><code># Read a csv file using read.csv()
csv_file = read.csv(file = "filtered_data.csv",
stringsAsFactors = FALSE, header = TRUE)
BabyBoomer = csv_file$Year_Birth[ csv_file$Year_Birth >= 1946 & csv_file$Year_Birth <= 1964]
head(BabyBoomer)
print::
[1] 1957 1954 1959 1952 1946 1946
y = csv_file$Year_Birth[csv_file$Year_Birth <= 1964]
BabyBoomer <- csv_file[-c(y), ]
head(BabyBoomer)
print:: df but without something changed
</code></pre>
<p>I would like to be able to create a subset with all rows deleted beside those <= 1964</p>
| [
{
"answer_id": 74294559,
"author": "br00t",
"author_id": 4028717,
"author_profile": "https://Stackoverflow.com/users/4028717",
"pm_score": 3,
"selected": true,
"text": "y = csv_file$Year_Birth[csv_file$Year_Birth <= 1964]\n"
},
{
"answer_id": 74294583,
"author": "Iwan de Jong",
"author_id": 15569025,
"author_profile": "https://Stackoverflow.com/users/15569025",
"pm_score": 2,
"selected": false,
"text": "y <- subset()"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20294853/"
] |
74,294,522 | <p>I am running into some issues when trying to take a table of games, and output a sorted list of matches played and points earned using the standard win=3 points, draw=1 point, loss=0 points.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>----</th>
<th>Hermione</th>
<th>Harry</th>
<th>Ron</th>
<th>Neville</th>
</tr>
</thead>
<tbody>
<tr>
<td>Hermione</td>
<td>-</td>
<td>Harry</td>
<td>Hermione</td>
<td>Hermione</td>
</tr>
<tr>
<td>Harry</td>
<td>Harry</td>
<td>-</td>
<td>Harry</td>
<td>Harry</td>
</tr>
<tr>
<td>Ron</td>
<td>Hermione</td>
<td>Harry</td>
<td>-</td>
<td></td>
</tr>
<tr>
<td>Neville</td>
<td>Hermione</td>
<td>Harry</td>
<td></td>
<td>-</td>
</tr>
</tbody>
</table>
</div>
<p>Quick issue: If I take the simple conversion in <code>=IF(B2=$A2,3,IF(B2=B$1,1,0))</code> and try to expand it to an arrayformula to get an intended result of {0,1,3,3} <code>=ArrayFormula(IF(B2:R2=$A2,3,IF(B2:R2=B$1,1,0)))</code> it only evaluates the first if condition and outputs {0,0,3,3}.</p>
<p>I have not found a good way to sum the values across each row iteratively, and include logic for pointing like above. Using SumIf or a Query it wants to evaluate the entire range for each criterion:
<code>={unique(A2:A5),ARRAYFORMULA(sumif(B2:E5,unique(A2:A5),G2:J5))}</code>
<a href="https://i.stack.imgur.com/a7tMM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a7tMM.png" alt="first" /></a></p>
<p>I can work around this by creating a filtered list <code>={"Player";unique(filter(A2:A5,NOT(ISBLANK(A2:A5))))}</code></p>
<p>Then account for it checking the entire section instead of going row by row with some quick math <code>={"Played","Points";ARRAYFORMULA(COUNTIF(B2:E5,A2:A5)/2),ARRAYFORMULA(COUNTIF(B2:E5,A2:A5)*1.5)}</code> but this still leaves us unable to count the number of games played accurately and with no options for a draw in the points totals.
<a href="https://i.stack.imgur.com/hX7Bk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hX7Bk.png" alt="workaround" /></a></p>
<p>The intended output would be:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Player</th>
<th>Played</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<tr>
<td>Hermione</td>
<td>3</td>
<td>6</td>
</tr>
<tr>
<td>Harry</td>
<td>3</td>
<td>9</td>
</tr>
<tr>
<td>Ron</td>
<td>2</td>
<td>0</td>
</tr>
<tr>
<td>Neville</td>
<td>2</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
<p>and if Ron and Neville were to play their last game of the 3 and draw it would update to:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Player</th>
<th>Played</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<tr>
<td>Hermione</td>
<td>3</td>
<td>6</td>
</tr>
<tr>
<td>Harry</td>
<td>3</td>
<td>9</td>
</tr>
<tr>
<td>Ron</td>
<td>3</td>
<td>1</td>
</tr>
<tr>
<td>Neville</td>
<td>3</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
<p>The idea would be to have both the player names, the games played, and points accrued in a sortable list (personal goal is to get it on one line because why not)</p>
<p>Please let me know what I am missing!</p>
| [
{
"answer_id": 74294559,
"author": "br00t",
"author_id": 4028717,
"author_profile": "https://Stackoverflow.com/users/4028717",
"pm_score": 3,
"selected": true,
"text": "y = csv_file$Year_Birth[csv_file$Year_Birth <= 1964]\n"
},
{
"answer_id": 74294583,
"author": "Iwan de Jong",
"author_id": 15569025,
"author_profile": "https://Stackoverflow.com/users/15569025",
"pm_score": 2,
"selected": false,
"text": "y <- subset()"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400288/"
] |
74,294,533 | <p>I want to extract store name and location from the <code>to_clean</code> column. I would like to use some regex pattern that accounts for all the different patterns and stores the store name in the <code>store</code> column and the location name in the <code>location</code> column.</p>
<p>Something like this:</p>
<pre><code>to_clean = ['ACTIVE BODY #1 - WEST VAN', 'BUY-LOW (80018) - KINGSGATE', 'CHOICES - CAMBIE #906',
'CAUSEWAY MASSET - CAMBIE', 'COMMUNITY NATURAL S2 - CHINOOK', 'MEINHARDT - GRANVILLE (80068)',
'WFM - CAMBIE - 10248']
store = ['ACTIVE BODY', 'BUY-LOW', 'CHOICES', 'CAUSEWAY MASSET', 'COMMUNITY NATURAL', 'MEINHARDT', 'WFM']
location = ['WEST VAN', 'KINGSGATE', 'CAMBIE','CAMBIE', 'CHINOOK', 'GRANVILLE', 'CAMBIE']
data = pd.DataFrame(list(zip(to_clean, store, location)), columns=['to_clean', 'store', 'location'])
data
</code></pre>
<p><a href="https://i.stack.imgur.com/Lf42W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lf42W.png" alt="enter image description here" /></a></p>
<p>Any help is greatly appreciated.</p>
<p>Thank you</p>
| [
{
"answer_id": 74294559,
"author": "br00t",
"author_id": 4028717,
"author_profile": "https://Stackoverflow.com/users/4028717",
"pm_score": 3,
"selected": true,
"text": "y = csv_file$Year_Birth[csv_file$Year_Birth <= 1964]\n"
},
{
"answer_id": 74294583,
"author": "Iwan de Jong",
"author_id": 15569025,
"author_profile": "https://Stackoverflow.com/users/15569025",
"pm_score": 2,
"selected": false,
"text": "y <- subset()"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14294794/"
] |
74,294,542 | <p>I want to concatenate the name of the product with "-v2" if the id is an odd number</p>
<pre><code>CREATE TABLE PRODUSE (
IdProdus int PRIMARY KEY IDENTITY,
Denumire varchar(36) NOT NULL,
IdCateg int NOT NULL
)
GO
SELECT IdProdus, Denumire,IIF(IdProdus%2=1, concat(Denumire, '-v2'), 0)
from PRODUSE;
</code></pre>
<p>The error is like</p>
<blockquote>
<p>Conversion failed when converting the varchar value 'Cablu USB-USB,
0.5m-v2' to data type int.</p>
</blockquote>
<p>'Cablu USB-USB, 0.5m' is the first name in the table.</p>
| [
{
"answer_id": 74294559,
"author": "br00t",
"author_id": 4028717,
"author_profile": "https://Stackoverflow.com/users/4028717",
"pm_score": 3,
"selected": true,
"text": "y = csv_file$Year_Birth[csv_file$Year_Birth <= 1964]\n"
},
{
"answer_id": 74294583,
"author": "Iwan de Jong",
"author_id": 15569025,
"author_profile": "https://Stackoverflow.com/users/15569025",
"pm_score": 2,
"selected": false,
"text": "y <- subset()"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19938435/"
] |
74,294,549 | <p>Requirement: I have a script that has a python command to run and the script is used by everyone</p>
<p>Error: python: command not found</p>
<p>Example:</p>
<pre><code>cat test.sh
python -c "import json,sys;"
</code></pre>
<p>If I change the script from <code>python -c</code> to <code>python3 -c</code> it works fine</p>
<p>Also, my ~/.zshrc as below</p>
<pre><code># To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
alias python=/usr/bin/python3
alias pip=/usr//bin/pip3
</code></pre>
<p>I already have python on my macOS as below</p>
<p><a href="https://i.stack.imgur.com/s9ESM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s9ESM.png" alt="enter image description here" /></a></p>
<p><strong>Issue is when running python inside the shellscript</strong></p>
<p>How to get the shell script to run the python command in it?</p>
<p>Also why is it blank when running below command
<a href="https://i.stack.imgur.com/y8kr8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y8kr8.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74294559,
"author": "br00t",
"author_id": 4028717,
"author_profile": "https://Stackoverflow.com/users/4028717",
"pm_score": 3,
"selected": true,
"text": "y = csv_file$Year_Birth[csv_file$Year_Birth <= 1964]\n"
},
{
"answer_id": 74294583,
"author": "Iwan de Jong",
"author_id": 15569025,
"author_profile": "https://Stackoverflow.com/users/15569025",
"pm_score": 2,
"selected": false,
"text": "y <- subset()"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12955349/"
] |
74,294,557 | <p>Im creating a flutter app with bloc, and I'm not able to use the block provider.</p>
<p>My main.dart:</p>
<pre><code>class _MyHomePageState extends State<MyHomePage> {
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(create: (_) => ManageBloc()),
BlocProvider(create: (_) => MonitorBloc()),
],
child: Builder(
builder: (context) => Scaffold(
appBar: AppBar(
title: Row(children: [
const Icon(Icons.wallet),
Text(widget.title),
]),
bottom: const TabBar(tabs: [
Tab(icon: Icon(Icons.home)),
Tab(icon: Icon(Icons.compare_arrows)),
Tab(icon: Icon(Icons.monetization_on))
]),
),
body: const TabBarView(
children: [
HomeScreen(),
OperationsView(),
PricesScreen(),
]),
floatingActionButton: FloatingActionButton(
onPressed: () {
showModalBottomSheet(context: context, builder: (BuildContext context) {
return NewOperation();
});
},
hoverColor: Colors.white,
backgroundColor: Colors.white10,
child: const Icon(Icons.add, color: Colors.lightBlue,),
),
),
));
}
}
</code></pre>
<p>When i click the floating button and try to view the NewOperation component, i recive the error.
NewOperation:</p>
<pre><code>class NewOperation extends StatelessWidget {
final GlobalKey<FormState> _formKey = GlobalKey();
final Operation operation = Operation();
bool _isEntry = false;
@override
Widget build(BuildContext context) {
return BlocBuilder<ManageBloc, ManageState>(builder: (context, state) {
Operation operation;
if (state is UpdateState) {
operation = state.previousOperation;
} else {
operation = Operation();
}
return Form(
key: _formKey,
child: Column(
children: [
TextFormField(
keyboardType: const TextInputType.numberWithOptions(
decimal: true),
validator: (String? inValue) {
if (inValue != null) {
if (double.parse(inValue) <= 0.0) {
return "Valor inválido!";
}
}
return null;
},
decoration: const InputDecoration(
hintText: "00.0",
labelText: "Valor da Operação",
),
),
TextFormField(
keyboardType: TextInputType.multiline,
validator: (String? inValue) {
if (inValue != null) {
if (inValue.length < 3) {
return "Addiction uma descrição mais detalhada!";
}
}
return null;
},
decoration: const InputDecoration(
hintText: "Conta de luz",
labelText: "Descrição",
),
),
Row(children: [
const Text("Entrada"),
Switch(value: _isEntry, onChanged: (bool inValue) {
// handleIsEntry(inValue);
}),
const Text("Saída"),
]),
ElevatedButton(onPressed: () {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
BlocProvider.of<ManageBloc>(context).add(SubmitEvent(operation: operation));
_formKey.currentState!.reset();
}
}, child: const Text("Salvar"))
],
));
});
}
}
</code></pre>
<p>What's the mistake?</p>
<p>I tried to put the floating button inside the MultiBlocProvider, and dosnt work.</p>
<p><a href="https://github.com/FischerRobson/traveler-wallet" rel="nofollow noreferrer">Github</a></p>
| [
{
"answer_id": 74294839,
"author": "Robert Sandberg",
"author_id": 13263384,
"author_profile": "https://Stackoverflow.com/users/13263384",
"pm_score": 1,
"selected": false,
"text": "showModalBottomSheet(\n context: context,\n builder: (modalContext) => BlocProvider.value(\n value: BlocProvider.of<ManageBloc>(context),\n child: NewOperation(),\n),\n"
},
{
"answer_id": 74295918,
"author": "Alex Stroescu",
"author_id": 9185312,
"author_profile": "https://Stackoverflow.com/users/9185312",
"pm_score": 0,
"selected": false,
"text": "return MultiBlocProvider(\n providers: [\n BlocProvider(create: (_) => ManageBloc()),\n ...\n ],\n child: MaterialApp(...),\n)\n \n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13509268/"
] |
74,294,590 | <p>i want to know that why we use two conditions
i am confused.. while head and head->next are not equal to null which means head and head's next will point to null ho is that possible</p>
<pre><code>int detectCycle(Node *& head)
{
Node * fast = head;
Node * slow = head;
while(fast!=nullptr && fast->next!=nullptr) // i am confused in these two conditions
{
slow = slow->next;
fast = fast->next->next;
if(fast == slow)
return 1;
}
return false;
}
</code></pre>
| [
{
"answer_id": 74294645,
"author": "Vlad from Moscow",
"author_id": 2877241,
"author_profile": "https://Stackoverflow.com/users/2877241",
"pm_score": 1,
"selected": false,
"text": "while(fast!=nullptr && fast->next!=nullptr)\n"
},
{
"answer_id": 74294753,
"author": "John Bollinger",
"author_id": 2402272,
"author_profile": "https://Stackoverflow.com/users/2402272",
"pm_score": 1,
"selected": true,
"text": "fast"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16429304/"
] |
74,294,605 | <p>I tried looking at serveral tutorials, but i didnt understand</p>
<pre><code>`#car driving
func get_car_input():
var velocity = Vector2.ZERO
var speed = 500
if Input.is_action_pressed("forward"):
velocity.y = -1
if Input.is_action_pressed("backward"):
velocity.y = 1
if Input.is_action_pressed("left"):
velocity.x = -1
if Input.is_action_pressed("right"):
velocity.x = 1
move_and_slide(velocity*speed)`
</code></pre>
| [
{
"answer_id": 74295103,
"author": "uberflut",
"author_id": 17329141,
"author_profile": "https://Stackoverflow.com/users/17329141",
"pm_score": 1,
"selected": false,
"text": "input(event)"
},
{
"answer_id": 74296591,
"author": "Theraot",
"author_id": 402022,
"author_profile": "https://Stackoverflow.com/users/402022",
"pm_score": 0,
"selected": false,
"text": " var speed := 500.0\n var velocity := Vector2(\n Input.get_axis(\"left\", \"right\"),\n Input.get_axis(\"forward\", \"backward\")\n ) * speed\n move_and_slide(velocity)\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20346379/"
] |
74,294,618 | <p>I want to use unboxed vectors on a simple newtype, but it's not clear to me how to enable this. What I have so far:</p>
<pre class="lang-hs prettyprint-override"><code>{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module UnboxedTest where
import Data.Vector.Unboxed
import Data.Word
newtype X = X Word64 deriving (Unbox)
</code></pre>
<p>I get:</p>
<pre><code>src/UnboxedTest.hs:11:32: error:
• No instance for (Data.Vector.Generic.Base.Vector Vector X)
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (Unbox X)
|
11 | newtype X = X Word64 deriving (Unbox)
</code></pre>
<p>How do I enable this to be put inside an unboxed vector?</p>
| [
{
"answer_id": 74294801,
"author": "Noughtmare",
"author_id": 15207568,
"author_profile": "https://Stackoverflow.com/users/15207568",
"pm_score": 2,
"selected": false,
"text": "Point"
},
{
"answer_id": 74307826,
"author": "leftaroundabout",
"author_id": 745903,
"author_profile": "https://Stackoverflow.com/users/745903",
"pm_score": 1,
"selected": false,
"text": "Unboxed.Vector"
},
{
"answer_id": 74308598,
"author": "lehins",
"author_id": 1848029,
"author_profile": "https://Stackoverflow.com/users/1848029",
"pm_score": 2,
"selected": false,
"text": "vector-0.13"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002430/"
] |
74,294,620 | <p>I spent last two days trying to fix this, but I realized that I cant do it alone. I'm trying to put my tooltip centered relative to parent. Here is my code =></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let collection = document.querySelectorAll("[data-text]");
collection.forEach((ele, ind) => {
var element = document.createElement("p");
element.className = "tooltip-text";
element.innerText = ele.dataset.text;
element.dataset.name = "_" + ele.id + ind;
document.getElementById(ele.id).appendChild(element);
document.querySelector('#' + ele.id).addEventListener('mouseover', () => {
document.querySelector('[data-name="' + element.dataset.name + '"]').style.visibility = 'visible';
}, false);
document.querySelector('#' + ele.id).addEventListener('mouseleave', () => {
document.querySelector('[data-name="' + element.dataset.name + '"]').style.visibility = 'hidden';
}, false);
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
display: flex;
background: #ccc;
justify-content: center;
align-items: center;
height: 95vh;
}
.c-content{
width: 100%;
max-width: 800px;
position: relative;
overflow: hidden;
border-radius: 4px;
}
.toprightcontrols {
margin: 0 1.2% 0 0;
display: flex;
position: absolute;
justify-content: flex-end;
top: 0;
right: 0;
width: 150px;
padding-top: 0;
flex-wrap: nowrap;
}
.btnClass {
padding: 10px;
background: none;
border: 0;
outline: 0;
cursor: pointer;
align-self: center;
justify-self: right;
}
.btnClass:before {
content: url('https://img001.prntscr.com/file/img001/nLMdieVITRSq82yZdqlWOw.png');
}
p.tooltip-text {
color: black;
display: block;
visibility: hidden;
width: fit-content;
position: absolute;
border-radius: 2px;
z-index: 1;
background: white;
pointer-events: none;
padding: 6px 8px 20.2px 8px;
font-size: 1rem;
animation: fadein 0.2s ease-in;
animation-fill-mode: forwards;
}
p.tooltip-text:before {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -8px;
border: 8px solid transparent;
border-bottom: 8px solid white;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
<div id="c-content">
<div class="toprightcontrols">
<span name="btn1" id="btn1" class="btnClass" data-text="Hello there"></span>
<span name="xxxxx" id="xxxxx" class="btnClass" data-text="Tooltip"></span>
<span name="something" id="something" class="btnClass" data-text="Click me"></span>
<span name="randomid" id="randomid" class="btnClass" data-text="I'm a text"></span>
</div>
</div>
</div></code></pre>
</div>
</div>
</p>
<p>The expected result must be something like this => <br>
<a href="https://i.stack.imgur.com/6fb2P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6fb2P.png" alt="enter image description here" /></a></p>
<p>Can you help me? I tried using <code>float, text-align, justify-content, margin: 0 auto</code>, everything I saw to centralize but nothing works</p>
<p>Thank you.</p>
| [
{
"answer_id": 74294769,
"author": "Alvin",
"author_id": 9239975,
"author_profile": "https://Stackoverflow.com/users/9239975",
"pm_score": 3,
"selected": true,
"text": ".btnClass"
},
{
"answer_id": 74294831,
"author": "NemoRu",
"author_id": 13267769,
"author_profile": "https://Stackoverflow.com/users/13267769",
"pm_score": 1,
"selected": false,
"text": ".btnClass {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20216936/"
] |
74,294,625 | <p>I am new to Java. I have a requirement to calculate the number of days, hour, time, sec from a given date to today, current time.</p>
<p>For example, I am getting 2 fields from database: <strong>Date</strong> and <strong>Time</strong>.<br />
<strong>Date</strong> field is in the format <code>Wednesday 02-October-2022</code> and <strong>Time</strong> field in the format <code>11:51:1 PM</code></p>
<p>In my Java class, I am able to pass these 2 field in String format:</p>
<pre><code>public String getLastRun(String failedDate, String failedTime)
{
}
</code></pre>
<p><code>String failedDate, String failedTime</code> are the <strong>Date</strong> and <strong>Time</strong> I got from DB in above format.</p>
<p>Now the issue is I need to calculate the <em>number of days, hour, time, sec passed</em> from that Date and time taken as input.</p>
<p>So, if <strong>current date</strong> is <code>Thursday 02-November-2022</code> and time is <code>11:51:1 PM</code>, I can calculate the number of days, hour, time, sec passed.<br />
Example: Output: <code>Last service failed 30 Days 12 hours 55 minutes 45 seconds</code> Kind of output calculating the given Date and time field as input to this current Date and time?</p>
<p>So far, I have taken this <strong>Date</strong> and <strong>Time</strong> as input in this format of <code>Wednesday 02-October-2022</code> and <code>11:51:1 PM</code> in the Java class, but I am still not sure about:</p>
<ol>
<li>How to generate or fetch current Date and Time in this format in Java code?</li>
<li>How to calculate the <em>number of days, hour, time, sec passed</em> from the given format with current Date and Time?</li>
</ol>
<p>I have checked these following links: <a href="https://stackoverflow.com/questions/27005861/calculate-days-between-two-dates-in-java-8#:%7E:text=We%20can%20use%20the%20between,days%20which%20completed%2024%20hours.">Link1</a>, <a href="https://stackabuse.com/how-to-get-the-number-of-days-between-dates-in-java/" rel="nofollow noreferrer">Link2</a> with local dates, but none of these have helped me to get the number of days, hour, time, sec from the given date and time format dynamically.<br />
I even tried with SimpleDateFormat as mentioned <a href="https://www.geeksforgeeks.org/find-the-duration-of-difference-between-two-dates-in-java/" rel="nofollow noreferrer">here</a> but not able to get with this format.</p>
<p>Any sample or pointer to start with will be helpful.<br />
Pls Note: Time zone is IST Asia/Kolkata</p>
| [
{
"answer_id": 74294751,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 2,
"selected": false,
"text": "LocalDate"
},
{
"answer_id": 74295865,
"author": "Arvind Kumar Avinash",
"author_id": 10819573,
"author_profile": "https://Stackoverflow.com/users/10819573",
"pm_score": 1,
"selected": false,
"text": "LocalDate"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13984087/"
] |
74,294,628 | <p>I am attempting to install the Azure CLI on my Fedora 35 machine using <a href="https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=dnf" rel="nofollow noreferrer">this guide</a>. When installing the RHEL 9 RPM using DNF (step 2 of that guide), Python 3.9 is installed along with Azure (Azure is dependent on 3.9). The installation of both applications appears to succeed until I run <code>az --version</code>, at which point I get a module not found error from <code>/usr/local/lib/python3.9/ssl.py</code>:</p>
<pre><code>ModuleNotFoundError: No module named '_ssl'
</code></pre>
<p>I have OpenSSL already installed properly on my machine at <code>/usr/bin/openssl</code>. Can I modify my Python installation to find this module?</p>
<p>I have already tried uninstalling and re-installing Azure and Python 3.9.</p>
<p>I have previously attempted to install Python 3.9 from source, but failed to do so, and did a manual uninstall by running <code>sudo rm -rf</code> on any directories relating to Python 3.9 before attempting to install Azure. None-the-less, it's entirely possible that I didn't do this properly.</p>
<p>I also have 2 other versions of Python (3.10.7 and 2.7.18) already installed.</p>
<p>I am very lost, and appreciate the help!</p>
<p>P.S: I expect to have similar issues with other modules once I resolve this problem. Ideally, I'd like to understand what I'm doing and how to apply this fix to similar errors. Thank you! :)</p>
| [
{
"answer_id": 74294751,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 2,
"selected": false,
"text": "LocalDate"
},
{
"answer_id": 74295865,
"author": "Arvind Kumar Avinash",
"author_id": 10819573,
"author_profile": "https://Stackoverflow.com/users/10819573",
"pm_score": 1,
"selected": false,
"text": "LocalDate"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20053525/"
] |
74,294,631 | <p>int alto;
int ancho;</p>
<pre><code> System.out.println("Dame el alto: ");
alto = scanner.nextInt();
System.out.println("dame el ancho: ");
ancho = scanner.nextInt();
int impresosAlto;
int impresosAncho;
do {
impresosAlto = 0;
impresosAncho = 0;
do {
System.out.print("*");
impresosAncho++;
} while (impresosAncho != ancho);
System.out.println();
impresosAlto++;
} while (impresosAlto != alto);
//
}
</code></pre>
<p>}</p>
<p>do while loop issue
Hi I´d like to sort this out but when i debug it , I have issues that the "impresosalto" stand whit int 1 instead of to , and the loop keep running in an infinite loop don´t know why , any help- advice ?
thanks
tried to change variables here and there but nothing worked out</p>
| [
{
"answer_id": 74294683,
"author": "Snehil Agrahari",
"author_id": 20400930,
"author_profile": "https://Stackoverflow.com/users/20400930",
"pm_score": 2,
"selected": false,
"text": "ImpresosAlto=0 move up two lines\n"
},
{
"answer_id": 74294759,
"author": "oleg.cherednik",
"author_id": 3461397,
"author_profile": "https://Stackoverflow.com/users/3461397",
"pm_score": -1,
"selected": false,
"text": "public static void main(String... args) throws IOException {\n Scanner scan = new Scanner(System.in);\n\n System.out.print(\"height: \");\n final int height = scan.nextInt();\n\n System.out.print(\"width: \");\n final int width = scan.nextInt();\n\n int row = 1;\n\n do {\n int col = 1;\n\n do {\n boolean star = row == 1 || row == height || col == 1 || col == width;\n System.out.println(star ? '*' : ' ');\n } while (++col <= width);\n\n System.out.println();\n } while (++row <= height);\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401009/"
] |
74,294,721 | <p>I'm trying to give an assistant access to part of someone's O365 mailbox. She currently has foldervisible permissions on his inbox. And there is about 607 folders under the inbox that she needs access to without having anymore permissions to the inbox itself.</p>
<p>Below is the code I've tried to run. I've removed the domain name but otherwise the code is exact. I've run the code twice and gotten no errors and it runs for a quite a while. But once it's complete, there is no change in the permissions.</p>
<pre><code>ForEach($f in (Get-EXOMailboxFolderStatistics -identity jjo | Where { $_.FolderPath.Contains("jjo:/Inbox/Case Files") -eq $True } ) ) {
$fname = "jjo:" + $f.FolderPath.Replace("/","\");
Add-MailboxFolderPermission $fname -User gka -AccessRights Owner
}
</code></pre>
| [
{
"answer_id": 74294683,
"author": "Snehil Agrahari",
"author_id": 20400930,
"author_profile": "https://Stackoverflow.com/users/20400930",
"pm_score": 2,
"selected": false,
"text": "ImpresosAlto=0 move up two lines\n"
},
{
"answer_id": 74294759,
"author": "oleg.cherednik",
"author_id": 3461397,
"author_profile": "https://Stackoverflow.com/users/3461397",
"pm_score": -1,
"selected": false,
"text": "public static void main(String... args) throws IOException {\n Scanner scan = new Scanner(System.in);\n\n System.out.print(\"height: \");\n final int height = scan.nextInt();\n\n System.out.print(\"width: \");\n final int width = scan.nextInt();\n\n int row = 1;\n\n do {\n int col = 1;\n\n do {\n boolean star = row == 1 || row == height || col == 1 || col == width;\n System.out.println(star ? '*' : ' ');\n } while (++col <= width);\n\n System.out.println();\n } while (++row <= height);\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401040/"
] |
74,294,744 | <p>My task is to practice inheritance, putting all the classes in separate files. I have a base class <code>Circle</code> and a derived class <code>Cylinder</code>.</p>
<p>What I'm stuck on is trying to display on the screen the result of my calculated area and volume for an object <code>B</code> of a <code>Cylinder</code> type. I found a way to do that for a <code>Circle</code>, though it doesn't work for my <code>Cylinder</code>.</p>
<p><strong>circle.h</strong></p>
<pre><code>#pragma once
#include <iostream>
class Circle {
public:
float r;
Circle();
Circle(float r);
Circle circumference();
Circle area();
void view();
void getArea();
void getCircum();
};
</code></pre>
<p><strong>circle.cpp</strong></p>
<pre><code>#include "circle.h"
#include <cmath>
using namespace std;
Circle::Circle() : r(5) {
cout << "Default constructor has been called for a circle\n";
}
Circle::Circle(float r) {
this->r = r;
cout << "Constructor with parameters has been called for a circle\n";
}
void Circle::view() {
cout << "Radius = " << r << endl;
}
Circle Circle::circumference() {
return 2 * M_PI * r;
}
Circle Circle::area() {
return M_PI * pow(r, 2);
}
void Circle::getArea() {
cout << "Area = " << r << " m^2";
}
void Circle::getCircum() {
cout << "Circumference = " << r << " m";
}
</code></pre>
<p><strong>cylinder.h</strong></p>
<pre><code>#pragma once
#include <iostream>
#include "circle.h"
class Cylinder : public Circle {
public:
float h;
Cylinder();
Cylinder(float r, float h);
void view();
double area();
double volume(float r, float h);
void getArea();
void getVolume();
};
</code></pre>
<p><strong>cylinder.cpp</strong></p>
<pre><code>#include "cylinder.h"
#include <cmath>
using namespace std;
Cylinder::Cylinder() : h(7) {
cout << "Default constructor has been called for a cylinder\n";
}
Cylinder::Cylinder(float r, float h) : Circle(r) {
this->h = h;
cout << "Constructor with parameters has been called fo a cylinder\n";
}
void Cylinder::view() {
Circle::view();
cout << "Height = " << h << endl;
}
double Cylinder::area() {
return 2 * M_PI * r * h;
}
double Cylinder::volume(float r, float h) {
return M_PI * pow(r, 2) * h;
}
void Cylinder::getArea() {
cout << "Area = " << h;
}
void Cylinder::getVolume() {
cout << "Volume = " << h;
}
</code></pre>
<p><strong>main.cpp</strong></p>
<pre><code>#include <iostream>
#include "circle.h"
#include "cylinder.h"
using namespace std;
int main() {
Circle A;
A.view();
Circle A1(8);
A1.view();
Cylinder B;
B.view();
Cylinder B1(4, 6);
B1.view();
//A.area().getArea();
//cout << endl;
//A.circumference().getCircum();
//cout << endl;
//A1.area().getArea();
//cout << endl;
//A1.circumference().getCircum();
B.area().getArea();
return 0;
}
</code></pre>
<p>The error that I'm getting:</p>
<pre class="lang-none prettyprint-override"><code>main.cpp: In function ‘int main()’:
main.cpp:26:14: error: request for member ‘getArea’ in ‘B.Cylinder::area()’, which is of non-class type ‘double’
26 | B.area().getArea();
| ^~~~~~~
</code></pre>
<p>I feel like neither my code in <code>main()</code> for instance <code>B</code>, nor my methods <code>getArea()</code> and <code>getVolume()</code> in class <code>Cylinder</code>, are correct. And there is probably a better approach to do the same for an object <code>A</code> and <code>A1</code> of a <code>Circle</code> type, though the code I commented out actually works.</p>
<p>I know that this is a dumb question, and such things should be quite straightforward, but I am trying to learn and would be grateful for any advice on how I can fix this.</p>
| [
{
"answer_id": 74294793,
"author": "Iwan de Jong",
"author_id": 15569025,
"author_profile": "https://Stackoverflow.com/users/15569025",
"pm_score": 1,
"selected": true,
"text": "getArea()"
},
{
"answer_id": 74294833,
"author": "Robert Shepherd",
"author_id": 19970913,
"author_profile": "https://Stackoverflow.com/users/19970913",
"pm_score": 1,
"selected": false,
"text": "main.cpp: In function ‘int main()’:\nmain.cpp:26:14: error: request for member ‘getArea’ in ‘B.Cylinder::area()’, which is of non-class type ‘double’\n 26 | B.area().getArea();\n | ^~~~~~~\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18237344/"
] |
74,294,746 | <p>I am trying to create plug-in that will catch any send item and show warning before sent out.
Currently I am using the below code</p>
<pre><code> private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Outlook.Application application = Globals.ThisAddIn.Application;
application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
}
</code></pre>
<p>However, I noticed it catches almost all the send event but when send button is pressed from main screen of Outlook, I mean when the mail is not popped out to separate window, it does not catch the event and my plugin function is not executed. My environment is Visual Studio 2019 and Outlook 2019. Any advise is appreciated.</p>
<p>Thank you,</p>
<p>Catch all the send event from Outlook.</p>
<p>Update 11/7/2022: it turned out that the event is caught but
I am tryning to catch the item type by the below method and inline item does not detected as an item.</p>
<pre><code>itemtype = Application.ActiveWindow().CurrentItem.Class;
</code></pre>
| [
{
"answer_id": 74294995,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 2,
"selected": true,
"text": "ItemSend"
},
{
"answer_id": 74306425,
"author": "Dmitry Streblechenko",
"author_id": 332059,
"author_profile": "https://Stackoverflow.com/users/332059",
"pm_score": 0,
"selected": false,
"text": "mailto:\""
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401086/"
] |
74,294,762 | <p>Now that I'm typing it, this seems like a very convoluted process that could definitely be solved easier. Ignoring that for the moment, I'm trying to take a string (from user input), separate the characters into an array, then call individual characters to make a new string. The issue I'm running into is that the "join" function doesn't like working with the "Vec" function (not sure if function is the right term, sorry). Here is my code so far:</p>
<pre><code>use std::io;
fn main() {
println!("Enter P1:");
let mut mono = String::new();
io::stdin()
.read_line(&mut mono)
.expect("Failed to read line");
let mono: Vec<char> = mono.chars().collect();
let x = [mono[0],mono[1]].join("");
println!("Square 1: {x}");
}
</code></pre>
<p>I'm very new to Rust, so any suggestions are extremely helpful. Thank you!</p>
| [
{
"answer_id": 74294995,
"author": "Eugene Astafiev",
"author_id": 1603351,
"author_profile": "https://Stackoverflow.com/users/1603351",
"pm_score": 2,
"selected": true,
"text": "ItemSend"
},
{
"answer_id": 74306425,
"author": "Dmitry Streblechenko",
"author_id": 332059,
"author_profile": "https://Stackoverflow.com/users/332059",
"pm_score": 0,
"selected": false,
"text": "mailto:\""
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401107/"
] |
74,294,875 | <p>I searched over internet and couldn't find this kind of grid layout.</p>
<p>"grid-template-columns" doesnt do the thing, cant do one box bigger then the others. I want 4 equal boxes and 1 box with equal height and width = square box * 2 + gridgap.</p>
<p>here is the image I've illustrated to make you understand what i ment.</p>
<p>I also tried to use display flex but I didnt get the Idea of it. Please, help me. Thanks!</p>
<p><a href="https://i.stack.imgur.com/KHK0l.png" rel="nofollow noreferrer">Illustation of my idea</a></p>
| [
{
"answer_id": 74295001,
"author": "Sli4o",
"author_id": 12185026,
"author_profile": "https://Stackoverflow.com/users/12185026",
"pm_score": -1,
"selected": true,
"text": ".container {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n width: 100%;\n height: 180px;\n}\n.row {\n display: flex;\n flex-direction: row;\n justify-content: center;\n}\n.box {\n width: 10vw;\n height: 10vw;\n margin: 12px;\n border: 1px solid black;\n}\n.box.big {\n width: calc(20vw + 24px);\n}"
},
{
"answer_id": 74295709,
"author": "orghu",
"author_id": 2817442,
"author_profile": "https://Stackoverflow.com/users/2817442",
"pm_score": 0,
"selected": false,
"text": ".wrapper {\n display: grid;\n justify-content: center;\n}\n\n.box {\n border: 2px solid #000;\n width: 128px;\n min-height: 128px;\n justify-content: center;\n margin: 10px;\n display: grid;\n align-items: center;\n}\n\n.box5 {\n grid-column: 2/5;\n width: 280px;\n}\n\n\n/*for this to be visible, the screen-width has to be under 600px*/\n\n@media (max-width: 600px) {\n .box5 {\n grid-column: 2/1;\n align-items: center;\n justify-content: center;\n display: grid;\n max-width: 128px;\n width: 100%;\n }\n}"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10706270/"
] |
74,294,877 | <p>I've tried all afternoon to dedup a table that looks like this:</p>
<pre><code>ID1 | ID2 | Date | Time |Status | Price
----+-----+------------+-----------------+--------+-------
01 | A | 01/01/2022 | 10:41:47.000000 | DDD | 55
01 | B | 02/01/2022 | 16:22:31.000000 | DDD | 53
02 | C | 01/01/2022 | 08:54:03.000000 | AAA | 72
02 | D | 03/01/2022 | 11:12:35.000000 | DDD |
03 | E | 01/01/2022 | 17:15:41.000000 | DDD | 67
03 | F | 01/01/2022 | 19:27:22.000000 | DDD | 69
03 | G | 02/01/2022 | 06:45:52.000000 | DDD | 78
</code></pre>
<p>Basically, I need to dedup based on two conditions:</p>
<ol>
<li><code>Status</code>: where AAA > BBB > CCC > DDD. So, pick the highest one.</li>
<li>When the <code>Status</code> is the same given the same <code>ID1</code>, pick the latest one based on <code>Date</code> and <code>Time</code>.</li>
</ol>
<p>The final table should look like:</p>
<pre><code>ID1 | ID2 | Date | Time |Status | Price
----+-----+------------+-----------------+--------+-------
01 | B | 02/01/2022 | 16:22:31.000000 | DDD | 53
02 | C | 01/01/2022 | 08:54:03.000000 | AAA | 72
03 | G | 02/01/2022 | 06:45:52.000000 | DDD | 78
</code></pre>
<p>Is there a way to do this in Redshift SQL / PostgreSQL?</p>
<p>I tried variations of this, but everytime it doesn't work because it demands that I add all columns to the group by, so then it defeats the purpose</p>
<pre><code>select a.id1,
b.id2,
b.date,
b.time,
b.status,
b.price,
case when (status = 'AAA') then 4
when (status = 'BBB') then 3
when (status= 'CCC') then 2
when (status = 'DDD') then 1
when (status = 'EEE') then 0
else null end as row_order
from table1 a
left join table2 b
on a.id1=b.id1
group by id1
having row_order = max(row_order)
and date=max(date)
and time=max(time)
</code></pre>
<p>Any help at all is appreciated!</p>
| [
{
"answer_id": 74294916,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "SELECT ID1, ID2, Date, Time, Status, Price\nFROM (\n SELECT *,\n row_number() OVER (PARTITION BY ID1 ORDER BY Status, Date DESC, Time DESC) rn\n FROM MyTable\n) t\nWHERE rn = 1\n"
},
{
"answer_id": 74294957,
"author": "Aaron Dietz",
"author_id": 5420008,
"author_profile": "https://Stackoverflow.com/users/5420008",
"pm_score": 2,
"selected": false,
"text": "ROW_NUMBER()"
},
{
"answer_id": 74295953,
"author": "GMB",
"author_id": 10676716,
"author_profile": "https://Stackoverflow.com/users/10676716",
"pm_score": 1,
"selected": false,
"text": "distinct on"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14088919/"
] |
74,294,885 | <p>My task is to implement the cos(x) function withou using Math. library and with the taylor polynom, my code looks like this:</p>
<pre><code>
public class Cosinus {
public static void main(String[] args) {
/*if(args.length == 0){
System.out.println("ERROR: Geben Sie ein Argument für x ein!");
return;
}*/
double x = 5;
double summand1 = (x*x) / 2;
double summand2 = (x*x*x*x) / (2*3*4);
double summand3 = (x*x*x*x*x*x) / (2*3*4*5*6);
double summand4 = (x*x*x*x*x*x*x*x) / (2*3*4*5*6*7*8);
double summand5 = (x*x*x*x*x*x*x*x*x*x) / (2*3*4*5*6*7*8*9*10);
double summand6 = (x*x*x*x*x*x*x*x*x*x*x*x) / (2*3*4*5*6*7*8*9*10*11*12);
double summand7 = (x*x*x*x*x*x*x*x*x*x*x*x*x*x) / (2*3*4*5*6*7*8*9*10*11*12*13*14);
//double summand8 = (x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x) / (2*3*4*5*6*7*8*9*10*11*12*13*14*15*16);
//double summand9 = (x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x) / (2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18);
//double summand10 = (x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x*x) / (2*3*4*5*6*7*8*9*10*11*12*13*14*15*16*17*18*19*20);
double cosinusFunktion = (((((((1 - summand1) + summand2) - summand3) + summand4) - summand5) + summand6) - summand7);
System.out.println(cosinusFunktion);
}
}
</code></pre>
<p>For x = 1, 2, 3, and 4 Y is between 1 and -1
but with x = 5 it goes too -4 and if the x are even getting bigger this continues too 1287918274.</p>
<p>I cant solve this task but tthe task says it is enough to implement this funktion iwth the taylor polynom and the first 11 summand. I tried this too, but then even with x = 1 the bounds are broken. How can i solve this, so x = 42.5 is in bound of -1 and 1?</p>
<p>Tried more summands to make the result more excact, but the bounds get broken even more.
tried implement the periodicity of x-2*PI, but I dont know where to put it and results get messed up eeven more.</p>
| [
{
"answer_id": 74294962,
"author": "Pursuit",
"author_id": 931379,
"author_profile": "https://Stackoverflow.com/users/931379",
"pm_score": 1,
"selected": false,
"text": "sin(x) = sin(x + n*2*pi) // for any integer n\n"
},
{
"answer_id": 74295142,
"author": "SR3142",
"author_id": 11239195,
"author_profile": "https://Stackoverflow.com/users/11239195",
"pm_score": 2,
"selected": false,
"text": "double summand7 = (x*x*x*x*x*x*x*x*x*x*x*x*x*x) / ((double) 2*3*4*5*6*7*8*9*10*11*12*13*14);\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20137237/"
] |
74,294,961 | <p>I'm having a problem that I haven't been abble to resolve, I need to merge two scripts or append the second script exported info into the same delimited CSV file (created by the first script).</p>
<p>This is the first script:</p>
<pre><code>Get-Mailbox -ResultSize Unlimited | Select-Object AddressBookPolicy, ProhibitSendQuota, SamAccountName, UserPrincipalName, WhenMailboxCreated, Alias, OrganizationalUnit, CustomAttribute1, DisplayName, PrimarySmtpAddress, RecipientType, RecipientTypeDetails, WindowsEmailAddress, WhenChanged, WhenCreated | export-csv -NoTypeInformation .\Mailboxes_filtered.csv -Delimiter ";" -Encoding unicode
</code></pre>
<p>And this the second one:</p>
<pre><code>Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName, StorageLimitStatus, TotalItemSize | export-csv -NoTypeInformation .\Mailboxes_filtered.csv -Delimiter ";" -Encoding unicode
</code></pre>
<p>PS: I'm using Exchange 2010.</p>
<p>I managed to get some success using "AddContent -Path .\Mailboxes_filtered.csv", but the added info appeared under the delimited cells on the CSV file instead of showing up beside and organized in the same way, I guess it happened because in this case the -Delimited ";" parameter is not accepted...</p>
<p>Those two scripts work, I just need to merge or append the exported info into the same CSV file.</p>
| [
{
"answer_id": 74294962,
"author": "Pursuit",
"author_id": 931379,
"author_profile": "https://Stackoverflow.com/users/931379",
"pm_score": 1,
"selected": false,
"text": "sin(x) = sin(x + n*2*pi) // for any integer n\n"
},
{
"answer_id": 74295142,
"author": "SR3142",
"author_id": 11239195,
"author_profile": "https://Stackoverflow.com/users/11239195",
"pm_score": 2,
"selected": false,
"text": "double summand7 = (x*x*x*x*x*x*x*x*x*x*x*x*x*x) / ((double) 2*3*4*5*6*7*8*9*10*11*12*13*14);\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401003/"
] |
74,294,966 | <p>Would appreciate your help with this.
I'm trying to get the site to automatically click on a button, when the site is loading.</p>
<p>The button I'm referring to is the blue one, above the fold right when you enter the page,
the text is "Full 2022-2023 Schedule".</p>
<p>Site is running Elementor on Wordpress.</p>
<p>Any ideas?</p>
<p>I tried adding this script to the homepage of the site <a href="http://www.thenflschedule.com" rel="nofollow noreferrer">www.thenflschedule.com</a>,
but it just doesn't work.</p>
<pre><code><script type="text/javascript">
document.getElementById("button").click();
</script>
</code></pre>
<p>Update:
There's a script on the page to open popups only when the window or any element is clicked. I thought that by auto-clicking a button, it would trigger the popup, but it doesn't. I would still need to click manually anywhere on the page for the pop up to open.</p>
<p>Is there a function to click anywhere on the window, that would trigger the popup script?</p>
<p>This is the pop up script that's running on the page:
<code><script data-cfasync="false" src="//acacdn.com/script/suv4.js" data-adel="lwsu" cdnd="acacdn.com" zid="323555"></script></code></p>
| [
{
"answer_id": 74294962,
"author": "Pursuit",
"author_id": 931379,
"author_profile": "https://Stackoverflow.com/users/931379",
"pm_score": 1,
"selected": false,
"text": "sin(x) = sin(x + n*2*pi) // for any integer n\n"
},
{
"answer_id": 74295142,
"author": "SR3142",
"author_id": 11239195,
"author_profile": "https://Stackoverflow.com/users/11239195",
"pm_score": 2,
"selected": false,
"text": "double summand7 = (x*x*x*x*x*x*x*x*x*x*x*x*x*x) / ((double) 2*3*4*5*6*7*8*9*10*11*12*13*14);\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401233/"
] |
74,294,972 | <p>The Graph API call with <code>https://graph.microsoft.com/v1.0/users/XXXX-XXXX-XXXX-XXXX-XXXX94105a4$select=mail</code> fails with</p>
<pre><code>{
"error": {
"code": "Request_ResourceNotFound",
"message": "Resource 'XXXX-XXXX-XXXX-XXXX-XXXX94105a4$select=mail' does not exist or one of its queried reference-property objects are not present.",
</code></pre>
<p>But the call <code>https://graph.microsoft.com/v1.0/users/XXXX-XXXX-XXXX-XXXX-XXXX94105a4</code> <strong>successfully</strong> reports the user's "mail":</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Get User</th>
<th>Get User Mail</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://i.stack.imgur.com/GNieu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GNieu.png" alt="Get User" /></a></td>
<td><a href="https://i.stack.imgur.com/V8wXr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V8wXr.png" alt="Get User Email" /></a></td>
</tr>
</tbody>
</table>
</div>
<p>Why & how to resolve?</p>
| [
{
"answer_id": 74294962,
"author": "Pursuit",
"author_id": 931379,
"author_profile": "https://Stackoverflow.com/users/931379",
"pm_score": 1,
"selected": false,
"text": "sin(x) = sin(x + n*2*pi) // for any integer n\n"
},
{
"answer_id": 74295142,
"author": "SR3142",
"author_id": 11239195,
"author_profile": "https://Stackoverflow.com/users/11239195",
"pm_score": 2,
"selected": false,
"text": "double summand7 = (x*x*x*x*x*x*x*x*x*x*x*x*x*x) / ((double) 2*3*4*5*6*7*8*9*10*11*12*13*14);\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/285795/"
] |
74,294,977 | <p>Stripe can return 3 different object types from as the customer.
I want the customer id which is what is normally returned.</p>
<p>What I have below is pretty ugly.</p>
<p>Is there a better way to do this?</p>
<pre><code> const stripeCustomer: string | Stripe.Customer | Stripe.DeletedCustomer = checkoutSession.customer;
let stripeCustomerId: string;
if (stripeCustomer instanceof Object && "email" in stripeCustomer) {
// customer is of type Stripe.Customer
stripeCustomerId = stripeCustomer.id;
} else if (typeof stripeCustomer === 'string') {
// customer is id
stripeCustomerId = stripeCustomer;
} else {
// customer is of type Stripe.DeletedCustomer
stripeCustomerId = null;
}
</code></pre>
| [
{
"answer_id": 74295166,
"author": "Alexander",
"author_id": 3141234,
"author_profile": "https://Stackoverflow.com/users/3141234",
"pm_score": 3,
"selected": true,
"text": "function isStripeCustomer(object: any): object is Stripe.Customer {\n return object instanceof Object \n && \"object\" in object \n && object.object === 'customer' \n && !object.deleted\n}\n\nfunction isStripCustomerID(object: any): object is string {\n return typeof object === \"string\"\n}\n\nfunction isStripeDeletedCustomer(object: any): object is Stripe.DeletedCustomer {\n return object instanceof Object\n && \"object\" in object \n && object.object === 'customer' \n && object.deleted\n}\n\nconst customer: string | Stripe.Customer | Stripe.DeletedCustomer = checkoutSession.customer;\n\nlet stripeCustomerId: string | null\n\nif (isStripeCustomer(customer)) {\n stripeCustomerId = customer.id\n} else if (isStripCustomerID(customer)) { \n stripeCustomerId = customer;\n} else if (isStripeDeletedCustomer(customer) {\n stripeCustomerId = null;\n} else {\n // It was none of the known types. Perhaps a new type of result was\n // add in a future version of their API?\n\n}\n"
},
{
"answer_id": 74295205,
"author": "fjc",
"author_id": 3599151,
"author_profile": "https://Stackoverflow.com/users/3599151",
"pm_score": 1,
"selected": false,
"text": "interface Customer {\n id: string;\n}\n\ntype CustomerResponse = Customer | string | null;\n\nfunction isCustomerObject(customer: CustomerResponse): customer is Customer {\n return customer != null && typeof customer === \"object\" && customer.id != null;\n}\n\nfunction isString(str: CustomerResponse): str is string {\n return typeof str === \"string\";\n}\n\nfunction identify(obj: Customer | string | null) {\n if (isCustomerObject(obj)) {\n console.log(obj, \"is a customer with ID\", obj.id);\n } else if (isString(obj)) {\n console.log(obj, \"is a string with value\", obj);\n } else {\n console.log(obj, \"is null\");\n }\n}\n\nconst customerObject: Customer = {\n id: \"123\"\n};\n\n\nidentify(customerObject);\nidentify(\"123\");\nidentify(null);\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10222449/"
] |
74,294,992 | <p>I'm wondering if it's possible to create dynamic type that would replace two params, such as in <code>on: (eventName: EventName, callback: (data: any) => void) => void</code> with something closer to this <code>on: (DynamicParams<EventName>) => void</code>, so it could extract <code>callback's</code> type from a predefined set and use it instead of <code>any</code> type.</p>
<p>I think it would be easier to explain with some code.</p>
<p>Say, I have set of different types of events:</p>
<pre><code>const events = ['loaded', 'changed'];
type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType[number];
type EventName = ArrayElement<typeof events>
</code></pre>
<p>and a function that runs only when a specific notification has been emitted;</p>
<pre><code>const on = (eventName: EventName, callback: (data: any) => void) => {}
</code></pre>
<p>But I want to be able to use this function with callback that accepts different parameter types, without checking for the type manually and without any casting, for example:</p>
<pre><code>on('loaded', (list: Entry[]) => {
// do something with loaded array of elements;
}
on('changed', (index: number) => {
// do something with index of a changed entry;
}
</code></pre>
<p>Is there a way to create a mapped type that would accept EventName and return a specific type to a given event?</p>
<p>Something like that:</p>
<pre><code>const on(eventName: EventName, DynamicMethod<'eventName'> => void) => {}
const on(DynamicParams<'eventName'>) => {}
</code></pre>
<p>Assume, I would need to replace event object and create a type in its place, instead:</p>
<pre><code>type events = [
{
name: 'loaded',
method: (list: Entry[]) => void
},
{
name: 'changed',
method: (index: number) => void
}
]
</code></pre>
<p>But I'm not sure how to extract name values (not types of the values).</p>
| [
{
"answer_id": 74295166,
"author": "Alexander",
"author_id": 3141234,
"author_profile": "https://Stackoverflow.com/users/3141234",
"pm_score": 3,
"selected": true,
"text": "function isStripeCustomer(object: any): object is Stripe.Customer {\n return object instanceof Object \n && \"object\" in object \n && object.object === 'customer' \n && !object.deleted\n}\n\nfunction isStripCustomerID(object: any): object is string {\n return typeof object === \"string\"\n}\n\nfunction isStripeDeletedCustomer(object: any): object is Stripe.DeletedCustomer {\n return object instanceof Object\n && \"object\" in object \n && object.object === 'customer' \n && object.deleted\n}\n\nconst customer: string | Stripe.Customer | Stripe.DeletedCustomer = checkoutSession.customer;\n\nlet stripeCustomerId: string | null\n\nif (isStripeCustomer(customer)) {\n stripeCustomerId = customer.id\n} else if (isStripCustomerID(customer)) { \n stripeCustomerId = customer;\n} else if (isStripeDeletedCustomer(customer) {\n stripeCustomerId = null;\n} else {\n // It was none of the known types. Perhaps a new type of result was\n // add in a future version of their API?\n\n}\n"
},
{
"answer_id": 74295205,
"author": "fjc",
"author_id": 3599151,
"author_profile": "https://Stackoverflow.com/users/3599151",
"pm_score": 1,
"selected": false,
"text": "interface Customer {\n id: string;\n}\n\ntype CustomerResponse = Customer | string | null;\n\nfunction isCustomerObject(customer: CustomerResponse): customer is Customer {\n return customer != null && typeof customer === \"object\" && customer.id != null;\n}\n\nfunction isString(str: CustomerResponse): str is string {\n return typeof str === \"string\";\n}\n\nfunction identify(obj: Customer | string | null) {\n if (isCustomerObject(obj)) {\n console.log(obj, \"is a customer with ID\", obj.id);\n } else if (isString(obj)) {\n console.log(obj, \"is a string with value\", obj);\n } else {\n console.log(obj, \"is null\");\n }\n}\n\nconst customerObject: Customer = {\n id: \"123\"\n};\n\n\nidentify(customerObject);\nidentify(\"123\");\nidentify(null);\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5233074/"
] |
74,294,997 | <p>Currently I sometimes run vim with a wildcard, e.g. like this:</p>
<pre><code>vim *.cpp
</code></pre>
<p>This works well, as I can then use <code>:next</code> and <code>:prev</code> to look at each of the <code>.cpp</code> files in sequence.</p>
<p>Where it falls down a little bit is when there are <em>many</em> files matching the wildcard, and I want to skip past several dozen/hundred of them quickly. E.g. typing <code>:next</code> 96 times in a row isn't much fun.</p>
<p>So my question is, is there some keystroke or command that will cause vim to list out all of the files that matched the wildcard-expansion, and allow me to "jump" directly to a file in the list, without having to laboriously <code>:next</code> my way down to it?</p>
| [
{
"answer_id": 74295781,
"author": "romainl",
"author_id": 546861,
"author_profile": "https://Stackoverflow.com/users/546861",
"pm_score": 2,
"selected": false,
"text": "$ vim {foo,bar,baz}/*.cpp\n"
},
{
"answer_id": 74295853,
"author": "William Pursell",
"author_id": 140750,
"author_profile": "https://Stackoverflow.com/users/140750",
"pm_score": 2,
"selected": true,
"text": ":ls\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74294997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131930/"
] |
74,295,004 | <p>Imagine I have the following dataframe:</p>
<pre><code>pd.DataFrame({"Date":["10/29/2022", "10/30/2022", "11/5/2022", "11/6/2022"],
"Values":[1, 6, 8, 12]})
</code></pre>
<p>I would like to create a new column with a value that equals to 0 if the row has a date before today and 1 to a date that's still on the future.</p>
<p>Any ideas on how to implement it?</p>
| [
{
"answer_id": 74295045,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "df['new'] = (pd.to_datetime(df['Date'], dayfirst=False) # convert to datetime\n .gt(pd.Timestamp('today')) # is the date after today?\n .astype(int) # result as 0/1\n )\n"
},
{
"answer_id": 74295047,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 0,
"selected": false,
"text": "df[\"new\"] = (pd.to_datetime(df[\"Date\"]) > pd.Timestamp.now()).astype(int)\nprint(df)\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17100222/"
] |
74,295,005 | <p><a href="https://i.stack.imgur.com/PgfqO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PgfqO.jpg" alt="enter image description here" /></a></p>
<p>i have started facing this issue after i installed clarifai API for project face recognition and i tried everything but can't find the solution. It shows this message when hovering on import clarifai:</p>
<blockquote>
<p>Could not find a declaration file for module 'clarifai'</p>
</blockquote>
<p>tried reinstalling clarifai and also node modules still didn't solve this</p>
| [
{
"answer_id": 74295045,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "df['new'] = (pd.to_datetime(df['Date'], dayfirst=False) # convert to datetime\n .gt(pd.Timestamp('today')) # is the date after today?\n .astype(int) # result as 0/1\n )\n"
},
{
"answer_id": 74295047,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 0,
"selected": false,
"text": "df[\"new\"] = (pd.to_datetime(df[\"Date\"]) > pd.Timestamp.now()).astype(int)\nprint(df)\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401114/"
] |
74,295,019 | <p>I have an <code>ArrayList<E></code>, where <code>E</code> has several subclasses. I want to remove the first instance of an object of subclass <code>T</code>.</p>
<p>My current implementation relies on an overridden <code>equals(Object o)</code> that looks at a constant that is unique to the subclass. Since objects of this subclass are interchangeable, I figured this would be much better than the usual implementations. See below.</p>
<pre><code>public class E {
//Stuff
}
</code></pre>
<pre><code>public class T extends E {
private static final String UNIQUE_STRING = "blah";
//More variables
public T() {
}
public static String getUniqueString() {
return UNIQUE_STRING;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (this.getClass() == o.getClass()) {
T t = (T) o;
if (this.getUniqueString().equals(t.getUniqueString())) return true;
}
return false;
}
//Also has hashCode() here somewhere, as well as other methods
}
</code></pre>
<pre><code>import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
initialize();
}
private static void initialize() {
E t1 = new T();
E t2 = new T();
E t3 = new T();
List<E> list = new ArrayList<>();
list.add(t1);
list.add(t2);
list.add(t3);
list.remove(new T());
}
}
</code></pre>
<p>Using a <code>Map<T, Integer></code> (or similar) is not feasible because <code>list</code> is going to contain other subclasses of <code>E</code>, not just <code>T</code>, and objects of <em>those</em> other subclasses differ in many respects. Only instances of <code>T</code> are, for all intents and purposes, interchangeable.</p>
<p>Separating instances of <code>T</code> from the list and using a <code>Map<T, Integer></code> would be a major headache due to indexing and whatnot.</p>
<p>Finally, searching each object one by one until I found an instance of <code>T</code> (by using <code>getClass()</code> and the literal name of the class) seems like it'd be even worse.</p>
<p>My concern is that creating new objects to do this, while functional, is highly inefficient and potentially "dangerous". Is there a better way of achieving this?</p>
| [
{
"answer_id": 74295071,
"author": "Marcus Dunn",
"author_id": 12639399,
"author_profile": "https://Stackoverflow.com/users/12639399",
"pm_score": 3,
"selected": true,
"text": "instanceof"
},
{
"answer_id": 74295216,
"author": "moussaEL",
"author_id": 18290052,
"author_profile": "https://Stackoverflow.com/users/18290052",
"pm_score": 0,
"selected": false,
"text": "public static void main(String[] args) {\n final var arrayList = new ArrayList<>(List.of(new E(), new E(), new E(), new T(), new T(), new E()));\n var listWithoutTinstances = arrayList.parallelStream()\n .filter(e -> e instanceOf T)\n .collect(Collectors.toList());\n }\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12247094/"
] |
74,295,020 | <p>I'm trying to get the 2 images next to each other instead of beneath each other but I have no clue how to go about something like this, I tried something with an I variable to influence the index but that did not really work out. normally I could do this but with the index, I have no clue how to go about this.</p>
<p>code:</p>
<pre><code>Center(
child: Column(
children: [
_items.isNotEmpty
? Expanded(
child: ListView.builder(
itemCount: _items.length,
itemBuilder: (context, index) {
return Column(
children: [
RawMaterialButton(
child: Image(
image: NetworkImage(_items[index]["portrait"]),
height: 200,
width: 140,
),
onPressed: () {
Navigator.push(context, _AnimatedNavigation(SpecificCharacterRoute(
_items[index]["name"], _items[index]["name"], _items[index]["shop_background"], _items[index]["overview"],
_items[index]["difficulty"], "images/dbdsurvivorlogo.png")
)
);
},
),
],
);
},
),
)
: Container()
],
),
),
</code></pre>
<p>Here's an image of what I mean
<a href="https://i.stack.imgur.com/NafjK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NafjK.png" alt="enter image description here" /></a></p>
<p>Here's an image of what I have</p>
<p><a href="https://i.stack.imgur.com/vLsT2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vLsT2.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74295071,
"author": "Marcus Dunn",
"author_id": 12639399,
"author_profile": "https://Stackoverflow.com/users/12639399",
"pm_score": 3,
"selected": true,
"text": "instanceof"
},
{
"answer_id": 74295216,
"author": "moussaEL",
"author_id": 18290052,
"author_profile": "https://Stackoverflow.com/users/18290052",
"pm_score": 0,
"selected": false,
"text": "public static void main(String[] args) {\n final var arrayList = new ArrayList<>(List.of(new E(), new E(), new E(), new T(), new T(), new E()));\n var listWithoutTinstances = arrayList.parallelStream()\n .filter(e -> e instanceOf T)\n .collect(Collectors.toList());\n }\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17398732/"
] |
74,295,039 | <p>As many have written about before, when a modal containing a video is closed, the video keeps playing in the background. I need to stop or pause the video.</p>
<p>I've been looking through all the recommend script answers. None of them seem to reference Colorbox and its unique modal setup. It's not like Bootstrap, which is where most of the answers are. Colorbox's modal is wrapped by a div with embedded style, not a div with a class that can be easily use in a script:</p>
<pre><code><div style='display:none'>
</code></pre>
<p>I checked <a href="http://www.jacklmoore.com/colorbox/faq/#faq-doctype" rel="nofollow noreferrer">Colorbox FAQ</a> and there's no mention of this problem.</p>
<p>Many of the solutions involve causing the video to pause when the close button is clicked. That could work, except the modal can also be exited by hitting the escape key or clicking anywhere outside the modal. The user can also click an arrow button to load the next modal directly, without explicitly closing the first modal. The video should also stop then. Some other solutions offered are for iframes, which this is not. It's HTML5 video.</p>
<p>Here's a sample of one of many videos on the page. Some of you Eagle Eyes will recognize Drupal markup in the class names. This is a Drupal site that is using Colorbox and Masonry libraries to make a gallery.</p>
<pre><code><div style='display:none'>
<div id="inline-3642" class="colorbox-content flex">
<div class="field field--name-field-gallery-item-title field--type-string field--label-hidden field--item">Test video</div>
<video controls>
<source src="/sites/default/files/FINAL_YouthCreate_2AugustaCAREs.mov" type="video/mp4">
</video>
<div class="field field--name-field-gallery-item-remote-video field--type-file field--label-hidden field--items">
<div class="field--item">
<span class="file file--mime-video-quicktime file--video icon-before"><span class="file-icon"><span class="icon glyphicon glyphicon-film text-primary" aria-hidden="true"></span></span><span class="file-link"><a href="https://opa-website.ddev.site/sites/default/files/FINAL_YouthCreate_2AugustaCAREs.mov" type="video/quicktime; length=47219945" title="Open video in new window" target="_blank" data-toggle="tooltip" data-placement="bottom">FINAL_YouthCreate_2AugustaCAREs.mov</a></span><span class="file-size">45.03 MB</span></span>
</div>
</div>
</div>
</div>
</code></pre>
<p>Here is the code for the thumbnail I click on to launch the modal:</p>
<pre><code><div class="paragraph paragraph--type--masonry-gallery-item paragraph--view-mode--default">
<a class="inline" href="#inline-3642">
<div class="field field--name-field-gallery-item-thumbnail field--type-image field--label-hidden field--item">
<img loading="lazy" src="/sites/default/files/2022-11/thumbnail-movie.png" width="2554" height="1298" alt="movie" typeof="foaf:Image" class="img-responsive" />
</div>
</a>
</div>
</code></pre>
<p>The buttons for going previous/next use the same IDs on all videos:</p>
<pre><code><button type="button" id="cboxNext" style="">next</button>
<button type="button" id="cboxPrevious" style="">previous</button>
</code></pre>
<p>Below in the comments, someone mentioned the initialization of the script.</p>
<pre><code>Drupal.behaviors.colorboxInit = {
attach: function () {
$('.lightbox').click(function(e){
e.preventDefault();
});
$('.lightbox').colorbox({
rel: 'lightbox',
transition:'none',
width: '80%',
height: '80%'
});
$('.inline').colorbox({
inline:true,
rel: 'lightbox',
width: '80%'
});
}
};
</code></pre>
<p>The videos are initialized with the .inline class.</p>
<p>I'd be grateful if anyone is able to point me in the right direction.</p>
| [
{
"answer_id": 74295436,
"author": "IT goldman",
"author_id": 3807365,
"author_profile": "https://Stackoverflow.com/users/3807365",
"pm_score": 0,
"selected": false,
"text": "onClose"
},
{
"answer_id": 74305594,
"author": "Justin Tew",
"author_id": 7010163,
"author_profile": "https://Stackoverflow.com/users/7010163",
"pm_score": 2,
"selected": true,
"text": "Drupal.behaviors.colorboxInit = {\nattach: function () {\n $('.lightbox').click(function (e) {\n e.preventDefault();\n });\n\n $('.lightbox').colorbox({\n rel: 'lightbox',\n transition: 'none',\n width: '80%',\n height: '80%'\n });\n\n $('.inline').colorbox({\n inline: true,\n rel: 'lightbox',\n width: '80%',\n onClosed: function () {\n $('video').each(function () {\n //pause the videos when modal is closed\n $(this).get(0).pause();\n });\n }\n });\n\n jQuery('body').on('click', '#cboxPrevious, #cboxNext', function () {\n jQuery('video').each(function () {\n //pause the videos when next and previouse arrows are used\n jQuery(this).get(0).pause();\n });\n });\n}};\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1836943/"
] |
74,295,049 | <p>I use BigIntegers to store my public and private keys for RSA encryption. Lately I found out that Strings are not safe to store passwords due to them being immutable. Do BigIntegers have the same volnurability?</p>
<p>Currently im refactoring my code so user keys are stored in char arrays instead of Strings when sent from one part of the app to another. I need to know if making BigInteger objects from these char arrays is safe for the users data, or if I need to change that part of my app's functionality as well.</p>
| [
{
"answer_id": 74295529,
"author": "Sam",
"author_id": 4618331,
"author_profile": "https://Stackoverflow.com/users/4618331",
"pm_score": 3,
"selected": true,
"text": "byte[]"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15937198/"
] |
74,295,051 | <p>I am attempting to create a spreadsheet with multiple summary rows, all of which are collapsed when the workbook is opened. I've tried using <code>SummaryRows()</code>, but it collapses the entire spreadsheet into a single group controlled by a single button. My code below will set all of the groups correctly, but they're all expanded by default.</p>
<pre class="lang-cs prettyprint-override"><code>// initialize a row indexer
var currentRow = 1;
// iterate through a collection containing several groups
for (var x in arr_x)
{
// skip a row for the group header
currentRow += 1;
// set start row for current group
var startRow = currentRow;
// iterate through the current group
foreach (var y in x.arr_y)
{
// do spreadsheet things
currentRow++;
}
// get last row of current group
var endRow = currentRow - 1;
// group the rows
sheet.Cells[$"{startRow}:{endRow}"].Rows.Group();
}
// put expando at the top of the groups
sheet.Outline.SummaryRow = SummaryRow.Above;
</code></pre>
<p>Ultimately, I'd like to see a structure like below:</p>
<pre><code>+ | Group 1
+ | Group 2
+ | Group 3
</code></pre>
<p>And when expanded:</p>
<pre><code>- | Group 1
| Item 1
| Item 2
| Item 3
+ | Group 2
+ | Group 3
</code></pre>
| [
{
"answer_id": 74295529,
"author": "Sam",
"author_id": 4618331,
"author_profile": "https://Stackoverflow.com/users/4618331",
"pm_score": 3,
"selected": true,
"text": "byte[]"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10066380/"
] |
74,295,062 | <p>I´d like to check if user input is a float/integer or a letter. For this purpose the use of scanf() is important. My problem is that a letter is saved as zero but I can´t exclude it.</p>
<p>I tried building solving it with if and as a condition I tried isalpha() and is digit().I tried a bunch of other things, but it´s not worth mentioning.</p>
| [
{
"answer_id": 74295529,
"author": "Sam",
"author_id": 4618331,
"author_profile": "https://Stackoverflow.com/users/4618331",
"pm_score": 3,
"selected": true,
"text": "byte[]"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401265/"
] |
74,295,063 | <p>I have a dataset here in which I have to group each sample. The group of each sample is apart of the sample's name. I have the rows each with a semi unique heading. e.g</p>
<pre><code>TCGA.02.0047.GBM.C4, TCGA.02.0055.GBM.C4, TCGA.ZS.A9CG.LIHC.C3, TCGA.ZU.A8S4.CHOL.C1, TCGA.ZX.AA5X.CESC.C2.
</code></pre>
<p>I need to target the C bit in the heading and group the values in that heading so that each sample will be in either, C1, C2, C3 or C4.</p>
<p>How would I go about doing this?</p>
| [
{
"answer_id": 74295529,
"author": "Sam",
"author_id": 4618331,
"author_profile": "https://Stackoverflow.com/users/4618331",
"pm_score": 3,
"selected": true,
"text": "byte[]"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14801643/"
] |
74,295,086 | <p>I am trying to create a program where you enter two values in individual functions and then print them out in the main function. But I am having an error stating that my function is not returning values.</p>
<pre><code>#include <iostream>
#include <iomanip>
using namespace std;
void welcome();
double mass(double m);
double freqnat(double nf);
int main()
{
double attachedmass = 0;
double naturalfrequency = 0;
welcome();
mass(attachedmass);
freqnat(naturalfrequency);
cout << attachedmass << setw(20) << naturalfrequency << endl;
}
void welcome()
{
cout << "Welcome to the spring stiffness program." << endl << endl << "This program calculates spring stiffness using mass and natural frequency to calculate your spring stiffness." << endl << endl;
system("pause");
cout << endl;
}
double mass(double m)
{
cout << "Please enter your desired mass." << endl << endl;
cin >> m;
}
double freqnat(double nf)
{
cout << "Please enter your desired natural frequency." << endl << endl;
cin >> nf;
}
</code></pre>
<p>I tried using return m; and return nf; at the end of the functions, hoping this would tell the function to return the values inputted by the user. Instead, the program does run but the values print out as zeroes.</p>
| [
{
"answer_id": 74295168,
"author": "Pablo Santa Cruz",
"author_id": 67606,
"author_profile": "https://Stackoverflow.com/users/67606",
"pm_score": 1,
"selected": false,
"text": "// storing results in variables\nattachedmass = mass(attachedmass);\nnaturalfrequency = freqnat(naturalfrequency);\n"
},
{
"answer_id": 74295181,
"author": "Robert Shepherd",
"author_id": 19970913,
"author_profile": "https://Stackoverflow.com/users/19970913",
"pm_score": 0,
"selected": false,
"text": "double mass(double& m);\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401312/"
] |
74,295,100 | <p>I am working on making a fiber-based job system for my latest project which will depend on the use of spinlocks for proper functionality. I had intended to use the PAUSE instruction as that seems to be the gold-standard for the waiting portion of your average modern spinlock. However, on doing some research into implementing my own fibers, I came across the fact that the cycle duration of PAUSE on recent machines has increased to an adverse extent.</p>
<p>I found this out from <a href="https://graphitemaster.github.io/fibers/" rel="nofollow noreferrer">here</a>, where it says, quoting the Intel Optimization Manual, "The latency of PAUSE instruction in prior generation microarchitecture is about 10 cycles, whereas on Skylake microarchitecture it has been extended to as many as 140 cycles," and
"As the PAUSE latency has been increased significantly, workloads that are sensitive to PAUSE latency will suffer some performance loss."</p>
<p>As a result, I'd like to find an alternative to the PAUSE instruction for use in my own spinlocks. I've read that in the past, PAUSE has been preferred due to it somehow saving on energy usage which I'm guessing is due to the other often quoted factoid that using PAUSE somehow signals to the processor that it's in the midst of a spinlock. I'm also guessing that this is on the other end of the spectrum power-wise to doing some dummy calculation for the desired number of cycles.</p>
<p>Given this, is there a best-case solution that comes close to PAUSE's apparent energy efficiency while having the flexibility and low-cycle count as a repeat 'throwout' calculation?</p>
| [
{
"answer_id": 74295217,
"author": "Mikdore",
"author_id": 8309536,
"author_profile": "https://Stackoverflow.com/users/8309536",
"pm_score": 0,
"selected": false,
"text": "nanosleep"
},
{
"answer_id": 74296946,
"author": "Peter Cordes",
"author_id": 224132,
"author_profile": "https://Stackoverflow.com/users/224132",
"pm_score": 4,
"selected": true,
"text": "pause"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401194/"
] |
74,295,101 | <p>I have a string in Bash and I want to replace parts of it that match a certain pattern that matches multi-line substrings with an output of a command/function executed with each matched substring as an argument.</p>
<p>The string that I have is the output of this command:</p>
<p><code>openssl s_client -showcerts -connect example.net:443</code></p>
<p>It looks like this (heavily edited for brevity and clarity):</p>
<pre><code>…stuff…
-----BEGIN CERTIFICATE-----
…Base64
multiline
string…
-----END CERTIFICATE-----
…stuff…
-----BEGIN CERTIFICATE-----
…Base64
multiline
string…
-----END CERTIFICATE-----
…stuff…
</code></pre>
<p>I want to replace the sections starting with <code>-----BEGIN CERTIFICATE-----</code> and ending with <code>-----END CERTIFICATE-----</code> with the output of the following command:</p>
<p><code>openssl x509 -in certificate.crt -text -noout</code></p>
<p>This command takes an input which is the Base64 string in between the above two markers (including the markers) and outputs a textual representation of the Base64.</p>
<p>My desired substitution is one where the Base64 lines get replaced by the output of the above command.</p>
<p>This means I need:</p>
<ul>
<li>An ability to specify a multi-line pattern (the two markers and lines between them)</li>
<li>An ability to use a Bash function as the replacer predicate
<ul>
<li>The function writes the matched substring to a file</li>
<li>The function then executes the above command with the temporary file at input</li>
<li>The function deletes the file</li>
<li>The function returns the output of the command</li>
</ul>
</li>
</ul>
<p>The desired output looks like this:</p>
<pre><code>…stuff…
-----BEGIN CERTIFICATE-----
…Textual
multiline
output…
-----END CERTIFICATE-----
…stuff…
-----BEGIN CERTIFICATE-----
…Textual
multiline
output…
-----END CERTIFICATE-----
…stuff…
</code></pre>
<p>I have found a few solutions on how to do one and the other using sed but I was not able to combine them. Eventually, I managed to get this mix of Bash and Python, but I am interested in a pure Bash solution:</p>
<pre class="lang-bash prettyprint-override"><code>echo | openssl s_client -showcerts -connect example.net:443 | python3 -c "
import fileinput
import re
import subprocess
import os
stdin=''.join(fileinput.input())
def replace(match):
with open('temp.crt', 'w') as text_file:
print(match.group(), file=text_file)
process = subprocess.run(['openssl', 'x509', '-in', 'temp.crt', '-text', '-noout'], capture_output=True, text=True)
os.remove('temp.crt')
return '-----BEGIN CERTIFICATE-----\n' + process.stdout + '\n-----END CERTIFICATE-----'
stdout=re.sub(r'-----BEGIN CERTIFICATE-----(\n(.*\n)+?)-----END CERTIFICATE-----', replace, stdin)
print(stdout)
"
</code></pre>
<p>I am trying to get something similar to this pseudocode to work:</p>
<pre class="lang-bash prettyprint-override"><code>echo \
| openssl s_client -showcerts -connect example.net:443 \
| sed 's/-----BEGIN CERTIFICATE-----\n.*?-----END CERTIFICATE-----/$(openssl x509 -in \0 -text -noout)/e'
</code></pre>
<p>I am not precious about using sed for this, but I also tried with awk and perl and did not get anywhere. Maybe OpenSSL can do this and I don't even need the substitution? Haven't found anything on that.</p>
<p>Is there a Bash one-line which can do all this?</p>
| [
{
"answer_id": 74295217,
"author": "Mikdore",
"author_id": 8309536,
"author_profile": "https://Stackoverflow.com/users/8309536",
"pm_score": 0,
"selected": false,
"text": "nanosleep"
},
{
"answer_id": 74296946,
"author": "Peter Cordes",
"author_id": 224132,
"author_profile": "https://Stackoverflow.com/users/224132",
"pm_score": 4,
"selected": true,
"text": "pause"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2715716/"
] |
74,295,110 | <p>I was given the following instructions:</p>
<blockquote>
<ol>
<li>Make the first instruction in your code a <code>jmp</code></li>
<li>Make that <code>jmp</code> a relative jump to 0x51 bytes from its current position</li>
<li>At 0x51 write the following code:</li>
<li>Place the top value on the stack into register RDI</li>
<li><code>jmp</code> to the absolute address 0x403000</li>
</ol>
</blockquote>
<p>What I did so far is:</p>
<pre><code>.intel_syntax noprefix
.global _start
_start:
jmp $+0x51
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
pop rdi
mov eax, 0x403000
jmp rax
</code></pre>
<p>Isn't this exactly what is required by the assignment? Is there a problem with the relative jump or the absolute jump?</p>
<p>EDIT:</p>
<p>I tried to change the absolute jump with the following, but still no result:</p>
<pre><code> . . .
nop
pop rdi
mov rax, 0x403000
jmp fword ptr [eax]
</code></pre>
<p>If it can help, <a href="https://pastebin.com/g2qQR7PP" rel="nofollow noreferrer">this</a> is the object dump derived from the assembled file.</p>
| [
{
"answer_id": 74296592,
"author": "Peter Cordes",
"author_id": 224132,
"author_profile": "https://Stackoverflow.com/users/224132",
"pm_score": 2,
"selected": false,
"text": "$+0x51"
},
{
"answer_id": 74310091,
"author": "Samir Amir",
"author_id": 20401332,
"author_profile": "https://Stackoverflow.com/users/20401332",
"pm_score": 1,
"selected": false,
"text": "pop"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401332/"
] |
74,295,126 | <p>I need to know how can I create a button, that has <a href="https://techupnext.com/emo-captions/" rel="nofollow noreferrer">red</a> color in starting but when get the mouse to it, it changes to orange.</p>
<p>I need to create button like this for my website.</p>
| [
{
"answer_id": 74296592,
"author": "Peter Cordes",
"author_id": 224132,
"author_profile": "https://Stackoverflow.com/users/224132",
"pm_score": 2,
"selected": false,
"text": "$+0x51"
},
{
"answer_id": 74310091,
"author": "Samir Amir",
"author_id": 20401332,
"author_profile": "https://Stackoverflow.com/users/20401332",
"pm_score": 1,
"selected": false,
"text": "pop"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401356/"
] |
74,295,147 | <p>I got a table like this one</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>CaseID</th>
<th>NAME</th>
<th>ADDRESS</th>
<th>ZIP</th>
<th>ROLE</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Joe</td>
<td>address_1</td>
<td>zip_1</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>John</td>
<td>address_2</td>
<td>zip_2</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>Jane</td>
<td>address_3</td>
<td>zip_3</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>Bill</td>
<td>address_4</td>
<td>zip_4</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>Bill</td>
<td>address_5</td>
<td>zip_5</td>
<td>role_2</td>
</tr>
<tr>
<td>2</td>
<td>Bob</td>
<td>address_6</td>
<td>zip_6</td>
<td>role_1</td>
</tr>
<tr>
<td>2</td>
<td>Shawn</td>
<td>address_7</td>
<td>zip_7</td>
<td>role_1</td>
</tr>
</tbody>
</table>
</div>
<p>I would like to group by the name and CaseID, making a list of the roles in each group. That part is easy. The tricky part is that as you can see for Bill, we have two different addresses and zip. I tried to keep only one with a Max or Min aggregation function inside the group, but there might be inconsistency in the resulting address, keeping zip of one row and the address of the other raw. How can I fetch the zip and address of the same row (which ever) in a group and listing all the roles. I'd like a result like</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>CaseID</th>
<th>NAME</th>
<th>ADDRESS</th>
<th>ZIP</th>
<th>ROLE</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Joe</td>
<td>address_1</td>
<td>zip_1</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>John</td>
<td>address_2</td>
<td>zip_2</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>Jane</td>
<td>address_3</td>
<td>zip_3</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>Bill</td>
<td>address_4</td>
<td>zip_4</td>
<td>role_1, role_2</td>
</tr>
<tr>
<td>2</td>
<td>Bob</td>
<td>address_6</td>
<td>zip_6</td>
<td>role_1</td>
</tr>
<tr>
<td>2</td>
<td>Shawn</td>
<td>address_7</td>
<td>zip_7</td>
<td>role_1</td>
</tr>
</tbody>
</table>
</div>
<p>or</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>CaseID</th>
<th>NAME</th>
<th>ADDRESS</th>
<th>ZIP</th>
<th>ROLE</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Joe</td>
<td>address_1</td>
<td>zip_1</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>John</td>
<td>address_2</td>
<td>zip_2</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>Jane</td>
<td>address_3</td>
<td>zip_3</td>
<td>role_1</td>
</tr>
<tr>
<td>1</td>
<td>Bill</td>
<td>address_5</td>
<td>zip_5</td>
<td>role_1, role_2</td>
</tr>
<tr>
<td>2</td>
<td>Bob</td>
<td>address_6</td>
<td>zip_6</td>
<td>role_1</td>
</tr>
<tr>
<td>2</td>
<td>Shawn</td>
<td>address_7</td>
<td>zip_7</td>
<td>role_1</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74295310,
"author": "Littlefoot",
"author_id": 9097906,
"author_profile": "https://Stackoverflow.com/users/9097906",
"pm_score": 0,
"selected": false,
"text": "SQL> with test (caseid, name, address, zip, role) as\n 2 (select 1, 'Joe' , 'address_1', 'zip_1', 'role_1' from dual union all\n 3 select 1, 'John', 'address_2', 'zip_2', 'role_1' from dual union all\n 4 select 1, 'Bill', 'address_4', 'zip_4', 'role_1' from dual union all\n 5 select 1, 'Bill', 'address_5', 'zip_5', 'role_2' from dual union all\n 6 select 2, 'Bob' , 'address_6', 'zip_6', 'role_1' from dual\n 7 ),\n"
},
{
"answer_id": 74295366,
"author": "GMB",
"author_id": 10676716,
"author_profile": "https://Stackoverflow.com/users/10676716",
"pm_score": 3,
"selected": true,
"text": "keep"
},
{
"answer_id": 74295433,
"author": "nimdil",
"author_id": 1119305,
"author_profile": "https://Stackoverflow.com/users/1119305",
"pm_score": 0,
"selected": false,
"text": "select \n caseid, name, \n min(address) keep (dense_rank first order by address, zip), \n min(zip) keep (dense_rank first order by address, zip), \n listagg(role)\nfrom <crappy table> \ngroup by caseid, name\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1141818/"
] |
74,295,149 | <p>How is it possible to show all orders which are not completely paid off related to a client? for e.g.</p>
<p>SHOW ALL order details of ‘unpaid’ ORDERS for CLIENT ‘50’</p>
<p>table: orders</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>order_total</th>
<th>client_id</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>15.00</td>
<td>50</td>
</tr>
<tr>
<td>2</td>
<td>18.50</td>
<td>50</td>
</tr>
<tr>
<td>3</td>
<td>40.00</td>
<td>50</td>
</tr>
</tbody>
</table>
</div>
<p>table: order_payments</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>order_id</th>
<th>total_paid</th>
<th>payment_status</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>15.00</td>
<td>paid</td>
</tr>
<tr>
<td>2</td>
<td>3.50</td>
<td>open</td>
</tr>
<tr>
<td>2</td>
<td>12.00</td>
<td>paid</td>
</tr>
</tbody>
</table>
</div>
<p>*** NOTE: Not every order has a registered payment. No registered payment should be considered "open" ***</p>
<p>Expected results:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>order_id</th>
<th>order_total</th>
<th>client_id</th>
<th>outstanding</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>15.00</td>
<td>50</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
<td>18.50</td>
<td>50</td>
<td>6.50</td>
</tr>
<tr>
<td>3</td>
<td>40.00</td>
<td>50</td>
<td>40.00</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74295421,
"author": "Florianb",
"author_id": 5299500,
"author_profile": "https://Stackoverflow.com/users/5299500",
"pm_score": 2,
"selected": true,
"text": "SELECT o.id AS order_id, o.order_total, o.client_id, \n(o.order_total - SUM(IF(op.payment_status = 'paid', op.total_paid, 0))) AS outstanding \nFROM orders o\n LEFT JOIN order_payments op ON o.id = op.order_id\nGROUP BY o.id\nORDER BY outstanding ASC\n"
},
{
"answer_id": 74295730,
"author": "GMB",
"author_id": 10676716,
"author_profile": "https://Stackoverflow.com/users/10676716",
"pm_score": 0,
"selected": false,
"text": "select o.*, op.total_paid, o.order_total - op.total_paid outstanding\nfrom orders o\ncross join lateral (\n select coalesce(sum(op.total_paid), 0) total_paid \n from order_payments op \n where payment_status = 'open' and op.order_id = o.id\n) op\n"
},
{
"answer_id": 74299822,
"author": "Jaykar",
"author_id": 16171968,
"author_profile": "https://Stackoverflow.com/users/16171968",
"pm_score": 0,
"selected": false,
"text": "SELECT \n orderss.id, orderss.ORDER_TOTAL, orderss.CLIENT_ID,\n nvl(A.Total_paid,0) AS TOTAL_PAID,\n Orderss.ORDER_TOTAL-nvl(A.Total_paid,0) AS TOTAL_OUTSTANDING\nFROM orders\nLEFT JOIN\n (SELECT id,payment_status,Total_paid\n FROM order_paymentss\n GROUP BY id,payment_status,Total_paid\n HAVING Payment_status='paid'\n ) A \n ON orderss.id=A.id;\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401337/"
] |
74,295,185 | <p>The Standard "apparently" defines "enumeration type" in [dcl.enum]/<a href="http://eel.is/c++draft/dcl.enum#1" rel="nofollow noreferrer">1</a>. The term "enumerated type" is defined <a href="http://eel.is/c++draft/enumerated.types" rel="nofollow noreferrer">here</a>.</p>
| [
{
"answer_id": 74295421,
"author": "Florianb",
"author_id": 5299500,
"author_profile": "https://Stackoverflow.com/users/5299500",
"pm_score": 2,
"selected": true,
"text": "SELECT o.id AS order_id, o.order_total, o.client_id, \n(o.order_total - SUM(IF(op.payment_status = 'paid', op.total_paid, 0))) AS outstanding \nFROM orders o\n LEFT JOIN order_payments op ON o.id = op.order_id\nGROUP BY o.id\nORDER BY outstanding ASC\n"
},
{
"answer_id": 74295730,
"author": "GMB",
"author_id": 10676716,
"author_profile": "https://Stackoverflow.com/users/10676716",
"pm_score": 0,
"selected": false,
"text": "select o.*, op.total_paid, o.order_total - op.total_paid outstanding\nfrom orders o\ncross join lateral (\n select coalesce(sum(op.total_paid), 0) total_paid \n from order_payments op \n where payment_status = 'open' and op.order_id = o.id\n) op\n"
},
{
"answer_id": 74299822,
"author": "Jaykar",
"author_id": 16171968,
"author_profile": "https://Stackoverflow.com/users/16171968",
"pm_score": 0,
"selected": false,
"text": "SELECT \n orderss.id, orderss.ORDER_TOTAL, orderss.CLIENT_ID,\n nvl(A.Total_paid,0) AS TOTAL_PAID,\n Orderss.ORDER_TOTAL-nvl(A.Total_paid,0) AS TOTAL_OUTSTANDING\nFROM orders\nLEFT JOIN\n (SELECT id,payment_status,Total_paid\n FROM order_paymentss\n GROUP BY id,payment_status,Total_paid\n HAVING Payment_status='paid'\n ) A \n ON orderss.id=A.id;\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2337207/"
] |
74,295,206 | <p>for example I want to edit the key that is 2 in this map and make it 3, how can I do that?</p>
<pre><code>Map<Integer,Integer>map=new HashMap<>();
map.put(2,2);
map.get(2)=3;
</code></pre>
| [
{
"answer_id": 74295226,
"author": "Marcus Dunn",
"author_id": 12639399,
"author_profile": "https://Stackoverflow.com/users/12639399",
"pm_score": 1,
"selected": false,
"text": "Map<Integer,Integer>map=new HashMap<>();\nmap.put(2,2);\nvar removed = map.remove(2);\nmap.put(3, removed);\n"
},
{
"answer_id": 74295231,
"author": "Louis Wasserman",
"author_id": 869736,
"author_profile": "https://Stackoverflow.com/users/869736",
"pm_score": 0,
"selected": false,
"text": "map.get(2) = 3"
},
{
"answer_id": 74295285,
"author": "Sasa Arsenovic",
"author_id": 13000604,
"author_profile": "https://Stackoverflow.com/users/13000604",
"pm_score": 0,
"selected": false,
"text": "map.put(2, 3); \n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18690175/"
] |
74,295,228 | <p>I need some states from different component
But atm only the latest state that changed is shown when i console.log them is shown correctly 3 out the 4 are undefined.</p>
<p>My Action and Reduxer</p>
<pre><code>export const paypal_error =
(time, timevalidation, acceptBox, sliderDeliveryValue) => (dispatch) => {
dispatch({
type: 'PAYPAL_ERROR',
payload: {
time,
timevalidation,
acceptBox,
sliderDeliveryValue,
},
});
};
export const paypalReducer = (state = {}, action) => {
switch (action.type) {
case 'PAYPAL_ERROR':
return {
...state,
time: action.payload.time,
timevalidation: action.payload.timevalidation,
acceptBox: action.payload.acceptBox,
sliderDeliveryValue: action.payload.sliderDeliveryValue,
};
default:
return state;
}
};
</code></pre>
<p>My dispatchs, each in a different component</p>
<pre><code>dispatch(paypal_error({ time: date }))
dispatch(paypal_error({ sliderDeliveryValue: event.target.value }));
dispatch(paypal_error({ timeValidation: false }));
dispatch(paypal_error({ acceptBox: !acceptBox }));
</code></pre>
| [
{
"answer_id": 74295261,
"author": "Konrad",
"author_id": 5089567,
"author_profile": "https://Stackoverflow.com/users/5089567",
"pm_score": 0,
"selected": false,
"text": "state"
},
{
"answer_id": 74295734,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 2,
"selected": true,
"text": "export const paypalReducer = (state = {}, action) => {\n switch (action.type) {\n case 'PAYPAL_ERROR':\n return {\n ...state,\n time: action.payload.time ?? state.time,\n timevalidation: action.payload.timevalidation ?? state.timevalidation,\n acceptBox: action.payload.acceptBox ?? state.acceptbox,\n sliderDeliveryValue:\n action.payload.sliderDeliveryValue ?? state.sliderDeliveryValue,\n };\n\n default:\n return state;\n }\n};\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20199710/"
] |
74,295,232 | <p>My server sends a request via WebClient and the code is below:</p>
<pre><code>public String getResponse(String requestBody){
...
WebClient.RequestHeadersSpec<?> request =
client.post().body(BodyInserters.fromValue(requestBody));
String resp =
request.retrieve().bodyToMono(String.class)
.doOnError(
WebClientResponseException.class,
err -> {
// do something
})
.block();
return resp;
}
</code></pre>
<p>I wrote a unit test for it and want to mock the WebClient so that I can receive the expected response:</p>
<pre><code>when(webClientMock.post()).thenReturn(requestBodyUriMock);
when(requestBodyUriMock.body(BodyInserters.fromValue(requestBody))).thenReturn(requestHeadersMock);
when(requestHeadersMock.retrieve()).thenReturn(responseMock);
when(responseMock.bodyToMono(String.class)).thenReturn(Mono.just("response"));
String response = someServiceSpy.getResponse(requestBody);
assertEquals(Mono.just("response"), response);
</code></pre>
<p>However, the result is not the <code>"response"</code> but a html file. I think I made a mistake somewhere but I don't know how to fix it.</p>
| [
{
"answer_id": 74295743,
"author": "Ben Borchard",
"author_id": 4054720,
"author_profile": "https://Stackoverflow.com/users/4054720",
"pm_score": 2,
"selected": false,
"text": "client"
},
{
"answer_id": 74309040,
"author": "Meilan",
"author_id": 8898054,
"author_profile": "https://Stackoverflow.com/users/8898054",
"pm_score": 1,
"selected": true,
"text": "WebClient"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8898054/"
] |
74,295,274 | <p>I want to display an integer number in html which I get from a rest api call as json response. But in my HTML page it is displayed with a comma. So now when I want to accept the fields and save my record, the field shows a error message: "Please enter a valid schema".</p>
<p>That's my code:</p>
<p>HTML:</p>
<pre><code><div class="mb-3">
<label for="disabledTextInput" class="form-label">Pages</label>
<input type="number" class="form-control" name="pages" value="${book.pages}">
</div>
</code></pre>
<p>The field in json:</p>
<pre><code>"pageCount": 1531
</code></pre>
<p>That's the result with separator:</p>
<p><a href="https://i.stack.imgur.com/NQNJM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NQNJM.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74295743,
"author": "Ben Borchard",
"author_id": 4054720,
"author_profile": "https://Stackoverflow.com/users/4054720",
"pm_score": 2,
"selected": false,
"text": "client"
},
{
"answer_id": 74309040,
"author": "Meilan",
"author_id": 8898054,
"author_profile": "https://Stackoverflow.com/users/8898054",
"pm_score": 1,
"selected": true,
"text": "WebClient"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5397752/"
] |
74,295,289 | <p>I have the following in my app properties</p>
<pre><code>spring:
main:
banner-mode: off
allow-bean-definition-overriding: true
config:
uri: http://localhost:8890
</code></pre>
<p>I have this class:</p>
<pre><code>@RefreshScope
@Configuration
@Getter
public class Service {
@Value("${Some Value}")
Boolean val;
}
</code></pre>
<p>The problem, is that my app does not grab the configuration from the localhost running configuration server. I can tell you that my local config server is working fine and that the config is visible in a browser</p>
| [
{
"answer_id": 74295743,
"author": "Ben Borchard",
"author_id": 4054720,
"author_profile": "https://Stackoverflow.com/users/4054720",
"pm_score": 2,
"selected": false,
"text": "client"
},
{
"answer_id": 74309040,
"author": "Meilan",
"author_id": 8898054,
"author_profile": "https://Stackoverflow.com/users/8898054",
"pm_score": 1,
"selected": true,
"text": "WebClient"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5974780/"
] |
74,295,296 | <p>I want to launch Excel using <code>subprocess.Popen()</code> but my script doesn't work as expected.</p>
<p>The following simple script doesn't work in the way I want it to work. It looks like Excel is terminated immediately when the script ends. What do I need to do to keep it open?</p>
<pre><code>import subprocess
subprocess.Popen(r'C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE')
</code></pre>
<p>If I enter the same codes into the interactive shell, it works as expected and Excel stays open.</p>
<p>Any help would be greatly appreciated!</p>
| [
{
"answer_id": 74322935,
"author": "Omer Dagry",
"author_id": 15010874,
"author_profile": "https://Stackoverflow.com/users/15010874",
"pm_score": 0,
"selected": false,
"text": "import os\nos.system(\"start excel.exe\")\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20393628/"
] |
74,295,357 | <p>In SQL Server, I have two strings. Need to check if string1 is a substring of string2. It should exactly match a word in the sentence.</p>
<p>String2: <code>El Alfi Abdullah Ahmed Abdullah</code></p>
<ul>
<li>Match Scenario: String1: <code>Ahmed</code></li>
<li>No match Scenario: String1: <code>Ahme</code></li>
</ul>
<pre><code>declare @string2 varchar(max) = 'El Alfi Abdullah Ahmed Abdullah';
declare @string1 varchar(max) = 'Ahmed';
</code></pre>
| [
{
"answer_id": 74295416,
"author": "John Cappelletti",
"author_id": 1570000,
"author_profile": "https://Stackoverflow.com/users/1570000",
"pm_score": 3,
"selected": true,
"text": "declare @string2 varchar(max) = 'El Alfi Abdullah Ahmed Abdullah';\ndeclare @string1 varchar(max) = 'Ahmed';\n\nSelect hits = count(*)\n From string_split(@string2,' ')\n Where value = @string1\n"
},
{
"answer_id": 74296207,
"author": "Stu",
"author_id": 15332650,
"author_profile": "https://Stackoverflow.com/users/15332650",
"pm_score": 0,
"selected": false,
"text": "select iif(Len(@string2) - Len(@string1) \n = Len(Replace(@string2, @string1, '')), 1, 0) IsSubstring;\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14986661/"
] |
74,295,369 | <p>I have a fixed position input.txt file like this:</p>
<blockquote>
<p>4033667 70040118401401<br />
4033671 70040/8401901 < not int because of "/"<br />
4033669 70040118401301<br />
4033673 70060118401101</p>
</blockquote>
<p>I'm using a text file input step to pull the data in, and I'd like to load the data into a database as int's and have errant data go to a log file.</p>
<p>I've tried to using the filter step and the data validator step, but I can't seem to get either to work. I've even tried using the text input field to bring it in as a string and then converting it to an int w/ the Select/Rename values Step, and changing the data-type in meta-data section.</p>
<p>a typical error I keep running into is "String : couldn't convert String to Integer"</p>
<p>Any suggestions?</p>
<p>Thanks!</p>
| [
{
"answer_id": 74295416,
"author": "John Cappelletti",
"author_id": 1570000,
"author_profile": "https://Stackoverflow.com/users/1570000",
"pm_score": 3,
"selected": true,
"text": "declare @string2 varchar(max) = 'El Alfi Abdullah Ahmed Abdullah';\ndeclare @string1 varchar(max) = 'Ahmed';\n\nSelect hits = count(*)\n From string_split(@string2,' ')\n Where value = @string1\n"
},
{
"answer_id": 74296207,
"author": "Stu",
"author_id": 15332650,
"author_profile": "https://Stackoverflow.com/users/15332650",
"pm_score": 0,
"selected": false,
"text": "select iif(Len(@string2) - Len(@string1) \n = Len(Replace(@string2, @string1, '')), 1, 0) IsSubstring;\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7479081/"
] |
74,295,418 | <p>In python, if <code>x,y</code> are vectors, I expected <code>x @ y.T</code> to give me the outer product of x and y, i.e. to match the result of <code>np.outer(x,y)</code>. However, to my surprise, <code>x @ y.T</code> returns a scalar. Why? Are vectors (i.e. one-dimensional arrays) not considered to be column vectors by numpy?</p>
<p>For example, the code</p>
<pre><code>import numpy as np
x=np.array([1,2])
y=np.array([3,4])
wrong_answer = x @ y.T
right_answer = np.outer(x,y)
</code></pre>
<p>gives the (interactive) output</p>
<pre><code>In [1]: wrong_answer
Out[1]: 11
In [2]: right_answer
Out[2]:
array([[3, 4],
[6, 8]])
</code></pre>
| [
{
"answer_id": 74295498,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 0,
"selected": false,
"text": "@"
},
{
"answer_id": 74295536,
"author": "Zach J.",
"author_id": 20276330,
"author_profile": "https://Stackoverflow.com/users/20276330",
"pm_score": 1,
"selected": false,
"text": "@"
},
{
"answer_id": 74296485,
"author": "hpaulj",
"author_id": 901925,
"author_profile": "https://Stackoverflow.com/users/901925",
"pm_score": 0,
"selected": false,
"text": "np.transpose"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3842030/"
] |
74,295,441 | <p>Using selenium in Python, I have been able to successfully access some url's of an image I want to download. However, the image link is stored within a srcset image attribute. When I use get_attribute('srcset'), it returns a string with the 4 links. I just want the one. How would I go about doing this? Could I possibly just crop the string afterwards?</p>
<p>Here's the site that I am scraping from:</p>
<p><a href="https://www.politicsanddesign.com/" rel="nofollow noreferrer">https://www.politicsanddesign.com/</a></p>
<p>Here is my code:</p>
<pre><code>from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
import pyautogui
import time
chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(ChromeDriverManager().install(), options = chrome_options)
driver.get('https://www.politicsanddesign.com/')
img_url = driver.find_element(By.XPATH, "//div[@class = 'responsive-image-wrapper']/img").get_attribute("srcset")
driver.get(img_url)
</code></pre>
<p>And here is what the img_url object looks like:</p>
<pre><code>//images.ctfassets.net/00vgtve3ank7/6f38yjnNcU1d6dw0jt1Uhk/70dfbf208b22f7b1c08b7421f910bb36/2020_HOUSE_VA-04_D-MCEACHIN..jpg?w=400&fm=jpg&q=80 400w, //images.ctfassets.net/00vgtve3ank7/6f38yjnNcU1d6dw0jt1Uhk/70dfbf208b22f7b1c08b7421f910bb36/2020_HOUSE_VA-04_D-MCEACHIN..jpg?w=800&fm=jpg&q=80 800w, //images.ctfassets.net/00vgtve3ank7/6f38yjnNcU1d6dw0jt1Uhk/70dfbf208b22f7b1c08b7421f910bb36/2020_HOUSE_VA-04_D-MCEACHIN..jpg?w=1200&fm=jpg&q=80 1200w, //images.ctfassets.net/00vgtve3ank7/6f38yjnNcU1d6dw0jt1Uhk/70dfbf208b22f7b1c08b7421f910bb36/2020_HOUSE_VA-04_D-MCEACHIN..jpg?w=1800&fm=jpg&q=80 1800w
</code></pre>
<p>But I'd like it to just be:</p>
<pre><code>//images.ctfassets.net/00vgtve3ank7/6f38yjnNcU1d6dw0jt1Uhk/70dfbf208b22f7b1c08b7421f910bb36/2020_HOUSE_VA-04_D-MCEACHIN..jpg?w=400&fm=jpg&q=80
</code></pre>
| [
{
"answer_id": 74295688,
"author": "Damon C. Roberts",
"author_id": 12394134,
"author_profile": "https://Stackoverflow.com/users/12394134",
"pm_score": 0,
"selected": false,
"text": "from selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom webdriver_manager.chrome import ChromeDriverManager\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver import ActionChains\nimport pyautogui\nimport time\n\n# WILL NEED TO EVENTUALLY FIGURE OUT HOW TO WRAP ALL OF THIS INTO A FUNCTION OR LOOP TO DO IT FOR ALL DIV OBJECTS\nchrome_options = Options()\nchrome_options.add_argument(\"--headless\")\ndriver = webdriver.Chrome(ChromeDriverManager().install(), options = chrome_options)\ndriver.get('https://www.politicsanddesign.com/')\nimg_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"srcset\")\ndriver.get(img_url)\nimg_url2 = 'https:' + img_url.split(' 400w',1)[0]\ndriver.get(img_url2)\n"
},
{
"answer_id": 74295883,
"author": "Gowthaman Ravindran",
"author_id": 10747860,
"author_profile": "https://Stackoverflow.com/users/10747860",
"pm_score": 2,
"selected": true,
"text": "img_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"currentSrc\")\ndriver.get(img_url)\n"
},
{
"answer_id": 74296010,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 1,
"selected": false,
"text": "from selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom webdriver_manager.chrome import ChromeDriverManager\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver import ActionChains\nimport pyautogui\nimport time\n\nchrome_options = Options()\nchrome_options.add_argument(\"--headless\")\ndriver = webdriver.Chrome(ChromeDriverManager().install(), options = chrome_options)\ndriver.get('https://www.politicsanddesign.com/')\nimg_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"srcset\")\nimg_urls = img_url.split(\",\")\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12394134/"
] |
74,295,450 | <p>something happens to babel, it can't compile my storybook code</p>
<p>I'm trying to assemble a boilerplate with storybook and nextjs</p>
<p>I did a search and couldn't find a solution to this problem, if anyone can help I would be grateful</p>
<p>This is the error I get when trying to build</p>
<pre><code>info - Linting and checking validity of types ..warn - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config
info - Linting and checking validity of types
info - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
> [PWA] Compile client (static)
> [PWA] Auto register service worker with: /home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next-pwa/register.js
> [PWA] Service worker: /home/crepszz/Desktop/boilerplate/boilerplate/.next/sw.js
> [PWA] url: /sw.js
> [PWA] scope: /
> [PWA] Compile server
> [PWA] Compile server
info - Using external babel configuration from /home/crepszz/Desktop/boilerplate/boilerplate/.babelrc
info - Creating an optimized production build
Failed to compile.
./src/pages/_app.tsx
Error: [BABEL] /home/crepszz/Desktop/boilerplate/boilerplate/src/pages/_app.tsx: You gave us a visitor for the node type TSSatisfiesExpression but it's not a valid type
at verify (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:397612)
at Function.explode (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:396515)
at /home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:49254
at Generator.next (<anonymous>)
at Function.<anonymous> (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:79767)
at Generator.next (<anonymous>)
at evaluateSync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:717268)
at Function.sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:715284)
at sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:80263)
at sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:716601)
./src/pages/_document.tsx
Error: [BABEL] /home/crepszz/Desktop/boilerplate/boilerplate/src/pages/_document.tsx: You gave us a visitor for the node type TSSatisfiesExpression but it's not a valid type
at verify (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:397612)
at Function.explode (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:396515)
at /home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:49254
at Generator.next (<anonymous>)
at Function.<anonymous> (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:79767)
at Generator.next (<anonymous>)
at evaluateSync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:717268)
at Function.sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:715284)
at sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:80263)
at sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:716601)
./src/pages/index.tsx
Error: [BABEL] /home/crepszz/Desktop/boilerplate/boilerplate/src/pages/index.tsx: You gave us a visitor for the node type TSSatisfiesExpression but it's not a valid type
at verify (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:397612)
at Function.explode (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:396515)
at /home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:49254
at Generator.next (<anonymous>)
at Function.<anonymous> (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:79767)
at Generator.next (<anonymous>)
at evaluateSync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:717268)
at Function.sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:715284)
at sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1:80263)
at sync (/home/crepszz/Desktop/boilerplate/boilerplate/node_modules/next/dist/compiled/babel/bundle.js:1910:716601)
> Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
</code></pre>
<p>//_app.tsx</p>
<pre><code>import type { AppProps } from 'next/app'
import Head from 'next/head'
import GlobalStyles from '../styles/global'
export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<title>React Avançado</title>
<link rel="shortcut icon" href="" />
<link rel="manifest" href="/manifest.json" />
<meta
name="description"
content="A simple project starter to work with Typescript"
/>
</Head>
<GlobalStyles />
<Component {...pageProps} />
</>
)
}
</code></pre>
<p>//__document.tsx</p>
<pre><code>import Document, {
Html,
Head,
Main,
NextScript,
DocumentContext
} from 'next/document'
import { ServerStyleSheet } from 'styled-components'
export default class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const sheet = new ServerStyleSheet()
const originalRenderPage = ctx.renderPage
try {
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App) => (props) =>
sheet.collectStyles(<App {...props} />)
})
const initialProps = await Document.getInitialProps(ctx)
return {
...initialProps,
styles: [initialProps.styles, sheet.getStyleElement()]
}
} finally {
sheet.seal()
}
}
render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
</code></pre>
<p>//index.tsx</p>
<pre><code>import Main from 'components/Main'
export default function Home() {
return <Main />
}
</code></pre>
<p>//next.config.js</p>
<pre><code>/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true
}
module.exports = nextConfig
module.exports = {
experimental: {
forceSwcTransforms: true
}
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withPWA = require('next-pwa')
const isProd = process.env.NODE_ENV === 'production'
module.exports = withPWA({
pwa: {
dest: 'public',
disable: !isProd
}
})
</code></pre>
<p>//package.json</p>
<pre><code>{
"name": "boilerplate",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "jest",
"test:watch": "yarn test --watch",
"storybook": "start-storybook -s ./public -p 6006",
"build-storybook": "build-storybook"
},
"lint-staged": {
"src/**/*": [
"yarn lint --fix",
"yarn test --findRelatedTests --bail"
]
},
"dependencies": {
"next": "13.0.0",
"next-pwa": "^5.6.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"styled-components": "^5.3.6"
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/preset-typescript": "^7.18.6",
"@storybook/addon-essentials": "^6.5.13",
"@storybook/builder-webpack5": "^6.5.13",
"@storybook/manager-webpack5": "^6.5.13",
"@storybook/react": "^6.5.13",
"@storybook/testing-library": "^0.0.13",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.2.0",
"@types/node": "18.11.7",
"@types/react": "18.0.24",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"babel-loader": "^8.2.5",
"babel-plugin-styled-components": "^2.0.7",
"eslint": "8.26.0",
"eslint-config-next": "13.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.31.10",
"eslint-plugin-react-hooks": "^4.6.0",
"jest": "^29.2.2",
"jest-environment-jsdom": "^29.2.2",
"jest-styled-components": "^7.1.1",
"prettier": "2.7.1",
"typescript": "4.8.4"
}
}
</code></pre>
| [
{
"answer_id": 74295688,
"author": "Damon C. Roberts",
"author_id": 12394134,
"author_profile": "https://Stackoverflow.com/users/12394134",
"pm_score": 0,
"selected": false,
"text": "from selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom webdriver_manager.chrome import ChromeDriverManager\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver import ActionChains\nimport pyautogui\nimport time\n\n# WILL NEED TO EVENTUALLY FIGURE OUT HOW TO WRAP ALL OF THIS INTO A FUNCTION OR LOOP TO DO IT FOR ALL DIV OBJECTS\nchrome_options = Options()\nchrome_options.add_argument(\"--headless\")\ndriver = webdriver.Chrome(ChromeDriverManager().install(), options = chrome_options)\ndriver.get('https://www.politicsanddesign.com/')\nimg_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"srcset\")\ndriver.get(img_url)\nimg_url2 = 'https:' + img_url.split(' 400w',1)[0]\ndriver.get(img_url2)\n"
},
{
"answer_id": 74295883,
"author": "Gowthaman Ravindran",
"author_id": 10747860,
"author_profile": "https://Stackoverflow.com/users/10747860",
"pm_score": 2,
"selected": true,
"text": "img_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"currentSrc\")\ndriver.get(img_url)\n"
},
{
"answer_id": 74296010,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 1,
"selected": false,
"text": "from selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom webdriver_manager.chrome import ChromeDriverManager\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver import ActionChains\nimport pyautogui\nimport time\n\nchrome_options = Options()\nchrome_options.add_argument(\"--headless\")\ndriver = webdriver.Chrome(ChromeDriverManager().install(), options = chrome_options)\ndriver.get('https://www.politicsanddesign.com/')\nimg_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"srcset\")\nimg_urls = img_url.split(\",\")\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20363957/"
] |
74,295,481 | <p>I'm trying to make some plots with plotnine.</p>
<p>I have clustered points into several clusters labeled 0 through 6. (but this range may change depending on the number of clusters in the future).</p>
<p>My goal is to plot each cluster with its own point on the legend, using plotnine's default color palette (I actually like it better than other palettes).</p>
<p>If I plot the data as-is, the clusters are integers and viewed as continuous, so the legend is plotted on a continuous scale.</p>
<p>I fixed this by adding</p>
<pre><code>+ guides(fill=guide_legend(override_aes={"size": 6}))
</code></pre>
<p>but then it doesn't show all of the clusters in the legend.</p>
<p>Example:</p>
<pre><code>frame_172_region_plot = (ggplot(data,
aes(x='x',y='y',fill='cluster'))
+ geom_point(size=3,alpha=1,stroke=0)
+ theme_bw()
+ theme(
legend_position=(.5, 0.05), legend_direction='horizontal'
, figure_size=(18.60, 13.96)
, dpi= 300
, axis_title=element_text(size=16)
)
+ guides(fill=guide_legend(override_aes={"size": 6}))
+ scale_x_continuous(limits = (0,1860), expand = (0, 0), name='')
+ scale_y_continuous(limits = (0,1396), expand = (0, 0), name='')
+ labs(title='All Variables: Unlabeled Clusters. (Frame: 172, Sample: COL3)')
)
</code></pre>
<p><a href="https://i.stack.imgur.com/AIycm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AIycm.jpg" alt="enter image description here" /></a></p>
<p>Then I tried making the variable a categorical variable using pd.Categorical():</p>
<pre><code>data = data.assign(cluster = pd.Categorical(data['cluster']))
</code></pre>
<p>This seemed to work, but now the color palette is different and I have no idea how to change it back to the Plotnine default color palette. Can anyone help me reassign the color palette back to the plotnine default? Thanks!</p>
| [
{
"answer_id": 74295688,
"author": "Damon C. Roberts",
"author_id": 12394134,
"author_profile": "https://Stackoverflow.com/users/12394134",
"pm_score": 0,
"selected": false,
"text": "from selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom webdriver_manager.chrome import ChromeDriverManager\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver import ActionChains\nimport pyautogui\nimport time\n\n# WILL NEED TO EVENTUALLY FIGURE OUT HOW TO WRAP ALL OF THIS INTO A FUNCTION OR LOOP TO DO IT FOR ALL DIV OBJECTS\nchrome_options = Options()\nchrome_options.add_argument(\"--headless\")\ndriver = webdriver.Chrome(ChromeDriverManager().install(), options = chrome_options)\ndriver.get('https://www.politicsanddesign.com/')\nimg_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"srcset\")\ndriver.get(img_url)\nimg_url2 = 'https:' + img_url.split(' 400w',1)[0]\ndriver.get(img_url2)\n"
},
{
"answer_id": 74295883,
"author": "Gowthaman Ravindran",
"author_id": 10747860,
"author_profile": "https://Stackoverflow.com/users/10747860",
"pm_score": 2,
"selected": true,
"text": "img_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"currentSrc\")\ndriver.get(img_url)\n"
},
{
"answer_id": 74296010,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 1,
"selected": false,
"text": "from selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom webdriver_manager.chrome import ChromeDriverManager\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver import ActionChains\nimport pyautogui\nimport time\n\nchrome_options = Options()\nchrome_options.add_argument(\"--headless\")\ndriver = webdriver.Chrome(ChromeDriverManager().install(), options = chrome_options)\ndriver.get('https://www.politicsanddesign.com/')\nimg_url = driver.find_element(By.XPATH, \"//div[@class = 'responsive-image-wrapper']/img\").get_attribute(\"srcset\")\nimg_urls = img_url.split(\",\")\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17144827/"
] |
74,295,511 | <p>I am trying to call an endpoint using cypress and get a value out form the JSON body. I am able to <code>console.log(response.body.data.invitationCode)</code> out fine but can't seem to assign that value to a variable (I want to pass that value to subsequent requests). I've tried using <a href="https://stackoverflow.com/questions/68936669/how-do-i-return-the-response-from-a-cy-request-through-a-function">promises</a> but I still can't get the value.</p>
<p>Here is my code:</p>
<pre><code>/// <reference types="cypress" />
const faker = require('faker');
// We can change this to an ENV variable if we want to run this in different environments
const baseURL = 'https://<my url>/';
const user = {
createUser: async function () {
let code;
await user.waitListEndpointCall().then((response) => {
{
//console.log(response.body.data.invitationCode) works like a charm
code = response.body.data.invitationCode;
}
});
console.log(code); //doesn't work
},
/**
* Function calls the '/api/v1/public/waitList/post' and returns an invitation code
*/
waitListEndpointCall: function () {
const options = {
method: 'POST',
url: `${baseURL}/api/v1/public/waitList/post`,
body: {
email: `dmtest-${faker.random.number(1000001)}@gmail.com`,
},
};
return cy.request(options);
// return new Cypress.Promise((resolve, reject) => {
// cy.request(options).then((response) => resolve(response));
// });
},
};
module.exports = {
user,
};
</code></pre>
<p><code>console.log(code)</code> gives me <code>undefined</code> in cypress.</p>
<p>I've even wrapped my <code>cy.request</code> in a promise like so:</p>
<pre><code>waitListEndpointCall: function(){
const options: {
...
}
return new Cypress.Promise((resolve, reject) => {
cy.request(options).then((response) => resolve(response));
});
}
</code></pre>
<p>calling it like via:</p>
<pre><code>let res = await user.waitListEndpointCall();
console.log(res.body);
</code></pre>
<p>and I still get <code>undefined</code></p>
| [
{
"answer_id": 74296300,
"author": "TesterDick",
"author_id": 18366749,
"author_profile": "https://Stackoverflow.com/users/18366749",
"pm_score": 2,
"selected": false,
"text": "await"
},
{
"answer_id": 74296508,
"author": "Fody",
"author_id": 16997707,
"author_profile": "https://Stackoverflow.com/users/16997707",
"pm_score": 1,
"selected": false,
"text": "\nconst user = {\n waitListEndpointCall: function () {\n const options = {\n method: 'GET',\n url: 'https://jsonplaceholder.typicode.com/todos/1',\n }\n return new Cypress.Promise((resolve) => {\n cy.request(options).then((response) => resolve(response));\n })\n }\n}\n\nit('tests promise-wrapped return value', async () => {\n const res = await user.waitListEndpointCall()\n expect(res).to.have.property('body') // passes\n})\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5429105/"
] |
74,295,528 | <p>I'm a bit familiar with python, but not at all with haskell (although learning a programming language has definitely helped with understanding the XMonad documentation).</p>
<p>Used TreeSelect to create a dynamic group of workspaces (and sub-workspaces).</p>
<p>Using CycleWS to navigate these workspaces.</p>
<p>I am currently using 'ignoringWSs' within my keybindings to cycle through a small list of workspaces using a large list of workspaces to exclude from the cycle. Looking to do the opposite, where I cycle through a small list of workspaces, without having to exclude the existing workspaces that I don't wish to interact with using that specific keybinding.</p>
<p>Currently using:</p>
<pre><code>, ("M-3", addName "Switch to Next ... Page" $ moveTo Next $ hiddenWS :&: ignoringWSs [ "{Programming}.$Terminals.1>"
, "{Programming}.$Terminals.2>"
, "{Programming}.$Terminals.3>"
...
</code></pre>
<p>It's a crude solution, but I'm looking to use something that simplifies my code a bit.</p>
<p>Any suggestions on any optimizations (including to my form of asking questions, as this is my first one!) would be highly appreciated.</p>
<p>Thank you in advance!</p>
| [
{
"answer_id": 74296300,
"author": "TesterDick",
"author_id": 18366749,
"author_profile": "https://Stackoverflow.com/users/18366749",
"pm_score": 2,
"selected": false,
"text": "await"
},
{
"answer_id": 74296508,
"author": "Fody",
"author_id": 16997707,
"author_profile": "https://Stackoverflow.com/users/16997707",
"pm_score": 1,
"selected": false,
"text": "\nconst user = {\n waitListEndpointCall: function () {\n const options = {\n method: 'GET',\n url: 'https://jsonplaceholder.typicode.com/todos/1',\n }\n return new Cypress.Promise((resolve) => {\n cy.request(options).then((response) => resolve(response));\n })\n }\n}\n\nit('tests promise-wrapped return value', async () => {\n const res = await user.waitListEndpointCall()\n expect(res).to.have.property('body') // passes\n})\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20385753/"
] |
74,295,551 | <p>Hey I try to create a search function where I search to find my products in the list but now I have a little problem and that is that searchBox is not in the top of the corner right. I tried a lot of things but nothing happens. In the left corner there is my logo and I tried to put this to the right corner.</p>
<p>This is my search function:</p>
<pre><code>function Navbar() {
const [inputText, setInputText] = useState("");
let inputHandler = (e) => {
//convert input text to lower case
var lowerCase = e.target.value.toLowerCase();
setInputText(lowerCase);
};
return (
<div className="navbar">
<div className="logo">Shop</div>
<div className="searchBox">
<Product input={inputText} />
<TextField
id="outlined-basic"
onChange={inputHandler}
variant="outlined"
label="Search"
></TextField>
</div>
</div>
);
}
export default Navbar;
</code></pre>
<p>This is my css to this :</p>
<pre><code>.navbar {
width: 100%;
height: 50px;
background-color: rgb(32, 32, 32);
.logo {
color: aqua;
font-size: 1.8rem;
font-family: "Orbitron", sans-serif;
line-height: 40px;
margin-left: 20px;
}
.searchBox {
color: aqua;
font-size: 1.8rem;
height: 1%;
width: 100%;
font-family: "Orbitron", sans-serif;
display: flex;
justify-content: space-between;
align-items: center;
}
}
</code></pre>
| [
{
"answer_id": 74295957,
"author": "Freelancer",
"author_id": 20398282,
"author_profile": "https://Stackoverflow.com/users/20398282",
"pm_score": 0,
"selected": false,
"text": ".navbar {\n width: 100%;\n height: 50px;\n background-color: rgb(32, 32, 32);\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n .logo {\n color: aqua;\n font-size: 1.8rem;\n font-family: \"Orbitron\", sans-serif;\n line-height: 40px;\n margin-left: 20px;\n }\n\n .searchBox {\n color: aqua;\n font-size: 1.8rem;\n height: 1%;\n font-family: \"Orbitron\", sans-serif;\n display: flex;\n align-items: center;\n }\n }\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18540664/"
] |
74,295,553 | <p>In the data frame (<code>df</code>), <code>col2</code> contains encoded information separated by a period like <code>d.MAG.5.2</code>. I want to split the <code>name</code> into three categories <code>genus</code>, <code>species</code>, <code>replicate</code> that in this case would correspond to <code>d</code>, <code>MAG</code>, <code>5.2</code>. Note that, I don't want to split the period of the numerics at the end.</p>
<pre><code>col1 <- rnorm(1:3)
col2 <- c("d.MAG.1.1","d.MAG.3.4","d.TEX.5.6")
df <- data.frame(col1, col2)
</code></pre>
<p>I want the new dataset to look like this:</p>
<pre><code>col1 <- rnorm(1:3)
genus <- c("d","d","d")
species <- c("MAG","MAG","TEX")
replicate <- c("1.1","3.4","5.6")
df <- data.frame(col1, genus, species, replicate)
</code></pre>
| [
{
"answer_id": 74295631,
"author": "Jilber Urbina",
"author_id": 1315767,
"author_profile": "https://Stackoverflow.com/users/1315767",
"pm_score": 2,
"selected": false,
"text": "df %>% \n mutate(col2 = sub(\"(^.*)\\\\.(.*)\\\\.(\\\\d+\\\\.\\\\d+)\", \"\\\\1,\\\\2,\\\\3\", col2)) %>% \n separate(col2, into = c(\"genus\", \"species\", \"replicate\"), sep=\",\")\n\n col1 genus species replicate\n1 0.7264348 d MAG 1.1\n2 1.0411627 d MAG 3.4\n3 1.2302765 d TEX 5.6\n"
},
{
"answer_id": 74295641,
"author": "stefan",
"author_id": 12993861,
"author_profile": "https://Stackoverflow.com/users/12993861",
"pm_score": 3,
"selected": true,
"text": "tidyr::extract"
},
{
"answer_id": 74295684,
"author": "Allan Cameron",
"author_id": 12500315,
"author_profile": "https://Stackoverflow.com/users/12500315",
"pm_score": 2,
"selected": false,
"text": "library(tidyverse)\n\ndf %>%\n separate(col2, into = c(\"genus\", \"species\", \"r1\", \"r2\")) %>%\n unite(\"replicate\", r1:r2, sep = \".\")\n#> col1 genus species replicate\n#> 1 -1.9530625 d MAG 1.1\n#> 2 -1.2879991 d MAG 3.4\n#> 3 0.8091388 d TEX 5.6\n"
},
{
"answer_id": 74295694,
"author": "AndS.",
"author_id": 9778513,
"author_profile": "https://Stackoverflow.com/users/9778513",
"pm_score": 2,
"selected": false,
"text": "library(tidyverse)\n\n#option 1\nextract(df, \n col2, \n into = c(\"genus\", \"species\" , \"replicate\"), \n regex = \"(\\\\w)\\\\.(\\\\w+)\\\\.(.*$)\")\n#> col1 genus species replicate\n#> 1 1.48039902 d MAG 1.1\n#> 2 0.03728211 d MAG 3.4\n#> 3 0.28125162 d TEX 5.6\n\n#option 2\nseparate(df, \n col2,\n into = c(\"genus\", \"species\" , \"replicate\"),\n sep = \"\\\\.(?!\\\\d$)\")\n#> col1 genus species replicate\n#> 1 1.48039902 d MAG 1.1\n#> 2 0.03728211 d MAG 3.4\n#> 3 0.28125162 d TEX 5.6\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7258020/"
] |
74,295,577 | <p>As a beginner in Ruby, how can I extract a substring from within a string in Ruby?</p>
<p>Example:</p>
<pre><code>string1 = "1.1.67.01-f9@92a47088f49d095f0"
</code></pre>
<p>I want to extract substring from the beginning to '-'. So the substring is '1.1.67.01'</p>
| [
{
"answer_id": 74295924,
"author": "Silvio Mayolo",
"author_id": 2288659,
"author_profile": "https://Stackoverflow.com/users/2288659",
"pm_score": 1,
"selected": false,
"text": "string1 = \"1.1.67.01-f9@92a47088f49d095f0\"\n/^([^-]*)-/ =~ string1\nputs $1\n"
},
{
"answer_id": 74297010,
"author": "Chase McDougall",
"author_id": 17985490,
"author_profile": "https://Stackoverflow.com/users/17985490",
"pm_score": 2,
"selected": false,
"text": "-"
},
{
"answer_id": 74297072,
"author": "steenslag",
"author_id": 290394,
"author_profile": "https://Stackoverflow.com/users/290394",
"pm_score": 2,
"selected": false,
"text": "-"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15217560/"
] |
74,295,593 | <p>Can multiple threads work with values from the same list at the same time?
For example, we have 3 threads and a list of tasks that they have to perform:</p>
<pre><code>ExecutorService executor = Executors.newFixedThreadPool(3);
List<Strng> tasks = Arrays.asList("firstTask", "secondTask", "thirdTask", "foiuthTask", "fifthTask");
</code></pre>
<p>The threads started their work and took the first three tasks, but the second thread completed the task the fastest. Now it needs to take the 4th task to work, if it is not occupied by another thread and etc. Is this implementation possible?
I can't find any information about this.</p>
<p>I tryid to work with parallel Streams, but always got wrong results.</p>
| [
{
"answer_id": 74295924,
"author": "Silvio Mayolo",
"author_id": 2288659,
"author_profile": "https://Stackoverflow.com/users/2288659",
"pm_score": 1,
"selected": false,
"text": "string1 = \"1.1.67.01-f9@92a47088f49d095f0\"\n/^([^-]*)-/ =~ string1\nputs $1\n"
},
{
"answer_id": 74297010,
"author": "Chase McDougall",
"author_id": 17985490,
"author_profile": "https://Stackoverflow.com/users/17985490",
"pm_score": 2,
"selected": false,
"text": "-"
},
{
"answer_id": 74297072,
"author": "steenslag",
"author_id": 290394,
"author_profile": "https://Stackoverflow.com/users/290394",
"pm_score": 2,
"selected": false,
"text": "-"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14823942/"
] |
74,295,632 | <p>I have the following data frame:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;"></th>
<th style="text-align: center;">Month</th>
<th style="text-align: center;">Day</th>
<th style="text-align: center;">Year</th>
<th style="text-align: center;">Open</th>
<th style="text-align: center;">High</th>
<th style="text-align: center;">Low</th>
<th style="text-align: center;">Close</th>
<th style="text-align: center;">Week</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">0</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">2003</td>
<td style="text-align: center;">46.593</td>
<td style="text-align: center;">46.656</td>
<td style="text-align: center;">46.405</td>
<td style="text-align: center;">46.468</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: left;">1</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">2003</td>
<td style="text-align: center;">46.538</td>
<td style="text-align: center;">46.66</td>
<td style="text-align: center;">46.47</td>
<td style="text-align: center;">46.673</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: left;">2</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">3</td>
<td style="text-align: center;">2003</td>
<td style="text-align: center;">46.717</td>
<td style="text-align: center;">46.781</td>
<td style="text-align: center;">46.53</td>
<td style="text-align: center;">46.750</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: left;">3</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">4</td>
<td style="text-align: center;">2003</td>
<td style="text-align: center;">46.815</td>
<td style="text-align: center;">46.843</td>
<td style="text-align: center;">46.68</td>
<td style="text-align: center;">46.750</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: left;">4</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">5</td>
<td style="text-align: center;">2003</td>
<td style="text-align: center;">46.935</td>
<td style="text-align: center;">47.000</td>
<td style="text-align: center;">46.56</td>
<td style="text-align: center;">46.593</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: left;">...</td>
<td style="text-align: center;">...</td>
<td style="text-align: center;">...</td>
<td style="text-align: center;">...</td>
<td style="text-align: center;">...</td>
<td style="text-align: center;">...</td>
<td style="text-align: center;">...</td>
<td style="text-align: center;">...</td>
<td style="text-align: center;">...</td>
</tr>
<tr>
<td style="text-align: left;">7257</td>
<td style="text-align: center;">10</td>
<td style="text-align: center;">26</td>
<td style="text-align: center;">2022</td>
<td style="text-align: center;">381.619</td>
<td style="text-align: center;">387.5799</td>
<td style="text-align: center;">381.350</td>
<td style="text-align: center;">382.019</td>
<td style="text-align: center;">43</td>
</tr>
<tr>
<td style="text-align: left;">7258</td>
<td style="text-align: center;">10</td>
<td style="text-align: center;">27</td>
<td style="text-align: center;">2022</td>
<td style="text-align: center;">383.07</td>
<td style="text-align: center;">385.00</td>
<td style="text-align: center;">379.329</td>
<td style="text-align: center;">379.98</td>
<td style="text-align: center;">43</td>
</tr>
<tr>
<td style="text-align: left;">7259</td>
<td style="text-align: center;">10</td>
<td style="text-align: center;">28</td>
<td style="text-align: center;">2022</td>
<td style="text-align: center;">379.869</td>
<td style="text-align: center;">389.519</td>
<td style="text-align: center;">379.67</td>
<td style="text-align: center;">389.019</td>
<td style="text-align: center;">43</td>
</tr>
<tr>
<td style="text-align: left;">7260</td>
<td style="text-align: center;">10</td>
<td style="text-align: center;">31</td>
<td style="text-align: center;">2022</td>
<td style="text-align: center;">386.44</td>
<td style="text-align: center;">388.399</td>
<td style="text-align: center;">385.26</td>
<td style="text-align: center;">386.209</td>
<td style="text-align: center;">44</td>
</tr>
<tr>
<td style="text-align: left;">7261</td>
<td style="text-align: center;">11</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">2022</td>
<td style="text-align: center;">390.14</td>
<td style="text-align: center;">390.39</td>
<td style="text-align: center;">383.29</td>
<td style="text-align: center;">384.519</td>
<td style="text-align: center;">44</td>
</tr>
</tbody>
</table>
</div>
<p>I want to create a new column titled 'week high' which will reference each week every year and pull in the high. So for Week 1, Year 2003, it will take the Highest High from rows 0 to 4 but for Week 43, Year 2022, it will take the Highest High from rows 7257 to 7259.</p>
<p>Is it possible to reference the columns Week and Year to calculate that value? Thanks!</p>
| [
{
"answer_id": 74295924,
"author": "Silvio Mayolo",
"author_id": 2288659,
"author_profile": "https://Stackoverflow.com/users/2288659",
"pm_score": 1,
"selected": false,
"text": "string1 = \"1.1.67.01-f9@92a47088f49d095f0\"\n/^([^-]*)-/ =~ string1\nputs $1\n"
},
{
"answer_id": 74297010,
"author": "Chase McDougall",
"author_id": 17985490,
"author_profile": "https://Stackoverflow.com/users/17985490",
"pm_score": 2,
"selected": false,
"text": "-"
},
{
"answer_id": 74297072,
"author": "steenslag",
"author_id": 290394,
"author_profile": "https://Stackoverflow.com/users/290394",
"pm_score": 2,
"selected": false,
"text": "-"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19739054/"
] |
74,295,633 | <p>I am trying to assert that the alert that appears when clicking a button is:</p>
<blockquote>
<p>Error: There was an unexpected problem with SQL query execution.</p>
</blockquote>
<p>In Cypress, it is showing that the assertion is failing because it is not the exact string that the alert is showing. Cypress showing two stars (**) at the beginning and end of the string. This is the output that Cypress is giving me when I run the test:</p>
<blockquote>
<p><strong>assert expected</strong> [Error: There was an unexpected problem with SQL query execution.] <strong>to equal</strong> **[Error: There was an unexpected problem with SQL query execution.]**</p>
</blockquote>
<p>Tried to using a <code>.contains()</code> and <code>.should()</code> but nothing would assert that the two alerts have the same message.</p>
<p>My code as of now is:</p>
<pre><code>cy.button().click();
cy.on('window:alert', (str) => {
expect(str).to.equal('[Error: There was an unexpected problem with SQL query execution.]')
})
</code></pre>
| [
{
"answer_id": 74295738,
"author": "NyxNight",
"author_id": 18802986,
"author_profile": "https://Stackoverflow.com/users/18802986",
"pm_score": 1,
"selected": false,
"text": "expect(str).to.equal('Error: There was an unexpected problem with SQL query execution.')\n"
},
{
"answer_id": 74296148,
"author": "TesterDick",
"author_id": 18366749,
"author_profile": "https://Stackoverflow.com/users/18366749",
"pm_score": 1,
"selected": false,
"text": "expect(str).to.contain('[Error: There was an unexpected problem with SQL query execution.]')\n"
},
{
"answer_id": 74297415,
"author": "DrewTests23",
"author_id": 14267157,
"author_profile": "https://Stackoverflow.com/users/14267157",
"pm_score": 0,
"selected": false,
"text": "str.toString()"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14267157/"
] |
74,295,640 | <p>I have FooClass with barMethod() that returns "bazz" string. How to print in console <code>barMethod</code> along with <code>bazz</code>?</p>
<p>For example:</p>
<pre><code>public class FooClass {
String barMethod() {
return "baz";
}
}
</code></pre>
<pre><code>System.out.println(FooClass.barMethod()) //Prints "baz"
</code></pre>
<p>How can I print the following?</p>
<pre><code>customPrint(FooClass.barMethod()) //barMethod = baz
</code></pre>
<p>Note: I can't modify barMethod() or FooClass.</p>
<p>Found <a href="https://stackoverflow.com/questions/3023354/how-to-get-string-name-of-a-method-in-java">How to get a string name of method in java</a> on stack overflow but it isn't what I'm looking for.</p>
| [
{
"answer_id": 74295738,
"author": "NyxNight",
"author_id": 18802986,
"author_profile": "https://Stackoverflow.com/users/18802986",
"pm_score": 1,
"selected": false,
"text": "expect(str).to.equal('Error: There was an unexpected problem with SQL query execution.')\n"
},
{
"answer_id": 74296148,
"author": "TesterDick",
"author_id": 18366749,
"author_profile": "https://Stackoverflow.com/users/18366749",
"pm_score": 1,
"selected": false,
"text": "expect(str).to.contain('[Error: There was an unexpected problem with SQL query execution.]')\n"
},
{
"answer_id": 74297415,
"author": "DrewTests23",
"author_id": 14267157,
"author_profile": "https://Stackoverflow.com/users/14267157",
"pm_score": 0,
"selected": false,
"text": "str.toString()"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4957149/"
] |
74,295,664 | <p>I'm trying to read a series of dictionaries from a file:</p>
<p>GFG.txt</p>
<pre><code>{'geek': 10, 'geeky': True}
{'GeeksforGeeks': 'Education', 'geekgod': 101.0, 3: 'gfg'}
{'supergeek': 5}
</code></pre>
<p>and I found this <a href="https://www.geeksforgeeks.org/read-list-of-dictionaries-from-file-in-python/" rel="nofollow noreferrer">website</a> with the following solution:</p>
<pre><code>import pickle
geeky_file = open('GFG.txt', 'r')
dictionary_list = pickle.load(geeky_file)
for d in dictionary_list:
print(d)
geeky_file.close()
</code></pre>
<p>However this throws an exception:</p>
<pre><code>TypeError: a bytes-like object is required, not 'str'
</code></pre>
<p>Opening the file in binary mode:</p>
<pre><code>geeky_file = open('GFG.txt', 'rb')
</code></pre>
<p>gives me the error:</p>
<pre><code>UnpicklingError: invalid load key, '{'.
</code></pre>
| [
{
"answer_id": 74295738,
"author": "NyxNight",
"author_id": 18802986,
"author_profile": "https://Stackoverflow.com/users/18802986",
"pm_score": 1,
"selected": false,
"text": "expect(str).to.equal('Error: There was an unexpected problem with SQL query execution.')\n"
},
{
"answer_id": 74296148,
"author": "TesterDick",
"author_id": 18366749,
"author_profile": "https://Stackoverflow.com/users/18366749",
"pm_score": 1,
"selected": false,
"text": "expect(str).to.contain('[Error: There was an unexpected problem with SQL query execution.]')\n"
},
{
"answer_id": 74297415,
"author": "DrewTests23",
"author_id": 14267157,
"author_profile": "https://Stackoverflow.com/users/14267157",
"pm_score": 0,
"selected": false,
"text": "str.toString()"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635863/"
] |
74,295,670 | <p>I have the following dataframe:</p>
<pre><code>[['M', 'A', '0', '0.2', '0.2', '0.2'],
[nan, nan, nan, '0.3', '0.3', '1'],
[nan, nan, nan, '1.4', '3.2', '32'],
[nan, nan, nan, nan, nan, nan],
[nan, nan, nan, nan, nan, nan],
['sex', 'test', 'conc', 'sugar', 'flour', 'yeast'],
['M', 'A', '3', '1.2', '1.2', '1.2'],
[nan, nan, nan, '1.3', '1.3', '2'],
[nan, nan, nan, '2.4', '4.2', '33'],
[nan, nan, nan, nan, nan, nan],
['sex', 'test', 'conc', 'sugar', 'flour', 'yeast'],
['M', 'A', '6', '2.2', '2.2', '2.2'],
[nan, nan, nan, '2.3', '2.3', '3'],
[nan, nan, nan, '3.4', '5.2', '34']]
</code></pre>
<p>I'd like to split it when a row is all nans, into multiple dataframes. I've tried the following code from the link below, and it does as I think I want it to do, but it appears to return a list of the splits. How do I get each one into its individual dataframe, so I'd have multiple dataframes?</p>
<p><a href="https://stackoverflow.com/questions/47319418/split-pandas-dataframe-on-blank-rows/47319482#47319482">SOF</a></p>
<pre><code>df_list = np.split(df, df[df.isnull().all(1)].index)
for df in df_list:
print(df, '\n')
</code></pre>
| [
{
"answer_id": 74295749,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 3,
"selected": true,
"text": "m = df.isna().all(axis=1)\n\ndfs = [g for k,g in df[~m].groupby(m.cumsum())]\n"
},
{
"answer_id": 74295790,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 1,
"selected": false,
"text": "dfs=[] # list to hold the DF\n\n# code that you already have. which is to split the DF on null rows\ndf_list = np.split(df, df[df.isnull().all(1)].index)\n\n# Iterate over the df_list and append to dfs\nfor idx, data in enumerate(df_list):\n dfs.append(data)\n\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18174007/"
] |
74,295,676 | <p>If I have tuple:</p>
<pre><code>myT=(“a”, “b”, “c”, “d”, “e”, “f”)
</code></pre>
<p>Is it possible to slice out say <code>“a”, “d”, “e”</code>?</p>
<p>Something like <code>myT = myT[0, 3, 4]</code>.</p>
| [
{
"answer_id": 74295707,
"author": "at54321",
"author_id": 15602349,
"author_profile": "https://Stackoverflow.com/users/15602349",
"pm_score": 1,
"selected": false,
"text": "a = ('a', 'b', 'c', 'd', 'e', 'f')\nb = (a[0], a[3], a[4])\n"
},
{
"answer_id": 74295782,
"author": "fsimonjetz",
"author_id": 15873043,
"author_profile": "https://Stackoverflow.com/users/15873043",
"pm_score": 0,
"selected": false,
"text": "operator.itemgetter"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19758369/"
] |
74,295,700 | <p>I cant import pycaret in a google colab</p>
<p>Here are all the steps I had taken:</p>
<p>Change python version to 3.8</p>
<p>Installed pip</p>
<p>I then ran</p>
<pre><code>!pip install pycaret
import pycaret
</code></pre>
<p>the install works, but then</p>
<pre><code>ModuleNotFoundError Traceback (most recent call last)
<ipython-input-27-fdea18e6876c> in <module>
1 get_ipython().system('pip install pycaret ')
----> 2 import pycaret
ModuleNotFoundError: No module named 'pycaret'
</code></pre>
<p>I must be doing something very wrong!</p>
<p>In troubleshooting I also pip installed numpy and pandas which both imported just fine</p>
| [
{
"answer_id": 74295707,
"author": "at54321",
"author_id": 15602349,
"author_profile": "https://Stackoverflow.com/users/15602349",
"pm_score": 1,
"selected": false,
"text": "a = ('a', 'b', 'c', 'd', 'e', 'f')\nb = (a[0], a[3], a[4])\n"
},
{
"answer_id": 74295782,
"author": "fsimonjetz",
"author_id": 15873043,
"author_profile": "https://Stackoverflow.com/users/15873043",
"pm_score": 0,
"selected": false,
"text": "operator.itemgetter"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13963151/"
] |
74,295,702 | <p>I am trying to send an email using this function I have written:</p>
<pre><code>def send_email(recip, subj, content):
email = MIMEMultipart('alternative')
email['To'] = ",".join(recip)
email['From'] = 'xyz@abc.com'
email['Subject'] = subj
body = MIMEText(content, 'html')
email.attach(body)
smtpObj = smtplib.SMTP('something.com')
smtpObj.sendmail('sender@abc.com', recip, email.as_string())
</code></pre>
<p>The email is sent and when I view the source I can also my css code there but it is clearly not using the CSS code. I am using Outlook.</p>
<pre><code> <html>
<head> <style>
{css}
</style> </head>
<body>
<img src = "header.png">
<div>
<h6> Trade Date - {date} </h6>
</div>
<div>
<h6> SUMMARY </h6>
{summary}
</div>
<div>
<h6> DETAILS </h6>
{details}
</div>
<div>
<h6> INTERNAL DESKS </h6>
{desk}
</div>
</body>
</html>
</code></pre>
<p>The above is my html code structured and the css code appears in the {css} area. Can anyone tell me what vis going wrong? I know Outlook should support style tags inside head like I am doing</p>
| [
{
"answer_id": 74295707,
"author": "at54321",
"author_id": 15602349,
"author_profile": "https://Stackoverflow.com/users/15602349",
"pm_score": 1,
"selected": false,
"text": "a = ('a', 'b', 'c', 'd', 'e', 'f')\nb = (a[0], a[3], a[4])\n"
},
{
"answer_id": 74295782,
"author": "fsimonjetz",
"author_id": 15873043,
"author_profile": "https://Stackoverflow.com/users/15873043",
"pm_score": 0,
"selected": false,
"text": "operator.itemgetter"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19375402/"
] |
74,295,718 | <p>I hava a page that uses tabulator to make a table. On each row of the table I habe a small thumbnail. When I click on the thumbnail a gallery opens. I want to classify the image by clicking some buttons (yes, no etc). When I click on one buttons I want to close the gallery and then have javascript go to the next cell gallery: trigger a click on the next row's cell. I can get the cell but I cannot manage to trigger the cell click form the javascript portion. I have tried (on the cell I want to use):</p>
<pre><code>//inside btn-clicked function
//after closing the gallery just want to trigger default tabulator cellClick event!
cellEl = cell.getElement();
$(cellEl).trigger('click')
</code></pre>
<p>and</p>
<pre><code>$("document").trigger('cellClick', cell)
$("#main-table").trigger('cellClick', [cell])
</code></pre>
<p>None of these work.</p>
<p>Here is a JSFiddle: <a href="https://jsfiddle.net/q5fuon6z/" rel="nofollow noreferrer">https://jsfiddle.net/q5fuon6z/</a></p>
| [
{
"answer_id": 74296304,
"author": "Mark Schultheiss",
"author_id": 125981,
"author_profile": "https://Stackoverflow.com/users/125981",
"pm_score": 1,
"selected": false,
"text": "$(\"#main-table\").on('click', '.cell-mate', function(event) {\n let cells = $('.cell-mate');\n cells.toggleClass(\"occupied next-up\", false);\n $(this).toggleClass(\"occupied\");\n let myIndex = $(this).index();\n let clickNext = $(this).index() == cells.last().index() ? cells.first() : $(this).next('.cell-mate');\n clickNext.trigger('cellClick', [$(this), myIndex, clickNext]);\n});\n$('.cell-mate').on('cellClick', function(event, cell, prevIndex, nextUp) {\n nextUp.toggleClass('next-up');\n $('#monitor').html(cell.html() + \" at \" + prevIndex + \" nudged \" + nextUp.html() +\n \" at \" + nextUp.index());\n});\n//start it all off (or comment out to start with a user action)\n$(\"#main-table\").find('.cell-mate').eq(0).trigger('click');"
},
{
"answer_id": 74336540,
"author": "alexandra",
"author_id": 3497386,
"author_profile": "https://Stackoverflow.com/users/3497386",
"pm_score": 0,
"selected": false,
"text": " $(cell.getElement()).trigger('click')\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3497386/"
] |
74,295,720 | <p>Object's clone method is protected, therefore it can be accessed in sub classes (class A), so why am I getting 'clone() has protected access in java.lang.Object' compiler error? I thought, that all Java classes are sub classes of Object. Thanks in advance.</p>
<p>The code below raises the compiler error:</p>
<pre><code>public class A {
public static void main(String[] args) {
Object o = new Object();
o.clone();//error
}
}
</code></pre>
<p>But this one compiles perfectly, don't they have the same semantics tho?</p>
<pre><code>public class A {
protected void foo() {
}
}
</code></pre>
<pre><code>public class B extends A {
public static void main(String[] args) {
A a = new A();
a.foo();
}
}
</code></pre>
| [
{
"answer_id": 74295791,
"author": "rzwitserloot",
"author_id": 768644,
"author_profile": "https://Stackoverflow.com/users/768644",
"pm_score": 4,
"selected": true,
"text": "protected"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8989302/"
] |
74,295,767 | <p>I have input as p1= 1,2,3 and p2=100,200,300.
I need to create a function that will get me:</p>
<p>[ ['1', '100'], ['2', '200'], ['3', '300'] ]</p>
<p>I tried to make it into a string but the issue is that I'm getting this output:</p>
<p>['[1, 100]', '[2, 200]', '[3, 300]']</p>
<p>Here's the code:</p>
<pre><code>'use strict'
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.question('', (p1) => {
rl.question('', (p2) => {
p1 = p1.split(", ")
p2 = p2.split(", ")
console.log(merge(p1,p2))
rl.close();
})
});
// DO NOT CHANGE ABOVE THIS LINE!!!!
const merge = function(p1,p2){
for(let i=0;i<p1.length;i++){
p1[i]="[ "+p1[i]+", "+p2[i]+" ]"
}
return p1;
} // Write this function
</code></pre>
| [
{
"answer_id": 74295791,
"author": "rzwitserloot",
"author_id": 768644,
"author_profile": "https://Stackoverflow.com/users/768644",
"pm_score": 4,
"selected": true,
"text": "protected"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401776/"
] |
74,295,798 | <p>I am using the experimental next.js (ver.13)
Trying to understand what is wrong with my code .. as i am not getting anything and i am simply following the documentation.</p>
<p>it errors : <strong>photos.map is not a function</strong></p>
<pre><code>async function getPhotos() {
const res = await fetch('https://jsonplaceholder.typicode.com/photos');
return res.json();
}
export default function Photos() {
const photos = getPhotos();
return (
<div>
{photos.map((photo) => {
return <div key={photo.id}>{photo.title}</div>;
})}
</div>
);
}
</code></pre>
| [
{
"answer_id": 74299248,
"author": "user20386762",
"author_id": 20386762,
"author_profile": "https://Stackoverflow.com/users/20386762",
"pm_score": 1,
"selected": false,
"text": "Photos"
},
{
"answer_id": 74333392,
"author": "Yilmaz",
"author_id": 10262805,
"author_profile": "https://Stackoverflow.com/users/10262805",
"pm_score": 0,
"selected": false,
"text": "module.exports = {\n experimental: {\n enableUndici: true\n }\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2769999/"
] |
74,295,834 | <p>I've got two spreadsheets, a primary sheet (that a google form dumps into) and another sheet (aka management sheet) that has shared access to the primary sheet. I'm trying to run the query below to automatically import a serial number based on the hostname in column D of the management sheet.</p>
<p>I can run a simple importrange successfully, so the access permissions are working properly.</p>
<pre><code>=QUERY(IMPORTRANGE("[URLHERE]”, “Form Responses 1!A2:H”), ”Select Col7 where Col5="&$D2))
</code></pre>
<p>Any help would be appreciated, thanks in advance!</p>
<p>Jerome</p>
| [
{
"answer_id": 74295999,
"author": "Jump_Ace",
"author_id": 1509059,
"author_profile": "https://Stackoverflow.com/users/1509059",
"pm_score": 0,
"selected": false,
"text": "=query({IMPORTRANGE(\"1pRWLfnYsJhmJFZio_pvny7oO8UCSUxfGhTc78TbwVhw\", \"Form Responses 1!A2:H\")}, \"Select Col7 where Col5 = '\"&D2&\"' LIMIT 1\",0)\n"
},
{
"answer_id": 74296039,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 1,
"selected": false,
"text": "=SINGLE(QUERY({IMPORTRANGE(\"1pRWLfnYsJhmJFZio_pvny7oO8UCSUxfGhTc78TbwVhw\", \n \"Form Responses 1!A:H\")}, \"select Col7 where Col5 = '\"&D2&\"'\", )\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1509059/"
] |
74,295,864 | <p><a href="https://i.stack.imgur.com/pxBG7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pxBG7.jpg" alt="enter image description here" /></a> Hello guys . I have a problem. As we see the characteristic of a table, when hovering over each cell, the background color of that cell turns yellow. I want the background color of the entire row to turn yellow when hovering over each cell.</p>
<p>For example, when you hover over Amazon, 4162 and 5327 and 00:24:34 and their background color becomes yellow.</p>
<pre><code>
//////////// My Html code ///////////
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="style.css" rel="stylesheet"/>
<title>Index2</title>
</head>
<body>
<center>
<div>
<table>
<tr>
<th>Sites</th>
<th>Views</th>
<th>Clicks</th>
<th>Avrage</th>
</tr>
<tr>
<td class="Google">Google</td>
<td class="Value">9518</td>
<td class="Value">6369</td>
<td class="Value">1:32:50</td>
</tr>
<tr>
<td class="Twitter">Twitter</td>
<td class="Value">7326</td>
<td class="Value">10437</td>
<td class="Value">00:51:22</td>
</tr>
<tr>
<td class="Amazon">Amazon</td>
<td class="Value">4162</td>
<td class="Value">5327</td>
<td class="Value">00:24:34</td>
</tr>
<tr>
<td class="Linkedin">Linkedin</td>
<td class="Value">3654</td>
<td class="Value">2961</td>
<td class="Value">00:12:10</td>
</tr>
<tr>
<td class="TopLearn">TopLearn</td>
<td class="Value">2002</td>
<td class="Value">4135</td>
<td class="Value">00:46:19</td>
</tr>
<tr>
<td class="GitHub">GitHub</td>
<td class="Value">4623</td>
<td class="Value">3486</td>
<td class="Value">00:31:52</td>
</tr>
</table>
</div>
</center>
</body>
</html>
</code></pre>
<pre><code>
////////////My Css code////////////
body
{
background-color: rgb(30, 33, 50);
}
div{
overflow-x: auto;
}
table{
margin-top: 4vw;
}
th{
font-family: sans-serif;
font-size :20px;
color: rgb(108, 186, 224);
}
th,td
{
padding: 1.25vw 12.5vw 1.25vw 1.25vw;
/* padding: 20px 200px 20px 20px; */
}
tr:nth-child(even)
{
background-color: rgb(45, 50, 69);
}
tr:nth-child(odd)
{
background-color: rgb(38, 44, 60);
}
tr:nth-child(1)
{
background-color: rgb(30, 33, 50);
}
th,td{
text-align: left;
}
/***************************************************************************************************/
td.Google{
font-family: sans-serif;
font-size: 18px;
color: rgb(250, 83, 113);
}
td.Amazon{
font-family: sans-serif;
font-size: 18px;
color: rgb(250, 83, 113);
}
td.Twitter{
font-family: sans-serif;
font-size: 18px;
color: rgb(250, 83, 113);
</code></pre>
| [
{
"answer_id": 74295999,
"author": "Jump_Ace",
"author_id": 1509059,
"author_profile": "https://Stackoverflow.com/users/1509059",
"pm_score": 0,
"selected": false,
"text": "=query({IMPORTRANGE(\"1pRWLfnYsJhmJFZio_pvny7oO8UCSUxfGhTc78TbwVhw\", \"Form Responses 1!A2:H\")}, \"Select Col7 where Col5 = '\"&D2&\"' LIMIT 1\",0)\n"
},
{
"answer_id": 74296039,
"author": "player0",
"author_id": 5632629,
"author_profile": "https://Stackoverflow.com/users/5632629",
"pm_score": 1,
"selected": false,
"text": "=SINGLE(QUERY({IMPORTRANGE(\"1pRWLfnYsJhmJFZio_pvny7oO8UCSUxfGhTc78TbwVhw\", \n \"Form Responses 1!A:H\")}, \"select Col7 where Col5 = '\"&D2&\"'\", )\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20173738/"
] |
74,295,886 | <p>I am working on a VR project in Unity (2020.3.40f), and need to add the option to move an object on its axis based on the controller's (the user's hand) movement.</p>
<p>Currently I store the controller's position when it grabs the object, and continuously calculate the distance the controller has moved from the initial position.
But it is inaccurate, because the controller might have moved in a direction that shouldn't affect the object's position.</p>
<p><strong>For example:</strong></p>
<p>I have this blue lever that the user has to pull. I want to know how much the controller has moved along the green axis, so I can move the lever accordingly.</p>
<p>If the user moves their hand upwards, it shouldn't affect the lever (but in my current implementation, I use <code>Vector3.Distance</code> so the lever moves anyway).</p>
<p><a href="https://i.stack.imgur.com/l0veF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l0veF.png" alt="An example" /></a></p>
<p><strong>My code:</strong></p>
<pre><code> private void OnTriggerEnter(Collider other)
{
controller = other.GetComponentInParent<IController>();
if (controller == null || controller.IsOccupied)
{
return;
}
controller.IsOccupied = true;
controllerStartPosition = controller.GetPosition();
}
private void Update()
{
if (controller == null) return;
Vector3 currentControllerPosition = controller.GetPosition();
float distance = Vector3.Distance(currentControllerPosition, controllerStartPosition);
transform.Translate(0, 0, distance * sensitivity); // The object always moves along its forward axis.
}
</code></pre>
<p>I assume that I need to project the controller's position on the object's forward axis and calculate the distance of that, but I have very basic knowledge in vectors maths so I am not sure about that.</p>
<p>So my question is, What are the calculations that I should do to get the correct distance?</p>
| [
{
"answer_id": 74300127,
"author": "Berkay Ozdemir",
"author_id": 20404739,
"author_profile": "https://Stackoverflow.com/users/20404739",
"pm_score": 0,
"selected": false,
"text": "float distance = currentControllerPosition.x - controllerStartPosition.x; "
},
{
"answer_id": 74304505,
"author": "derHugo",
"author_id": 7111561,
"author_profile": "https://Stackoverflow.com/users/7111561",
"pm_score": 2,
"selected": true,
"text": "Vector3.Project"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9977758/"
] |
74,295,914 | <p>Having trouble producing a vector (e.g. "bootdist") containing a bootstrap distribution of 1000 values of the slope of the linear regression of <code>y</code> on <code>x</code>.</p>
<p>I have written the following to fit a linear regression on the given data:</p>
<pre><code>lm.out <- lm(y ~ x)
coef(lm.out)
ypred <- predict(lm.out)
resids <- y - ypred
SSE <- sum(resids^2)
print(paste("Error sum of squares is", SSE))
summary(lm.out)
length(x)
</code></pre>
<p>However, unsure how to proceed from here. Any tips on how to apply to bootstrap would be appreciated, thanks!</p>
<h2>Data</h2>
<pre><code>x <- c(1, 1.5, 2, 3, 4, 4.5, 5, 5.5, 6, 6.5, 7, 8, 9, 10, 11, 12,
13, 14, 15)
y <- c(21.9, 27.8, 42.8, 48, 52.5, 52, 53.1, 46.1, 42, 39.9, 38.1,
34, 33.8, 30, 26.1, 24, 20, 11.1, 6.3)
</code></pre>
| [
{
"answer_id": 74300127,
"author": "Berkay Ozdemir",
"author_id": 20404739,
"author_profile": "https://Stackoverflow.com/users/20404739",
"pm_score": 0,
"selected": false,
"text": "float distance = currentControllerPosition.x - controllerStartPosition.x; "
},
{
"answer_id": 74304505,
"author": "derHugo",
"author_id": 7111561,
"author_profile": "https://Stackoverflow.com/users/7111561",
"pm_score": 2,
"selected": true,
"text": "Vector3.Project"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401908/"
] |
74,295,939 | <p>I am trying to detect when a <code><select></code> element that was dynamically added has had its option changed. However, it does not trigger when I change it.</p>
<p>The code:</p>
<pre><code>var diP = document.createElement("select");
diP.add(option);
diP.add(option2);
diP.addEventListener("change", alert("Test"));
div2.appendChild(diP);
</code></pre>
<p>The code does not alert anything when I change the option.</p>
| [
{
"answer_id": 74295962,
"author": "Jovana",
"author_id": 11365465,
"author_profile": "https://Stackoverflow.com/users/11365465",
"pm_score": 2,
"selected": true,
"text": "diP.addEventListener(\"change\", () => alert(\"Test\"));\n"
},
{
"answer_id": 74295991,
"author": "imvain2",
"author_id": 3684265,
"author_profile": "https://Stackoverflow.com/users/3684265",
"pm_score": 0,
"selected": false,
"text": "function funcName(){\n\n}\n\ndiP.addEventListener(\"change\", funcName);\n"
},
{
"answer_id": 74296031,
"author": "Artem Arkhipov",
"author_id": 5075755,
"author_profile": "https://Stackoverflow.com/users/5075755",
"pm_score": 0,
"selected": false,
"text": "addEventListener"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20401906/"
] |
74,295,948 | <p>Let's say I have an object like this</p>
<pre><code>const person = {
name: 'Amir',
age: 25,
favoriteFruits: ['Apple', 'Orange']
};
</code></pre>
<p>I need a function to accept a key which its value is an array.</p>
<p>Here the second argument in IDE should just suggest the <code>favoriteFruits</code> key:</p>
<pre><code>get(person, '');
</code></pre>
<p>I tried to make such function but it accepts all of the keys</p>
<pre><code>function get<T, Key extends keyof T>(container: T, key: Key) {
return container[key];
}
</code></pre>
| [
{
"answer_id": 74296144,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 0,
"selected": false,
"text": "KeysOfType"
},
{
"answer_id": 74296203,
"author": "Daniel Rodríguez Meza",
"author_id": 6032155,
"author_profile": "https://Stackoverflow.com/users/6032155",
"pm_score": 3,
"selected": true,
"text": "type RemoveNonArrayKeys<T> = keyof {\n [K in keyof T as T[K] extends unknown[] ? K : never]: T[K];\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12165605/"
] |
74,295,964 | <pre><code>import UIKit
class ViewController: UIViewController {
@IBOutlet weak var ortalamaLabel: UILabel!
@IBOutlet weak var firstSectionCredit: UITextField!
@IBOutlet weak var firstSectionGrade: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}
var firstNumberGrade:Double = 0 //These are my grade variables.
var secondNumberGrade:Double = 0
var sonuc1:Double = 0
@IBAction func calculate(_ sender: Any) {
let ilkKredi = Double(firstSectionCredit.text!)
if let ilkNot = firstSectionGrade.text {
if ilkNot == "AA" {
firstNumberGrade = 4.0
}
if ilkNot == "BA" {
firstNumberGrade = 3.5
}
if ilkNot == "BB" {
firstNumberGrade = 3.0
}
if ilkNot == "CB" {
firstNumberGrade = 2.5
}
if ilkNot == "CC" {
firstNumberGrade = 2.0
}
if ilkNot == "DC" {
firstNumberGrade = 1.5
}
if ilkNot == "DD" {
firstNumberGrade = 1.0
}
if ilkNot == "FF" {
firstNumberGrade = 0
}
sonuc1 = firstNumberGrade * ilkKredi!
//I want to do these process for 8 section.I don want to rewrite all these codes.
</code></pre>
<p>I want to make university grade calculator.But it takes too much time and I repeated so much codes.I have 8 section 8 grades and 8 section credits.How can I use easy function to do that.I am beginner in Swift</p>
| [
{
"answer_id": 74296144,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 0,
"selected": false,
"text": "KeysOfType"
},
{
"answer_id": 74296203,
"author": "Daniel Rodríguez Meza",
"author_id": 6032155,
"author_profile": "https://Stackoverflow.com/users/6032155",
"pm_score": 3,
"selected": true,
"text": "type RemoveNonArrayKeys<T> = keyof {\n [K in keyof T as T[K] extends unknown[] ? K : never]: T[K];\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12097598/"
] |
74,295,980 | <p>I am exploring AsciiDoc as a replacement for Atlassian Confluence, for our developers to maintain documentation with the code.</p>
<p>One feature I'm missing from Confluence is <a href="https://confluence.atlassian.com/doc/page-properties-report-macro-186089616.html" rel="nofollow noreferrer">Page Properties Report</a> which can list pages and the values of properties on those pages.</p>
<p><strong>I am wondering if there is a strategy to achieve something similar with AsciiDoc?</strong></p>
<p>I do not need a full automated solution.</p>
<p>I thought if there was a way I could reference the value of an attribute from another document, then I can manually create a table listing of documents, with columns that I manually populate with reference to document attributes. But I have not been able to find if that's possible.</p>
<p>The following does not work, but is just to illustrate the desired goal for producing a table listing of Architecture Decision Records (ADRs) that displays the attributes of each ADR document.</p>
<pre><code>|===
|Decision|Status|Decision date|Amends|Amended by
|xref:adr-1.adoc[ADR 1: Decision Foo]
|{adr-1.adoc:adr-status}
|{adr-1.adoc:adr-date}
|{adr-1.adoc:adr-amends}
|{adr-1.adoc:adr-amendedby}
|xref:adr-2.adoc[ADR 2: Decision Bar]
|{adr-2.adoc:adr-status}
|{adr-2.adoc:adr-date}
|{adr-2.adoc:adr-amends}
|{adr-2.adoc:adr-amendedby}
|===
</code></pre>
| [
{
"answer_id": 74296144,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 0,
"selected": false,
"text": "KeysOfType"
},
{
"answer_id": 74296203,
"author": "Daniel Rodríguez Meza",
"author_id": 6032155,
"author_profile": "https://Stackoverflow.com/users/6032155",
"pm_score": 3,
"selected": true,
"text": "type RemoveNonArrayKeys<T> = keyof {\n [K in keyof T as T[K] extends unknown[] ? K : never]: T[K];\n}\n"
}
] | 2022/11/02 | [
"https://Stackoverflow.com/questions/74295980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2045006/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.