qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,427,437 | <p>The dataframe contains date column, revenue column(for specific date) and the name of the day.
<a href="https://i.stack.imgur.com/RSD4M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RSD4M.png" alt="enter image description here" /></a></p>
<p>This is the code for creating the df:</p>
<pre><code>pd.DataFrame({'Date':['2015-01-08','2015-01-09','2015-01-10','2015-02-10','2015-08-09','2015-08-13','2015-11-09','2015-11-15'],
'Revenue':[15,4,15,13,16,20,12,9],
'Weekday':['Monday','Tuesday','Wednesday','Monday','Friday','Saturday','Monday','Sunday']})
</code></pre>
<p>I want to find the sum of revenue between Mondays:</p>
<pre><code>2015-02-10 34 Monday
2015-11-09 49 Monday etc.
</code></pre>
| [
{
"answer_id": 74429173,
"author": "haggi krey",
"author_id": 9142615,
"author_profile": "https://Stackoverflow.com/users/9142615",
"pm_score": 2,
"selected": false,
"text": "pm.refresh()\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18756733/"
] |
74,427,452 | <p>I'm new to google sheet. I have a column(E) with the date and another with a session(F), I want to merge them into one column with each date & different session just like the first few rows in column C.</p>
<p><a href="https://i.stack.imgur.com/K2QrH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K2QrH.jpg" alt="enter image description here" /></a></p>
<p>I've tried "=ArrayFormula(concat(D2:D,concat(" ",F2:F5)))" in column C but only got the first date.</p>
| [
{
"answer_id": 74429173,
"author": "haggi krey",
"author_id": 9142615,
"author_profile": "https://Stackoverflow.com/users/9142615",
"pm_score": 2,
"selected": false,
"text": "pm.refresh()\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20497626/"
] |
74,427,492 | <p><a href="https://i.stack.imgur.com/t6OM9.png" rel="nofollow noreferrer">image here</a></p>
<pre><code><Accordion>
<Accordion.Item eventKey="0">
<Card style={{ margin: 10 }}>
<Card.Header style={{ display: "flex" }}>
<span
style={{
flex: 1,
fontSize: 18,
color: "black",
textDecoration: "none",
cursor: "pointer",
alignSelf: "center",
}}
>
<Accordion.Header >{note.title}</Accordion.Header>
</span>
</code></pre>
<p>The border on the text came when I applied accordion before it was not there</p>
| [
{
"answer_id": 74427528,
"author": "ANISH SAJI KUMAR",
"author_id": 12309235,
"author_profile": "https://Stackoverflow.com/users/12309235",
"pm_score": 0,
"selected": false,
"text": ".accordion-header {\n border: none;\n}\n"
},
{
"answer_id": 74427675,
"author": "Kamran Davar",
"author_id": 12510464,
"author_profile": "https://Stackoverflow.com/users/12510464",
"pm_score": 4,
"selected": true,
"text": ".accordion .card-header button {\n border: none;\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20193086/"
] |
74,427,502 | <p>I would like to take the json output of window values from a program. The output of it currently is:</p>
<pre><code>[
3067,
584
]
[
764,
487
]
</code></pre>
<p>But I need it to be formatted like: <code>3067,584 764x487</code>. How would I go about doing this using jq or other commands?</p>
<p>I'm not very experienced with jq and json formatting in general, so I'm not really sure where to start. I have tried looking this up but am still not really sure how to do it.</p>
| [
{
"answer_id": 74427528,
"author": "ANISH SAJI KUMAR",
"author_id": 12309235,
"author_profile": "https://Stackoverflow.com/users/12309235",
"pm_score": 0,
"selected": false,
"text": ".accordion-header {\n border: none;\n}\n"
},
{
"answer_id": 74427675,
"author": "Kamran Davar",
"author_id": 12510464,
"author_profile": "https://Stackoverflow.com/users/12510464",
"pm_score": 4,
"selected": true,
"text": ".accordion .card-header button {\n border: none;\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20497688/"
] |
74,427,504 | <p>Just like to ask whether is there any character limit when fluentbit send logs to splunk? How can I increase the character limit via the Splunk Web UI?</p>
| [
{
"answer_id": 74435880,
"author": "RichG",
"author_id": 2227420,
"author_profile": "https://Stackoverflow.com/users/2227420",
"pm_score": 2,
"selected": false,
"text": "TRUNCATE"
},
{
"answer_id": 74469265,
"author": "xxestter",
"author_id": 3400076,
"author_profile": "https://Stackoverflow.com/users/3400076",
"pm_score": 1,
"selected": true,
"text": "[host::small_events]\nTRUNCATE = 256\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3400076/"
] |
74,427,520 | <p>I'm doing a GET fetch request to my DB on page load and wish to display only the True items.</p>
<p>The response json object has 32 items returned from the API.
They are all key value pairs (with boolean values) eg:</p>
<pre><code>{
Apple: false
Banana: false
Orange: true
Kiwi: true
}
</code></pre>
<p>I need to find ONLY the true items, create a button element for each true item, set the button text label from the Key, and add this to my page inside an empty div.</p>
<p>I've played with If/Else and turning the Object into an Array with Object.entries - but I'm out of my depth and don't really know the right approach.</p>
<p>Any help appreciated.
Cheers</p>
<p>(Vanilla JS only thx)</p>
| [
{
"answer_id": 74427636,
"author": "Ping",
"author_id": 20288037,
"author_profile": "https://Stackoverflow.com/users/20288037",
"pm_score": 0,
"selected": false,
"text": "const obj = {\n Apple: false,\n Banana: false,\n Orange: true,\n Kiwi: true\n }\n\nconst results = [];\n\nfor (const [fruit,boolean] of Object.entries(obj)) {\n if (boolean) results.push(fruit);\n}\n\nconsole.log(`There are ${results.length} 'true' in the given obj.\\nThey are:\\n${results.join(',\\n')}`)\n\n// output:\n// There are 2 'true' in the given obj.\n// They are:\n// Orange,\n// Kiwi"
},
{
"answer_id": 74427677,
"author": "Maniraj Murugan",
"author_id": 7785337,
"author_profile": "https://Stackoverflow.com/users/7785337",
"pm_score": 2,
"selected": true,
"text": "document.getElementById('container')"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19380514/"
] |
74,427,563 | <p>MySQL will accept NULL to an <code>auto increment</code> column and insert the last value. So you could presumably use</p>
<p>(Using the code from <a href="https://stackoverflow.com/a/46805508/631764">this SO answer</a>, where <code>st</code> is a <code>preparedStatement</code>)</p>
<p><code>st.setNull(1, java.sql.Types.NULL)</code></p>
<p>I'm trying to figure out how you do the same with Postgresql, where you cannot use <code>NULL</code>, but must use <code>DEFAULT</code> instead:</p>
<pre><code>INSERT INTO serial_table (id) VALUES(NULL)
</code></pre>
<p>Does something like this exist?</p>
<pre><code>st.setDefault(1, java.sql.Types.DEFAULT)
</code></pre>
<p>Or</p>
<pre><code>st.setObject(1, "DEFAULT")
</code></pre>
<p>I assume I can't just use the string "DEFAULT".</p>
<p>EDIT:</p>
<p>To clarify, this is a testing table defined as such:</p>
<pre><code>CREATE TABLE serial_table (
id SERIAL NOT NULL PRIMARY KEY
);
</code></pre>
<p>So I can't just skip the column to let Postgresql handle it</p>
<pre><code>INSERT INTO serial_table VALUES()
ERROR: syntax error at or near ")"
LINE 1: INSERT INTO serial_table VALUES();
^
</code></pre>
| [
{
"answer_id": 74428025,
"author": "a_horse_with_no_name",
"author_id": 330315,
"author_profile": "https://Stackoverflow.com/users/330315",
"pm_score": 2,
"selected": false,
"text": "INSERT INTO serial_table DEFAULT VALUES\n"
},
{
"answer_id": 74432646,
"author": "Dima",
"author_id": 4254517,
"author_profile": "https://Stackoverflow.com/users/4254517",
"pm_score": 0,
"selected": false,
"text": "insert into foo (bar) values (\"foobar\")\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/631764/"
] |
74,427,580 | <p>I have to take first list element and check if that substring is present in the other list element.
if the substring is present then append that string to another list.</p>
<p>INPUT
list1 = ["2044","1222"]
list2 = ["I am Raman 2044","I am Raman 2044"x,"I am Raman 2044","I am Rohan 1222","I am Rohan 1222"]</p>
<p>OUTPUT
list3 = ["I am Raman 2044I am Raman 2044I am Raman 2044","I am Rohan 1222I am Rohan 1222"]</p>
| [
{
"answer_id": 74427612,
"author": "xlmaster",
"author_id": 17917443,
"author_profile": "https://Stackoverflow.com/users/17917443",
"pm_score": 1,
"selected": false,
"text": " a in list[]"
},
{
"answer_id": 74429443,
"author": "Talha Tayyab",
"author_id": 13086128,
"author_profile": "https://Stackoverflow.com/users/13086128",
"pm_score": 0,
"selected": false,
"text": "k=[]\n\nlist1 = [\"2044\",\"1222\"]\n\nlist2 = [\"I am Raman 2044\",\"I am Raman 2044\",\"I am Raman 2044\",\"I am Rohan 1222\",\"I am Rohan 1222\"]\n\nRaman = ''.join(list2).split('I am Rohan 1222')\nRohan = ''.join(list2).split('I am Raman 2044')\n\nfor x in Raman:\n if len(x)>0:\n k.append(x)\n\nfor y in Rohan:\n if len(y)>0:\n k.append(y)\n\nprint(k)\n['I am Raman 2044I am Raman 2044I am Raman 2044', 'I am Rohan 1222I am Rohan 1222']\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20497750/"
] |
74,427,605 | <p>When I'm trying to compile program with threads, C2672 error ('invoke': no matching overloaded function found) is occuring.</p>
<p>My code:</p>
<pre><code>#include <iostream>
#include <thread>
// the procedure for array 2 filling
void bar(int sum2)
{
for (int i = 100000; i < 200000; i++) {
sum2 = sum2 + (i + 1);
std::cout << sum2;
}
}
int main()
{
// the second counter initialization
int sum2 = 0;
// the constructor for the thread
std::cout << "staring thread2...\n";
std::thread thread(bar);
// the thread detaching
thread.detach();
// the first counter initialization
int sum1 = 0;
// filling of the first array
for (int i = 0; i < 100000; i++) {
sum1 = sum1 + (i + 1);
// elements output
std::cout << sum1;
}
}
</code></pre>
<p>Tell me please, how to fix this bug?</p>
| [
{
"answer_id": 74427612,
"author": "xlmaster",
"author_id": 17917443,
"author_profile": "https://Stackoverflow.com/users/17917443",
"pm_score": 1,
"selected": false,
"text": " a in list[]"
},
{
"answer_id": 74429443,
"author": "Talha Tayyab",
"author_id": 13086128,
"author_profile": "https://Stackoverflow.com/users/13086128",
"pm_score": 0,
"selected": false,
"text": "k=[]\n\nlist1 = [\"2044\",\"1222\"]\n\nlist2 = [\"I am Raman 2044\",\"I am Raman 2044\",\"I am Raman 2044\",\"I am Rohan 1222\",\"I am Rohan 1222\"]\n\nRaman = ''.join(list2).split('I am Rohan 1222')\nRohan = ''.join(list2).split('I am Raman 2044')\n\nfor x in Raman:\n if len(x)>0:\n k.append(x)\n\nfor y in Rohan:\n if len(y)>0:\n k.append(y)\n\nprint(k)\n['I am Raman 2044I am Raman 2044I am Raman 2044', 'I am Rohan 1222I am Rohan 1222']\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20497483/"
] |
74,427,628 | <p>Can someone help me with a query on how to remove strings from an array in mongodb only if the string has a substring "abc.com"</p>
<p>Current result in a collection :</p>
<pre><code>{
_id: '1',
users: ['1@abc.com', '2@abc.com', '3@def.com']
}
{
_id: '2',
users: ['1@abc.com', '2@def.com', '3@def.com']
}
</code></pre>
<p>Expected Result :</p>
<pre><code>{
_id: '1',
users: ['3@def.com']
}
{
_id: '2',
users: ['2@def.com', '3@def.com']
}
</code></pre>
| [
{
"answer_id": 74427612,
"author": "xlmaster",
"author_id": 17917443,
"author_profile": "https://Stackoverflow.com/users/17917443",
"pm_score": 1,
"selected": false,
"text": " a in list[]"
},
{
"answer_id": 74429443,
"author": "Talha Tayyab",
"author_id": 13086128,
"author_profile": "https://Stackoverflow.com/users/13086128",
"pm_score": 0,
"selected": false,
"text": "k=[]\n\nlist1 = [\"2044\",\"1222\"]\n\nlist2 = [\"I am Raman 2044\",\"I am Raman 2044\",\"I am Raman 2044\",\"I am Rohan 1222\",\"I am Rohan 1222\"]\n\nRaman = ''.join(list2).split('I am Rohan 1222')\nRohan = ''.join(list2).split('I am Raman 2044')\n\nfor x in Raman:\n if len(x)>0:\n k.append(x)\n\nfor y in Rohan:\n if len(y)>0:\n k.append(y)\n\nprint(k)\n['I am Raman 2044I am Raman 2044I am Raman 2044', 'I am Rohan 1222I am Rohan 1222']\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14361300/"
] |
74,427,661 | <p>Here I'm developing a service which is going to receive a SOAP request Message and then convert it into JSON. After that, I want to invoke a REST API with the converted JSON and then I want to receive the JSON response back from that REST API and finally I want to convert that JSON response into SOAP Response message and then send it back the caller service. So basically this service is going to act as a intermediate Wrapper service between SOAP and REST communication.</p>
<p>I've the WSDL with me and need a way to do this by using Spring boot. Could any help me here please?</p>
<p>Currently I'm doing as below -</p>
<pre><code>@RestController
public class WrapperController {
@PostMapping(
value = "/wrap",
consumes = MediaType.APPLICATION_XML_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public Q248Req wrapSOAPRequest(@RequestBody String SOAPReq)
throws SOAPException, IOException, JAXBException {
System.out.println("SOAP Request: " + SOAPReq);
SOAPMessage message =
MessageFactory.newInstance()
.createMessage(null, new ByteArrayInputStream(SOAPReq.getBytes()));
Unmarshaller unmarshaller = JAXBContext.newInstance(TestObj.class).createUnmarshaller();
TestObj Req =
(TestObj) unmarshaller.unmarshal(message.getSOAPBody().extractContentAsDocument());
return Req;
}
</code></pre>
<p>I have generated the TestObj class from the supplied WSDL then I'm trying to map SOAP Message to TestObj class but it's throwing error -</p>
<pre><code>SOAP Body: [#document: null]
2022-11-14 12:36:43.888 ERROR 21596 --- [nio-9080-exec-3] c.s.x.m.s.s.impl : SAAJ0251: Unable to extract Document from body
2022-11-14 12:36:43.896 ERROR 21596 --- [nio-9080-exec-3] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/wrapper-service/v1/decisions/q248] threw exception [Request processing failed; nested exception is com.sun.xml.messaging.saaj.SOAPExceptionImpl: Unable to extract Document from body] with root cause
java.lang.ClassCastException: class com.sun.org.apache.xerces.internal.dom.TextImpl cannot be cast to class org.w3c.dom.Element (com.sun.org.apache.xerces.internal.dom.TextImpl and org.w3c.dom.Element are in module java.xml of loader 'bootstrap')
at com.sun.xml.messaging.saaj.soap.impl.BodyImpl.extractContentAsDocument(BodyImpl.java:338) ~[saaj-impl-1.5.3.jar:1.5.3]
at com.lbg.rsk.cdp.core.controller.WrapperController.wrapSOAPRequest(WrapperController.java:265) ~[main/:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.3.18.jar:5.3.18]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681) ~[tomcat-embed-core-9.0.60.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.18.jar:5.3.18]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.60.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96) ~[spring-boot-actuator-2.6.6.jar:2.6.6]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.60.jar:9.0.60]
at java.lang.Thread.run(Thread.java:829) [?:?]
</code></pre>
| [
{
"answer_id": 74427612,
"author": "xlmaster",
"author_id": 17917443,
"author_profile": "https://Stackoverflow.com/users/17917443",
"pm_score": 1,
"selected": false,
"text": " a in list[]"
},
{
"answer_id": 74429443,
"author": "Talha Tayyab",
"author_id": 13086128,
"author_profile": "https://Stackoverflow.com/users/13086128",
"pm_score": 0,
"selected": false,
"text": "k=[]\n\nlist1 = [\"2044\",\"1222\"]\n\nlist2 = [\"I am Raman 2044\",\"I am Raman 2044\",\"I am Raman 2044\",\"I am Rohan 1222\",\"I am Rohan 1222\"]\n\nRaman = ''.join(list2).split('I am Rohan 1222')\nRohan = ''.join(list2).split('I am Raman 2044')\n\nfor x in Raman:\n if len(x)>0:\n k.append(x)\n\nfor y in Rohan:\n if len(y)>0:\n k.append(y)\n\nprint(k)\n['I am Raman 2044I am Raman 2044I am Raman 2044', 'I am Rohan 1222I am Rohan 1222']\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19369457/"
] |
74,427,682 | <p>I have 2x RDS single instances (MySQL) in the same region.</p>
<p>The goal is to copy (A) RDS to (B) RDS on nightly basis.</p>
<p>Is there any way to have this configuration auto sync between 2 RDS instances?</p>
| [
{
"answer_id": 74427612,
"author": "xlmaster",
"author_id": 17917443,
"author_profile": "https://Stackoverflow.com/users/17917443",
"pm_score": 1,
"selected": false,
"text": " a in list[]"
},
{
"answer_id": 74429443,
"author": "Talha Tayyab",
"author_id": 13086128,
"author_profile": "https://Stackoverflow.com/users/13086128",
"pm_score": 0,
"selected": false,
"text": "k=[]\n\nlist1 = [\"2044\",\"1222\"]\n\nlist2 = [\"I am Raman 2044\",\"I am Raman 2044\",\"I am Raman 2044\",\"I am Rohan 1222\",\"I am Rohan 1222\"]\n\nRaman = ''.join(list2).split('I am Rohan 1222')\nRohan = ''.join(list2).split('I am Raman 2044')\n\nfor x in Raman:\n if len(x)>0:\n k.append(x)\n\nfor y in Rohan:\n if len(y)>0:\n k.append(y)\n\nprint(k)\n['I am Raman 2044I am Raman 2044I am Raman 2044', 'I am Rohan 1222I am Rohan 1222']\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12122963/"
] |
74,427,701 | <p>I use <code>EditForm</code> in the Blazor Server. The <code>EditForm</code> has a property named <code>OnValidSubmit</code>.<br />
Suppose that I have used the <code>Required</code> attribute on a field in the model such as:</p>
<pre><code> [Required]
public string Name { get; set; }
</code></pre>
<p>If the user disables JavaScript in the browser, is server-side validation also performed by <code>OnValidSubmit</code>?</p>
<p>There is the <code>ModelState.IsValid</code> In the asp.net <code>mvc</code>, Is there an alternative in Blazor? Considering the use of <code>OnValidSubmit</code>, is it really necessary to manually check the model validation again on the server side?</p>
| [
{
"answer_id": 74428849,
"author": "MrC aka Shaun Curtis",
"author_id": 13065781,
"author_profile": "https://Stackoverflow.com/users/13065781",
"pm_score": 2,
"selected": true,
"text": "OnSubmit"
},
{
"answer_id": 74432958,
"author": "Marvin Klein",
"author_id": 13440841,
"author_profile": "https://Stackoverflow.com/users/13440841",
"pm_score": 0,
"selected": false,
"text": "<EditForm Model=\"YourModel\" @ref=\"_form\">\n @* Your Form here *@\n</EditForm>\n\n<button type=\"button\" class=\"btn btn-primary\" @onclick=\"SubmitAsync\">Submit</button>\n\n@code {\n\n private EditForm? _form;\n\n private Task SubmitAsync()\n {\n if(_form is null || _form.EditContext is null)\n {\n return Task.CompletedTask;\n }\n\n if (_form.EditContext.Validate())\n {\n // Do your stuff here.\n }\n }\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4444757/"
] |
74,427,705 | <p>I want to render some JSX based on a condition, but it is not happenning. Below is my code -</p>
<pre><code>chkAccess().then((result) => {
console.log(result)
if(result) {
alert("Access Granted")
return (
<div className='login_container p-5 m-5 bg-dark'>
<h1 className='text-center p-3'>You are seeing this page because you are a Manager</h1>
</div>
)
}
alert("Access Denied")
return(<Access_denied />)
</code></pre>
<p>The JSX returned is not getting rendered. Why is it so and how I can i fix it?</p>
<p>I expect the returned code to be rendered, but It did not happen.</p>
| [
{
"answer_id": 74428849,
"author": "MrC aka Shaun Curtis",
"author_id": 13065781,
"author_profile": "https://Stackoverflow.com/users/13065781",
"pm_score": 2,
"selected": true,
"text": "OnSubmit"
},
{
"answer_id": 74432958,
"author": "Marvin Klein",
"author_id": 13440841,
"author_profile": "https://Stackoverflow.com/users/13440841",
"pm_score": 0,
"selected": false,
"text": "<EditForm Model=\"YourModel\" @ref=\"_form\">\n @* Your Form here *@\n</EditForm>\n\n<button type=\"button\" class=\"btn btn-primary\" @onclick=\"SubmitAsync\">Submit</button>\n\n@code {\n\n private EditForm? _form;\n\n private Task SubmitAsync()\n {\n if(_form is null || _form.EditContext is null)\n {\n return Task.CompletedTask;\n }\n\n if (_form.EditContext.Validate())\n {\n // Do your stuff here.\n }\n }\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13393219/"
] |
74,427,747 | <p>I am trying to convert a CSV into a dataframe and also updating column values in the CSV. But the issue I am facing is I am not getting rid of the index column as a result I am getting an extra index column without name in the console as follows.</p>
<pre><code> fsym_id factset_entity_id ... is_substituted is_current
0 VVG1JM-S ABCXYZ-Z ... True False
</code></pre>
<p>If you see below, there is no column name for 0. If I try dropping first column in the dataframe using the following code line, <code>df.drop(columns = df.columns[0], axis = 1, inplace= True)</code>, it drops the fsym_id column which I need. Below is the code.</p>
<pre><code>def update_run_id_in_csv(rds_db_conn,test_case_name,file_name):
df = pd.read_csv("{}/output/Float_Ingestion_Expected_Output_files/{}/{}.csv".format(str(parentDir), test_case_name, file_name))
df['run_id'] = '2323323232999'
#get_run_id(rds_db_conn,max_13f_query,query)
df.drop(columns = df.columns[0], axis = 1, inplace= True)
print(df)
</code></pre>
<p>There is no index column in the CSV. I am not able to understand how it gets added while updating the column run id in the data frame. How to get rid of the index column?</p>
| [
{
"answer_id": 74428849,
"author": "MrC aka Shaun Curtis",
"author_id": 13065781,
"author_profile": "https://Stackoverflow.com/users/13065781",
"pm_score": 2,
"selected": true,
"text": "OnSubmit"
},
{
"answer_id": 74432958,
"author": "Marvin Klein",
"author_id": 13440841,
"author_profile": "https://Stackoverflow.com/users/13440841",
"pm_score": 0,
"selected": false,
"text": "<EditForm Model=\"YourModel\" @ref=\"_form\">\n @* Your Form here *@\n</EditForm>\n\n<button type=\"button\" class=\"btn btn-primary\" @onclick=\"SubmitAsync\">Submit</button>\n\n@code {\n\n private EditForm? _form;\n\n private Task SubmitAsync()\n {\n if(_form is null || _form.EditContext is null)\n {\n return Task.CompletedTask;\n }\n\n if (_form.EditContext.Validate())\n {\n // Do your stuff here.\n }\n }\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20262433/"
] |
74,427,807 | <p>I have a search input tag, and I wanted to set a placeholder. In place holder I need to keep a magnify icon, how to do it in jquery? below is the code I tried</p>
<pre class="lang-js prettyprint-override"><code>$('.gridjs-head .gridjs-search .gridjs-search-input').attr("placeholder", "<i class='mdi mdi-magnify'></i>&nbsp;Search...")
</code></pre>
<p>I needed to use this path because I'm using grid.js to render table in my django project</p>
| [
{
"answer_id": 74428849,
"author": "MrC aka Shaun Curtis",
"author_id": 13065781,
"author_profile": "https://Stackoverflow.com/users/13065781",
"pm_score": 2,
"selected": true,
"text": "OnSubmit"
},
{
"answer_id": 74432958,
"author": "Marvin Klein",
"author_id": 13440841,
"author_profile": "https://Stackoverflow.com/users/13440841",
"pm_score": 0,
"selected": false,
"text": "<EditForm Model=\"YourModel\" @ref=\"_form\">\n @* Your Form here *@\n</EditForm>\n\n<button type=\"button\" class=\"btn btn-primary\" @onclick=\"SubmitAsync\">Submit</button>\n\n@code {\n\n private EditForm? _form;\n\n private Task SubmitAsync()\n {\n if(_form is null || _form.EditContext is null)\n {\n return Task.CompletedTask;\n }\n\n if (_form.EditContext.Validate())\n {\n // Do your stuff here.\n }\n }\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13431295/"
] |
74,427,834 | <pre class="lang-lisp prettyprint-override"><code>(equal? '(1 2) (cons 1 2)) ; #f
</code></pre>
<p>Why exactly are these two not equivalent considering lists are just that — <a href="https://gigamonkeys.com/book/they-called-it-lisp-for-a-reason-list-processing.html" rel="nofollow noreferrer">illusion built on top of cons cells</a>.</p>
| [
{
"answer_id": 74428307,
"author": "coredump",
"author_id": 124319,
"author_profile": "https://Stackoverflow.com/users/124319",
"pm_score": 2,
"selected": false,
"text": "'(1 2)\n"
},
{
"answer_id": 74428309,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 3,
"selected": false,
"text": "'(1 2)"
},
{
"answer_id": 74429254,
"author": "Rainer Joswig",
"author_id": 69545,
"author_profile": "https://Stackoverflow.com/users/69545",
"pm_score": 4,
"selected": true,
"text": "(cons 1 2)"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10363738/"
] |
74,427,847 | <p><a href="https://i.stack.imgur.com/SI9Wl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SI9Wl.png" alt="enter image description here" /></a></p>
<p>why is this error there in the terminal?</p>
<p>i was trying to run a simple file after saving it yet it wasnt able to locate the file in the directory as mentioned, hence was giving the following error.</p>
| [
{
"answer_id": 74428307,
"author": "coredump",
"author_id": 124319,
"author_profile": "https://Stackoverflow.com/users/124319",
"pm_score": 2,
"selected": false,
"text": "'(1 2)\n"
},
{
"answer_id": 74428309,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 3,
"selected": false,
"text": "'(1 2)"
},
{
"answer_id": 74429254,
"author": "Rainer Joswig",
"author_id": 69545,
"author_profile": "https://Stackoverflow.com/users/69545",
"pm_score": 4,
"selected": true,
"text": "(cons 1 2)"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15211424/"
] |
74,427,881 | <p>Hi I want to know how can i do this query in Laravel 8 , I tried adding the join clause but not work as expected, i need join clause? Or maybe there is another form to do it. I search others examples but i don´t see anythat help me. The query is the next:</p>
<pre><code>DB::table('escandallo_p as esc')
->select("esc.material", "esc.referencia", "esc.ancho", "esc.proveedor", "esc.punto",
"esc.precio", "esc.consumo", "esc.veces", "esc.001", "esc.002", "esc.003", "esc.004",
"esc.005", "esc.006", "esc.007", "esc.008", "esc.009", "esc.010", "esc.011", "esc.um", "esc.merma", "esc.importe", "esc.tipo", "esc.xtalla", "esc.fase",
DB::raw("(select anulado from prototipos_p as p where p.prototipo = '".$scandal[0]->prototipo."' and p.tipo = 'c' and p.referencia = esc.referencia )"),
// ignore
//original query "(select anulado from prototipos_p as p where p.prototipo = ",$request->prototipo," and p.tipo = 'c' and p.referencia = esc.referencia ) as 'anulado'",
// "(select clase from prototipos_p as p where p.prototipo = ",$request->prototipo," and p.tipo = 'c' and p.referencia = esc.referencia ) as 'clase'")
//Converted query ->select('pro.anulado')->where('pro.prototipo', $request->prototipo)
// ->where("p.prototipo", "=", $request->prototipo)
->where("esc.id_escandallo", "=", $request->id_escandallo)
->where("esc.id_version", "=", $request->version)
->orderBy("id","asc")
->get();
</code></pre>
<p>!!!! I need to pass the esc.referencia to the sub select query</p>
<p>The second select is the conversion of the select inside "" ( i know this is wrong is only for explain it).</p>
<p>Thank you in advance for any suggestion.</p>
<p>Best regards</p>
<p>EDIT: I can solve my problem with DB::raw, but if anyone know others methos are welcome!</p>
| [
{
"answer_id": 74428229,
"author": "Anuj Shrestha",
"author_id": 8630903,
"author_profile": "https://Stackoverflow.com/users/8630903",
"pm_score": 1,
"selected": false,
"text": "DB::table('users')\n ->join('contacts', function ($join) {\n $join->on('users.id', '=', 'contacts.user_id')\n ->where('contacts.user_id', '>', 5);\n })\n ->get();\n"
},
{
"answer_id": 74430251,
"author": "Peisou",
"author_id": 6260297,
"author_profile": "https://Stackoverflow.com/users/6260297",
"pm_score": 1,
"selected": true,
"text": "joins"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6260297/"
] |
74,427,883 | <p>I have a column that contains either letters or numbers. I want to add a column identifying whether each cell contains a letter or a number. The problem is that there are thousands of records in this particular database.</p>
<p>I tried the following syntax:</p>
<p><code>= Table.AddColumn(Source, "Column2", each if [Column1] is number then "Number" else "Letters")</code></p>
<p>My problem is that when I enter this, it returns everything as "Letter" because it looks at the column type instead of the actual value in the cell. This remains the case even when I change the column type from Text to General. Either way, it still produces "Letter" as it automatically assigns text as the data type since the column contains both text and numbers.</p>
| [
{
"answer_id": 74428368,
"author": "Peter",
"author_id": 7108589,
"author_profile": "https://Stackoverflow.com/users/7108589",
"pm_score": 1,
"selected": false,
"text": "= Table.AddColumn(Source, \"Column2\", each if List.Contains({\"0\"..\"9\"}, Text.Start([Column1], 1)) then \"Numbers\" else \"Letters\")\n"
},
{
"answer_id": 74431077,
"author": "horseyride",
"author_id": 9264230,
"author_profile": "https://Stackoverflow.com/users/9264230",
"pm_score": 0,
"selected": false,
"text": "= try if Value.Is(Number.From([Column1]), type number) then \"number\" else \"not\" otherwise \"not\"\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20172589/"
] |
74,427,904 | <p>I have string which is as follows below</p>
<pre><code>stg = 'AVBFGHJ'
</code></pre>
<p>I want the adjacent letter to be printed as expected below</p>
<pre><code>AV
VB
BF
FG
GH
HJ
J None
</code></pre>
<p>I tried below code but throws me error like Index out of Range</p>
<p><strong>My code :</strong></p>
<pre><code>for i in range(len(stg)):
print(stg[i],stg[i+1])
</code></pre>
| [
{
"answer_id": 74428368,
"author": "Peter",
"author_id": 7108589,
"author_profile": "https://Stackoverflow.com/users/7108589",
"pm_score": 1,
"selected": false,
"text": "= Table.AddColumn(Source, \"Column2\", each if List.Contains({\"0\"..\"9\"}, Text.Start([Column1], 1)) then \"Numbers\" else \"Letters\")\n"
},
{
"answer_id": 74431077,
"author": "horseyride",
"author_id": 9264230,
"author_profile": "https://Stackoverflow.com/users/9264230",
"pm_score": 0,
"selected": false,
"text": "= try if Value.Is(Number.From([Column1]), type number) then \"number\" else \"not\" otherwise \"not\"\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20497816/"
] |
74,427,981 | <p>I have two tables. Let's call it as t1 and t2. Below is the t1 table</p>
<pre><code>t1(product_number, date, sales_before)
t2(product_number, date, sales_after)
</code></pre>
<p>t1 table contains 247 rows and t2 contains 264 rows. I'm trying to match the rows on product_number and date and did inner join.</p>
<pre><code>select t1.*, t2.sales_after from t1
inner join t2
on t1.product_number = t2.product_number
and t1.date = t2.date
</code></pre>
<p>But it's returning around 600 rows.</p>
<p>The t1 and t2 table samples are below</p>
<p>t1</p>
<pre><code>product_number date sales_before
1 2022-01-01 22
2 2022-01-02 20
3 2022-01-03 47
</code></pre>
<p>t2</p>
<pre><code>product_number date sales_after
1 2022-01-01 31
2 2022-01-02 9
4 2022-01-10 97
</code></pre>
<p>I'm expecting output like</p>
<pre><code>product_number date sales_before sales_after
1 2022-01-01 22 31
2 2022-01-02 20 9
3 2022-01-03 47 NULL
4 2022-01-10 NULL 97
</code></pre>
<p>Can anyone help me with this?</p>
| [
{
"answer_id": 74428182,
"author": "Mark",
"author_id": 18158837,
"author_profile": "https://Stackoverflow.com/users/18158837",
"pm_score": 0,
"selected": false,
"text": "select \n coalesce(t1.product_number, t2.product_number), \n coalesce(t2.date, t2.date), \n t1.sales_before, \n t2.sales_after \nfrom \n t1 \n full outer join t2 on t1.product_number = t2.product_number \n and t1.date = t2.date\n"
},
{
"answer_id": 74428208,
"author": "Hosein Hamedan",
"author_id": 4636301,
"author_profile": "https://Stackoverflow.com/users/4636301",
"pm_score": 2,
"selected": true,
"text": "enter code here\n\n SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_before\nFROM #t1 t1\nfull JOIN #t2 t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
},
{
"answer_id": 74428253,
"author": "lavantho0508_java_dev",
"author_id": 18500877,
"author_profile": "https://Stackoverflow.com/users/18500877",
"pm_score": 1,
"selected": false,
"text": "SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_after\nFROM t1\nfull outer JOIN t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74427981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18158837/"
] |
74,428,016 | <p>Are there any real computaional problems which can be solved by time complexity of log(n) * log(n)?</p>
<ul>
<li><p>This is different from finding smallest element in sorted matrix, which is log(n)+log(n) or 2log(n).</p>
</li>
<li><p>There are can be some kind of pattern printing algorithm which can be made as ϴ(logn)^2 but I'm not sure if they are classified as Computational Problems.</p>
</li>
</ul>
| [
{
"answer_id": 74428182,
"author": "Mark",
"author_id": 18158837,
"author_profile": "https://Stackoverflow.com/users/18158837",
"pm_score": 0,
"selected": false,
"text": "select \n coalesce(t1.product_number, t2.product_number), \n coalesce(t2.date, t2.date), \n t1.sales_before, \n t2.sales_after \nfrom \n t1 \n full outer join t2 on t1.product_number = t2.product_number \n and t1.date = t2.date\n"
},
{
"answer_id": 74428208,
"author": "Hosein Hamedan",
"author_id": 4636301,
"author_profile": "https://Stackoverflow.com/users/4636301",
"pm_score": 2,
"selected": true,
"text": "enter code here\n\n SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_before\nFROM #t1 t1\nfull JOIN #t2 t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
},
{
"answer_id": 74428253,
"author": "lavantho0508_java_dev",
"author_id": 18500877,
"author_profile": "https://Stackoverflow.com/users/18500877",
"pm_score": 1,
"selected": false,
"text": "SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_after\nFROM t1\nfull outer JOIN t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19365435/"
] |
74,428,021 | <p>here is my app.js</p>
<pre><code><Router>
<Header title="My Todos List" />
<Routes>
<Route path="/about" element={<About />} />
<Route path="/" render={() => {
return (
<>
<AddTodo addTodo={addTodo} />
<Todos todos={todos} onDelete={onDelete} />
</>)
}} />
</Routes>
<Footer />
</Router>
</code></pre>
<p>the render function is not rendering anything in my home page</p>
| [
{
"answer_id": 74428182,
"author": "Mark",
"author_id": 18158837,
"author_profile": "https://Stackoverflow.com/users/18158837",
"pm_score": 0,
"selected": false,
"text": "select \n coalesce(t1.product_number, t2.product_number), \n coalesce(t2.date, t2.date), \n t1.sales_before, \n t2.sales_after \nfrom \n t1 \n full outer join t2 on t1.product_number = t2.product_number \n and t1.date = t2.date\n"
},
{
"answer_id": 74428208,
"author": "Hosein Hamedan",
"author_id": 4636301,
"author_profile": "https://Stackoverflow.com/users/4636301",
"pm_score": 2,
"selected": true,
"text": "enter code here\n\n SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_before\nFROM #t1 t1\nfull JOIN #t2 t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
},
{
"answer_id": 74428253,
"author": "lavantho0508_java_dev",
"author_id": 18500877,
"author_profile": "https://Stackoverflow.com/users/18500877",
"pm_score": 1,
"selected": false,
"text": "SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_after\nFROM t1\nfull outer JOIN t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498097/"
] |
74,428,034 | <p>I have a list of Map of Strings like this</p>
<pre><code>List<Map<String, String>> dataListMap = new ArrayList<>();
Map<String, String> dataMap = new HashMap<String, String>() {
{
put("Charged fare", "3");
put("Trip ID", "1");
put("Account", "220");
}
};
dataListMap.add(dataMap);
dataMap = new HashMap<String, String>() {
{
put("Charged fare", "5");
put("Trip ID", "2");
put("Account", "220");
}
};
dataListMap.add(dataMap);
dataMap = new HashMap<String, String>() {
{
put("Charged fare", "7");
put("Trip ID", "3");
put("Account", "230");
}
};
dataListMap.add(dataMap);
dataMap = new HashMap<String, String>() {
{
put("Charged fare", "8");
put("Trip ID", "4");
put("Account", "230");
}
};
dataListMap.add(dataMap);
</code></pre>
<p>I want to separate this list by the account number and convert this to two list in side a List<List<Map<String,String>>> Is there an easy way to do that?Please help</p>
| [
{
"answer_id": 74428182,
"author": "Mark",
"author_id": 18158837,
"author_profile": "https://Stackoverflow.com/users/18158837",
"pm_score": 0,
"selected": false,
"text": "select \n coalesce(t1.product_number, t2.product_number), \n coalesce(t2.date, t2.date), \n t1.sales_before, \n t2.sales_after \nfrom \n t1 \n full outer join t2 on t1.product_number = t2.product_number \n and t1.date = t2.date\n"
},
{
"answer_id": 74428208,
"author": "Hosein Hamedan",
"author_id": 4636301,
"author_profile": "https://Stackoverflow.com/users/4636301",
"pm_score": 2,
"selected": true,
"text": "enter code here\n\n SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_before\nFROM #t1 t1\nfull JOIN #t2 t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
},
{
"answer_id": 74428253,
"author": "lavantho0508_java_dev",
"author_id": 18500877,
"author_profile": "https://Stackoverflow.com/users/18500877",
"pm_score": 1,
"selected": false,
"text": "SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_after\nFROM t1\nfull outer JOIN t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19499442/"
] |
74,428,041 | <p>I want my image resize relatively from parent <code>Containerwidget</code> and defined <code>scale: 0.8,//here</code> in <code>AssetImage()</code> but it doesn't work ? How Can I fix this ?</p>
<pre><code> Container(
margin: const EdgeInsets.only(top: 30),
alignment: Alignment.centerLeft,
child: Wrap(
children: [
GestureDetector(
onTap: () {
print("test");
},
child: Container(
width: 50,
height: 50,
// color: Colors.green,
decoration: const BoxDecoration(
color: Colors.blue,
shape: BoxShape.circle,
image:
DecorationImage(
fit: BoxFit.fill,
image: AssetImage('images/prop/lock.png'),
scale: 0.8,//here
),
),
),
),
],
),
),
</code></pre>
<hr />
<p>Additional comment
I think <code>LayoutBuilder()</code> doesn't work appropriately.
<a href="https://i.stack.imgur.com/hXerP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hXerP.png" alt="enter image description here" /></a></p>
<pre><code> Container(
margin: const EdgeInsets.only(top: 30),
alignment: Alignment.centerLeft,
child: Wrap(
children: [
GestureDetector(
onTap: () {
print("test");
},
child: Container(
width: 50,
height: 50,
// color: Colors.green,
decoration: const BoxDecoration(
color: Colors.blue,
shape: BoxShape.circle,
),
child: LayoutBuilder(
builder: (context, constraints) {
return Image.asset(
'images/prop/lock.png',
fit: BoxFit.none,
height: constraints.maxHeight * 0.1,
width: constraints.maxWidth * 0.1,
);
},
),
),
),
],
),
),
</code></pre>
| [
{
"answer_id": 74428182,
"author": "Mark",
"author_id": 18158837,
"author_profile": "https://Stackoverflow.com/users/18158837",
"pm_score": 0,
"selected": false,
"text": "select \n coalesce(t1.product_number, t2.product_number), \n coalesce(t2.date, t2.date), \n t1.sales_before, \n t2.sales_after \nfrom \n t1 \n full outer join t2 on t1.product_number = t2.product_number \n and t1.date = t2.date\n"
},
{
"answer_id": 74428208,
"author": "Hosein Hamedan",
"author_id": 4636301,
"author_profile": "https://Stackoverflow.com/users/4636301",
"pm_score": 2,
"selected": true,
"text": "enter code here\n\n SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_before\nFROM #t1 t1\nfull JOIN #t2 t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
},
{
"answer_id": 74428253,
"author": "lavantho0508_java_dev",
"author_id": 18500877,
"author_profile": "https://Stackoverflow.com/users/18500877",
"pm_score": 1,
"selected": false,
"text": "SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_after\nFROM t1\nfull outer JOIN t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6843543/"
] |
74,428,043 | <p>I am unable to register an user from my app written in Flutter. I am also unable to get some form for error message. I can debug and see my createUser function is called and the arguments looks good. Nothing happens after I call "FirebaseAuth.instance.createUserWithEmailAndPassword". No exception and nothing is printed in the FireBase emulator console. What am I missing here? Here is what I got:</p>
<pre><code>Emulator:
Running on 127.0.0.1:9099
</code></pre>
<p>main.dart:</p>
<pre><code>void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,);
try {
await FirebaseAuth.instance.useAuthEmulator('localhost', 9099);
} catch (e) {
// ignore: avoid_print
print(e);
}
runApp(
MaterialApp(
title: "Foo",
home: buildContent(),
),
);
}
</code></pre>
<p>Registration function:</p>
<pre><code>void createUser() async {
print("createUser()");
try {
final credential = await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: nameController.text,
password: passwordController.text,
);
//final credential = await FirebaseAuth.instance.createUserWithEmailAndPassword(email: nameController.text, password: passwordController.text);
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
print('The password provided is too weak.');
} else if (e.code == 'email-already-in-use') {
print('The account already exists for that email.');
}
} catch (e) {
print(e);
}
}
</code></pre>
<p>Edit:
I keep getting this message when i call "createUserWithEmailAndPassword"</p>
<p>W/System (26859): Ignoring header X-Firebase-Locale because its value was null.</p>
| [
{
"answer_id": 74428182,
"author": "Mark",
"author_id": 18158837,
"author_profile": "https://Stackoverflow.com/users/18158837",
"pm_score": 0,
"selected": false,
"text": "select \n coalesce(t1.product_number, t2.product_number), \n coalesce(t2.date, t2.date), \n t1.sales_before, \n t2.sales_after \nfrom \n t1 \n full outer join t2 on t1.product_number = t2.product_number \n and t1.date = t2.date\n"
},
{
"answer_id": 74428208,
"author": "Hosein Hamedan",
"author_id": 4636301,
"author_profile": "https://Stackoverflow.com/users/4636301",
"pm_score": 2,
"selected": true,
"text": "enter code here\n\n SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_before\nFROM #t1 t1\nfull JOIN #t2 t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
},
{
"answer_id": 74428253,
"author": "lavantho0508_java_dev",
"author_id": 18500877,
"author_profile": "https://Stackoverflow.com/users/18500877",
"pm_score": 1,
"selected": false,
"text": "SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_after\nFROM t1\nfull outer JOIN t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1348837/"
] |
74,428,048 | <p>I have a react application where I pass state via react router and access the state using location in the target component/page. It works perfect, however when I close the tab and paste the exact same url to that page in another tab it crashes and says <code>Cannot read properties of null (reading '1')</code>. This is how I am accessing the state:</p>
<pre><code>const { filter, mode } = location?.state[1];
</code></pre>
<p>I want to navigate to home page if the location state is null.</p>
<p>I have tried the following but does not seem to work.</p>
<pre><code>if (location.state === null) {
navigate("/");
}
const { filter, mode } = location?.state[1];
</code></pre>
<p>Any help will be appreciated</p>
| [
{
"answer_id": 74428182,
"author": "Mark",
"author_id": 18158837,
"author_profile": "https://Stackoverflow.com/users/18158837",
"pm_score": 0,
"selected": false,
"text": "select \n coalesce(t1.product_number, t2.product_number), \n coalesce(t2.date, t2.date), \n t1.sales_before, \n t2.sales_after \nfrom \n t1 \n full outer join t2 on t1.product_number = t2.product_number \n and t1.date = t2.date\n"
},
{
"answer_id": 74428208,
"author": "Hosein Hamedan",
"author_id": 4636301,
"author_profile": "https://Stackoverflow.com/users/4636301",
"pm_score": 2,
"selected": true,
"text": "enter code here\n\n SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_before\nFROM #t1 t1\nfull JOIN #t2 t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
},
{
"answer_id": 74428253,
"author": "lavantho0508_java_dev",
"author_id": 18500877,
"author_profile": "https://Stackoverflow.com/users/18500877",
"pm_score": 1,
"selected": false,
"text": "SELECT COALESCE(t2.product_number,t1.product_number) product_number\n ,COALESCE(t1.date,t2.date)date ,\n t1.sales_before ,\n t2.sales_after\nFROM t1\nfull outer JOIN t2 ON t1.product_number = t2.product_number\nAND t1.date = t2.date\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20475046/"
] |
74,428,065 | <p>I just upgraded to version 4.5.0 of WebDriver, using JMeter 5.5, and can't perform any actions.</p>
<p>Based on the official docs: <code>https://jmeter-plugins.org/wiki/WebDriverSampler/</code>
should be using like:</p>
<pre><code>var pkg = JavaImporter(org.openqa.selenium) but I faced exception.
</code></pre>
<p>Is there any way how to resolve this exception, so I can use it for sendKeys or click actions?</p>
<p><a href="https://i.stack.imgur.com/KFPc8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KFPc8.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74428512,
"author": "Dmitri T",
"author_id": 2897748,
"author_profile": "https://Stackoverflow.com/users/2897748",
"pm_score": 2,
"selected": true,
"text": "groovy"
},
{
"answer_id": 74429559,
"author": "vlatko606",
"author_id": 5210482,
"author_profile": "https://Stackoverflow.com/users/5210482",
"pm_score": 0,
"selected": false,
"text": "Jmeter5.5 + Java17 + selenium version 4.5.0 + groovy as language"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5210482/"
] |
74,428,084 | <p>in the reactjs I am not understand the below code please help me in this</p>
<pre><code>...todo, complete: !todo.complete
</code></pre>
<p>according to me first ...todo is the spread array, and after comma the condition has been implemented on it.</p>
| [
{
"answer_id": 74428255,
"author": "Konrad",
"author_id": 5089567,
"author_profile": "https://Stackoverflow.com/users/5089567",
"pm_score": 0,
"selected": false,
"text": "!false -> true\n!true -> false\n"
},
{
"answer_id": 74430702,
"author": "Dev-Siri",
"author_id": 18646049,
"author_profile": "https://Stackoverflow.com/users/18646049",
"pm_score": 0,
"selected": false,
"text": "const todo = {\n completed: false,\n title: \"Test\"\n};\n\nconst sameTodo = { ...todo };\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12927552/"
] |
74,428,087 | <p>In Javascript I tried to add a function like this for checking if the entered password contains any symbol (special) character such as <code>!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?</code>.</p>
<p>So I did this:</p>
<pre><code> function checkpasswordlength(){
var format1 = /^[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]*$/;
var e = document.getElementById("password").value;
if(e != "") {
if(e.length >= 12){
if(e.match(format1)){
document.getElementById("passwordstrengthstatus").style.display = "inline";
document.getElementById("passwordstrengthstatus").innerHTML = "strong";
document.getElementById("passwordstrengthstatus").style.setProperty('background-color', '#3cb878', 'important');
}else{
document.getElementById("passwordstrengthstatus").style.display = "inline";
document.getElementById("passwordstrengthstatus").innerHTML = "normal";
document.getElementById("passwordstrengthstatus").style.setProperty('background-color', '#3cb878', 'important');
}
}else{
document.getElementById("passwordstrengthstatus").style.display = "inline";
document.getElementById("passwordstrengthstatus").innerHTML = "weak";
document.getElementById("passwordstrengthstatus").style.setProperty('background-color', 'red', 'important');
}
}else{
document.getElementById("passwordstrengthstatus").style.display = "none";
}
}
</code></pre>
<p>As you can see, it will check if the password is not empty and it's length is more than <code>12</code> characters, then go ahead and check for <code>e.match(format1)</code>.</p>
<p>But the problem is, when I enter those characters as well, it will not return this condition as true and therefore the message <strong><code>strong</code></strong> does not appear and still shows <strong><code>normal</code></strong> message on screen.</p>
<p>So what's going wrong with this?</p>
<p>How can I solve this problem and properly check if the string contains the written symbols or not?</p>
| [
{
"answer_id": 74428255,
"author": "Konrad",
"author_id": 5089567,
"author_profile": "https://Stackoverflow.com/users/5089567",
"pm_score": 0,
"selected": false,
"text": "!false -> true\n!true -> false\n"
},
{
"answer_id": 74430702,
"author": "Dev-Siri",
"author_id": 18646049,
"author_profile": "https://Stackoverflow.com/users/18646049",
"pm_score": 0,
"selected": false,
"text": "const todo = {\n completed: false,\n title: \"Test\"\n};\n\nconst sameTodo = { ...todo };\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17730693/"
] |
74,428,156 | <p>I want to show the drop-down links in a particular order. Right now the order is -</p>
<ul>
<li>Link 1</li>
<li>Link 3</li>
<li>Link 2</li>
</ul>
<p>HTML Code -</p>
<pre><code><ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"></a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Link 1</a></li>
<li><a class="dropdown-item" href="#">Link 3</a></li>
</ul>
</li>
</ul>
</code></pre>
<p>Javascript Code -</p>
<pre><code>if (role == "admin") {
$(".dropdown-menu").append('<li>'+
'<a class="dropdown-item" href="#">Link 2</a>'+
'</li>');
}
</code></pre>
<p>Can anyone tell me how can I show the links in the following order?</p>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
| [
{
"answer_id": 74428343,
"author": "Vivekanand Vishvkarma",
"author_id": 19443694,
"author_profile": "https://Stackoverflow.com/users/19443694",
"pm_score": 1,
"selected": true,
"text": "if (role == \"admin\") {\n $(\".dropdown-menu :first\").after('<li>'+\n '<a class=\"dropdown-item\" href=\"#\">Link 2</a>'+\n '</li>');\n}\n"
},
{
"answer_id": 74428358,
"author": "Maniraj Murugan",
"author_id": 7785337,
"author_profile": "https://Stackoverflow.com/users/7785337",
"pm_score": 1,
"selected": false,
"text": "textContent"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15439038/"
] |
74,428,166 | <p>I have this pretty straightforward formula in my <a href="https://docs.google.com/spreadsheets/d/1vMbnxv-Oz5hzEowZvjrc1KVWwI1q0N03cs-z9Zs5lBE/edit#gid=0" rel="nofollow noreferrer">Spreadsheet</a>:</p>
<blockquote>
<p>={"Number of purchases"; SUM(C3:C) ; ARRAYFORMULA(if(isblank(A3:A),,sumif('Raw Data'!A:A,A3:A,'Raw
Data'!B:B)+sumif('Raw Data'!A:A,B3:B,'Raw Data'!B:B)))}</p>
</blockquote>
<p>The issue is when I apply a filter to row 1, my SUM will be messed up if I sort the data.
I would like my filter to remain in row 1 and not to row 2.</p>
<p>Any solution/help would be appreciated.</p>
| [
{
"answer_id": 74430994,
"author": "The God of Biscuits",
"author_id": 18645332,
"author_profile": "https://Stackoverflow.com/users/18645332",
"pm_score": 1,
"selected": false,
"text": "={\"Number of purchases\"&CHAR(10)&SUM(C2:C);...}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18778887/"
] |
74,428,175 | <p>I have a JSON array where I need to get the CustomerId value from property where the CustomerId property exits for that section, I'm trying below to loop through the categories and skip the one that has no CustomerId property down its properties tree</p>
<pre><code>var customerId = "";
foreach (var category in JObject.Parse(someData)?["categories"])
{
val = category?["sections"].FirstOrDefault()
?["areas"]?.FirstOrDefault()
?["components"]?.
?["variables"]?.FirstOrDefault()
?["properties"]
?["customerId"]?.ToString();
if (val == null)
continue;
else
{
customerId = val;
break;
}
}
</code></pre>
<p>Problem is this looks inefficient (less readable) in the sense that I imagine there is a nice <code>.Select</code> that can be used to get the same result without going forEach element and check if the property is null.</p>
<p>Please not this is not an issue I have, this is working, I'd only like to do this in a more readable way using <code>Select</code> instead of <code>ForEach</code>.</p>
<p>Sample JSON Data</p>
<pre><code> {
"categories": [
{
"identifier": "cat1",
"sections": [
{
"identifier": "030615e9-67f9-43ca-a06e-194e7afadccb",
"properties": {},
"areas": [
{
"identifier": "1206f27b-d354-4bfa-9b5e-1fe6b4f7cc83",
"componenets": [
{
"identifier": "49e4550f-8001-4d32-b796-a7ad4423e118",
"type": "Product",
"variables": [
{
"identifier": "0d260417-fa6d-492b-85f1-dc2565bc4805",
"properties": {
"description": ""
}
}
]
}
]
}
]
}
]
},
{
"identifier": "cat2",
"sections": [
{
"identifier": "00b5bfa6-f482-47c2-bdd7-aaac273b7772",
"properties": {},
"areas": [
{
"identifier": "1ca9d051-5ec0-45af-84bc-561cd7620efa",
"componenets": [
{
"identifier": "c73b1e52-3acd-4020-8fc5-adfef7d633b4",
"type": "Customer",
"variables": [
{
"identifier": "0064e872-5c7f-4ec7-a2d6-e8b35b94bd1d",
"properties": {
"customerId": { "Text":"MainId",
"Value":"A12123"
}
}
}
]
}
]
}
]
}
]
}
]
}
</code></pre>
| [
{
"answer_id": 74428271,
"author": "mikovacs",
"author_id": 18656819,
"author_profile": "https://Stackoverflow.com/users/18656819",
"pm_score": 0,
"selected": false,
"text": "List<T> arrayItems = jsonBuidler?[\"categories\"].ReadFromJson<List<T>>();\nList<string> customerIds = arrayItems\n .Where(_ => CustomerId != null)\n .Select(_ => _.CustomerId);\n"
},
{
"answer_id": 74428653,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 2,
"selected": true,
"text": ".SelectTokens"
},
{
"answer_id": 74428732,
"author": "L01NL",
"author_id": 686023,
"author_profile": "https://Stackoverflow.com/users/686023",
"pm_score": 1,
"selected": false,
"text": "categories"
},
{
"answer_id": 74428783,
"author": "D A",
"author_id": 13840530,
"author_profile": "https://Stackoverflow.com/users/13840530",
"pm_score": 1,
"selected": false,
"text": "var pJson = JObject.Parse(someData);\nJToken? customerToken = pJson.SelectToken($\"$..customerId\");\nvar customerId = customerToken?.ToString();\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/272414/"
] |
74,428,306 | <p>I am using Docker on my Windows machine and i want to copy a directory to another directory in my Windows host. I have a Maven project that does this on Windows using org.apache.commons.FileUtils library and it works just fine. I want to run this Maven project in my Docker container so that i can move files on my Windows via Docker.</p>
<p>When i tried doing it, it gave no error but there was no copy process either. Can i manage files on my host machine with Docker?</p>
| [
{
"answer_id": 74428271,
"author": "mikovacs",
"author_id": 18656819,
"author_profile": "https://Stackoverflow.com/users/18656819",
"pm_score": 0,
"selected": false,
"text": "List<T> arrayItems = jsonBuidler?[\"categories\"].ReadFromJson<List<T>>();\nList<string> customerIds = arrayItems\n .Where(_ => CustomerId != null)\n .Select(_ => _.CustomerId);\n"
},
{
"answer_id": 74428653,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 2,
"selected": true,
"text": ".SelectTokens"
},
{
"answer_id": 74428732,
"author": "L01NL",
"author_id": 686023,
"author_profile": "https://Stackoverflow.com/users/686023",
"pm_score": 1,
"selected": false,
"text": "categories"
},
{
"answer_id": 74428783,
"author": "D A",
"author_id": 13840530,
"author_profile": "https://Stackoverflow.com/users/13840530",
"pm_score": 1,
"selected": false,
"text": "var pJson = JObject.Parse(someData);\nJToken? customerToken = pJson.SelectToken($\"$..customerId\");\nvar customerId = customerToken?.ToString();\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19004150/"
] |
74,428,310 | <p>I've created Procedure in order to insert new employees, but the problem is, it is not inserting. I need to pass the attributes values as parameters. This is my code:</p>
<pre><code>CREATE OR REPLACE PROCEDURE p_new(p_empid IN employees.employee_id%type,
p_fname IN employees.first_name%type,
p_lname IN employees.last_name%type,
p_email IN employees.email%type,
p_pnum IN employees.phone_number%type,
p_hdate IN employees.hire_date%type,
p_jid IN employees.job_id%type,
p_salary IN employees.salary%type,
p_comm IN employees.commission_pct%type,
p_mid IN employees.manager_id%type,
p_deptid IN employees.department_id%type) AS
v_empid employees.employee_id%type;
v_fname employees.first_name%type;
v_lname employees.last_name%type;
v_email employees.email%type;
v_pnum employees.phone_number%type;
v_hdate employees.hire_date%type;
v_jid employees.job_id%type;
v_salary employees.salary%type;
v_comm employees.commission_pct%type;
v_mid employees.manager_id%type;
v_deptid employees.department_id%type;
CURSOR c_emp IS
select employee_id, first_name, last_name, email, phone_number,
hire_date, job_id, salary, commission_pct, manager_id, department_id
from employees
WHERE employee_id=p_empid;
BEGIN
OPEN c_emp;
FETCH c_emp INTO
v_empid, v_fname, v_lname, v_email, v_pnum, v_hdate,
v_jid, v_salary, v_comm, v_mid, v_deptid;
INSERT INTO EMPLOYEES(employee_id, first_name, last_name, email, phone_number,
hire_date, job_id, salary, commission_pct, manager_id, department_id)
VALUES (v_empid, v_fname, v_lnamw, v_email, v_pnum, v_hdate,
v_jid, v_salary, v_comm, v_mid, v_deptid);
CLOSE c_emp;
END;
/
</code></pre>
<p>I don't know which is wrong in this one. And this is my code for calling procedure</p>
<p>For calling Procedure:</p>
<pre><code>DECLARE
v_empid employees.employee_id%type:=600;
v_fname employees.first_name%type:='text';
v_lname employees.last_name%type:='string';
v_email employees.email%type:='string';
v_pnum employees.phone_number%type:=123456789;
v_hdate employees.hire_date%type:='18-SEP-2000';
v_jid employees.job_id%type:='string';
v_salary employees.salary%type:=4000;
v_comm employees.commission_pct%type:=0.5;
v_mid employees.manager_id%type:=105;
v_deptid employees.department_id%type:=30;
BEGIN
p_new(v_empid, v_fname, v_lname,
v_email,v_pnum,v_hdate,v_jid,v_salary,v_comm,
v_mid,v_deptid);
END;
/
</code></pre>
<p>I don't know why it is not inserting. I am having an error of unique constraint</p>
| [
{
"answer_id": 74428271,
"author": "mikovacs",
"author_id": 18656819,
"author_profile": "https://Stackoverflow.com/users/18656819",
"pm_score": 0,
"selected": false,
"text": "List<T> arrayItems = jsonBuidler?[\"categories\"].ReadFromJson<List<T>>();\nList<string> customerIds = arrayItems\n .Where(_ => CustomerId != null)\n .Select(_ => _.CustomerId);\n"
},
{
"answer_id": 74428653,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 2,
"selected": true,
"text": ".SelectTokens"
},
{
"answer_id": 74428732,
"author": "L01NL",
"author_id": 686023,
"author_profile": "https://Stackoverflow.com/users/686023",
"pm_score": 1,
"selected": false,
"text": "categories"
},
{
"answer_id": 74428783,
"author": "D A",
"author_id": 13840530,
"author_profile": "https://Stackoverflow.com/users/13840530",
"pm_score": 1,
"selected": false,
"text": "var pJson = JObject.Parse(someData);\nJToken? customerToken = pJson.SelectToken($\"$..customerId\");\nvar customerId = customerToken?.ToString();\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498206/"
] |
74,428,347 | <p>I want to align diffrent items within one element! I tried to give the Element an flexbox and adjust the items themselv inside! but it don't responde properly ! The List Items should be aligned in a row, left-links on the left side and right-links on the right side! Logo should be in the center!</p>
<pre><code>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flex Header</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header">
<div class="left-links">
<ul>
<li><a href="#">ONE</a></li>
<li><a href="#">TWO</a></li>
<li><a href="#">THREE</a></li>
</ul>
</div>
<div class="logo">LOGO</div>
<div class="right-links">
<ul>
<li><a href="#">FOUR</a></li>
<li><a href="#">FIVE</a></li>
<li><a href="#">SIX</a></li>
</ul>
</div>
</div>
</body>
</html>
</code></pre>
<pre><code>
.header {
font-family: monospace;
background: papayawhip;
display: flex;
align-items: center;
}
.logo {
font-size: 48px;
font-weight: 900;
color: tomato;
background: white;
padding: 4px 32px;
}
ul {
/* this removes the dots on the list items*/
list-style-type: none;
}
a {
font-size: 22px;
background: white;
padding: 8px;
/* this removes the line under the links */
text-decoration: none;
}
.header .left-links {
display: flex;
justify-content: flex-start; //I tried justify-items also, but it doesn't help!
flex-direction: row;
}
.header .logo {
display: flex;
justify-content: center;
}
.header .right-links {
display: flex;
justify-content: flex-end;
flex-direction: row;
}
</code></pre>
<p>//I tried justify-items also, but it doesn't help!</p>
| [
{
"answer_id": 74428271,
"author": "mikovacs",
"author_id": 18656819,
"author_profile": "https://Stackoverflow.com/users/18656819",
"pm_score": 0,
"selected": false,
"text": "List<T> arrayItems = jsonBuidler?[\"categories\"].ReadFromJson<List<T>>();\nList<string> customerIds = arrayItems\n .Where(_ => CustomerId != null)\n .Select(_ => _.CustomerId);\n"
},
{
"answer_id": 74428653,
"author": "ProgrammingLlama",
"author_id": 3181933,
"author_profile": "https://Stackoverflow.com/users/3181933",
"pm_score": 2,
"selected": true,
"text": ".SelectTokens"
},
{
"answer_id": 74428732,
"author": "L01NL",
"author_id": 686023,
"author_profile": "https://Stackoverflow.com/users/686023",
"pm_score": 1,
"selected": false,
"text": "categories"
},
{
"answer_id": 74428783,
"author": "D A",
"author_id": 13840530,
"author_profile": "https://Stackoverflow.com/users/13840530",
"pm_score": 1,
"selected": false,
"text": "var pJson = JObject.Parse(someData);\nJToken? customerToken = pJson.SelectToken($\"$..customerId\");\nvar customerId = customerToken?.ToString();\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20308702/"
] |
74,428,413 | <p>I'm learning multi-head attention with <a href="https://towardsdatascience.com/transformers-explained-visually-part-3-multi-head-attention-deep-dive-1c1ff1024853" rel="nofollow noreferrer">this article</a>.
As the writer claimed, the structure of MHA (by the original paper) is as follows:</p>
<p><a href="https://i.stack.imgur.com/hwDQq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hwDQq.png" alt="enter image description here" /></a></p>
<p>But the <a href="https://www.tensorflow.org/api_docs/python/tf/keras/layers/MultiHeadAttention" rel="nofollow noreferrer"><code>MultiHeadAttention</code></a> layer of Tensorflow seems to be more flexible:</p>
<ol>
<li>It does not require <code>key_dim * num_heads = embed_dim</code>. Like:</li>
</ol>
<pre><code>layer = tf.keras.layers.MultiHeadAttention(num_heads = 2, key_dim = 4)
x = tf.keras.Input(shape=[3, 5])
layer(x, x)
# no error
</code></pre>
<p>Does the depth of the weight matrix in <code>tf.MHA</code> layer set to <code>key_dim * num_heads</code> regardless of <code>embed_dim</code>? So that Q/K/V can still be properly split by <code>num_heads</code>.</p>
<ol start="2">
<li>However, the output depth of tf.MHA layer is (by default) guaranteed to be <code>embed_dim</code>. So there is a final dense layer with <code>embed_dim</code> nodes to ensure the dimension?</li>
</ol>
| [
{
"answer_id": 74430271,
"author": "V.M",
"author_id": 8143158,
"author_profile": "https://Stackoverflow.com/users/8143158",
"pm_score": 3,
"selected": true,
"text": "layer = tf.keras.layers.MultiHeadAttention(num_heads = 2, key_dim = 4, use_bias=False) #Set use_bias=False for simplicity.\nx = tf.keras.Input(shape=[3, 5])\nlayer(x, x)\n"
},
{
"answer_id": 74430622,
"author": "Mohammad Ahmed",
"author_id": 7746219,
"author_profile": "https://Stackoverflow.com/users/7746219",
"pm_score": 1,
"selected": false,
"text": "#Take an arbitrarily input of with embed_size = 512\nx_embed = tf.random.normal((64,100,512))\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2923419/"
] |
74,428,449 | <p>I'm trying to add this feature called booking for others. If the user want to order 5 tour package, user have to input 4 emails of that user friends, to notify them that they got the tour package by this user. The idea i had is to store the emails in array. When i tried to create the front-end i got error <code>count(): Argument #1 ($value) must be of type Countable|array, null given</code>. How can i store the array value??</p>
<p>The Controller :</p>
<pre><code>public function store(Request $request){
$numbers = $request->numbers;
$emails = $request->email;
for($count = 0; $count < count($numbers); $count++){
emails::create([
'email'=>$emails[$count]
]);
}
return redirect ('/home/');
}
</code></pre>
<p>The blade file :</p>
<pre><code><form action="{{route('EmailStore')}}" method="post">
@csrf
<div class="form-group">
<label>How many people</label>
<input type="text" required class="form-control @error ('numbers') is-invalid @enderror"
id="numbers" name="numbers" autocomplete="off">
</div>
@php
$emails = count($numbers);
@endphp
@for ($i = 0; $i < $emails; $i++)
<tr>
<td>
<label>Email.{{$i}}</label>
<input type="text" required class="form-control @error ('email') is-invalid @enderror"
id="email" name="email[]" autocomplete="off">
</td>
</tr>
@endfor
<button type="submit" class="btn btn-info" id="btn_submit"
style="background-color: #eefa69; border:none; color:black">Submit</button>
</form>
</code></pre>
<p>For example input is like this :
<code>How many book : 5</code></p>
<pre><code>Email number 1 : a@gmail.com
Email number 2 : b@gmail.com
Email number 3: c@gmail.com
Email number 4: d@gmail.com
</code></pre>
| [
{
"answer_id": 74430271,
"author": "V.M",
"author_id": 8143158,
"author_profile": "https://Stackoverflow.com/users/8143158",
"pm_score": 3,
"selected": true,
"text": "layer = tf.keras.layers.MultiHeadAttention(num_heads = 2, key_dim = 4, use_bias=False) #Set use_bias=False for simplicity.\nx = tf.keras.Input(shape=[3, 5])\nlayer(x, x)\n"
},
{
"answer_id": 74430622,
"author": "Mohammad Ahmed",
"author_id": 7746219,
"author_profile": "https://Stackoverflow.com/users/7746219",
"pm_score": 1,
"selected": false,
"text": "#Take an arbitrarily input of with embed_size = 512\nx_embed = tf.random.normal((64,100,512))\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18460864/"
] |
74,428,459 | <p>I’m creating demonstration code for a presentation.</p>
<pre><code>var fruitList = ["apple", "banana", "cherry", "durian", "elderberry", "fig", "grape", "huckleberry", "incaberry", "juniper", "kapok", "lime", "mango", "nectarine", "olive", "plum", "quince", "rambutan", "strawberry", "tangerine", "ugli", "vanilla", "watermelon", "xigua", "yarrow", "zhe"];
for (var i = 0; i < fruitList.length; i++) {
if (fruitList[i].charAt(fruitList[i].length-1) == "y") {
fruitList.splice(i, 1);
}
}
console.log(fruitList);
</code></pre>
<p>This code is working almost perfectly, but there’s one strange problem: the incaberry. No matter how many times I rename it, or put another element before or after it, it never gets removed from the list.</p>
<p>I tried to introduce new elements to the list, hoping to discover it was some strange problem with indexing, but it still stayed in the list.</p>
<p>Through experimentation, I learned that for any set of consecutive elements ending in y, only the first will be removed. How do I fix this?</p>
| [
{
"answer_id": 74430271,
"author": "V.M",
"author_id": 8143158,
"author_profile": "https://Stackoverflow.com/users/8143158",
"pm_score": 3,
"selected": true,
"text": "layer = tf.keras.layers.MultiHeadAttention(num_heads = 2, key_dim = 4, use_bias=False) #Set use_bias=False for simplicity.\nx = tf.keras.Input(shape=[3, 5])\nlayer(x, x)\n"
},
{
"answer_id": 74430622,
"author": "Mohammad Ahmed",
"author_id": 7746219,
"author_profile": "https://Stackoverflow.com/users/7746219",
"pm_score": 1,
"selected": false,
"text": "#Take an arbitrarily input of with embed_size = 512\nx_embed = tf.random.normal((64,100,512))\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498405/"
] |
74,428,469 | <p>Hi currently in making new model I have some memory struggling.
I am doing summation between outputs of previous layers.
But it takes so much computation because it keeps allocating new memories I think.</p>
<p>print(max2.shape) = (None,8,8,96)</p>
<pre><code>...
c6 = layers.DepthwiseConv2D(kernel_size = (3,3), depth_multiplier = 1, padding = 'same', activation = 'relu')(max2)
c7 = layers.DepthwiseConv2D(kernel_size = (3,3), depth_multiplier = 1, padding = 'same', activation = 'relu')(max2)
# Concat All the Depthwised outputs
layer3_output_list = [c0,c1,c2,c3,c4,c5,c6,c7]
layer3 = layers.Concatenate(axis = -1)(layer3_output_list)
# Add R's G's B's
add_list = []
for i in range(layer3.shape[3]):
if i%6 == 0:
x = layers.Add()([layer3[:, :, :, i:i+1],layer3[:, :, :, i+3:i+4]])
y = layers.Add()([layer3[:, :, :, i+1:i+2],layer3[:, :, :, i+4:i+5]])
z = layers.Add()([layer3[:, :, :, i+2:i+3],layer3[:, :, :, i+5:i+6]])
add_list.append(x)
add_list.append(y)
add_list.append(z)
layer3 = layers.Concatenate(axis = -1)(add_list)
</code></pre>
<p>print(layer3.shape) = (None,8,8,768)</p>
<pre><code>max3 = layers.MaxPooling2D(pool_size = (2,2))(layer3)
flatten = layers.Flatten()(max3)
</code></pre>
<p>is there any way to make this use less memory?
Do I have to make customized Layer for this?</p>
<p><strong>In Addition</strong>
To explain about the for loops, with the result of layer3, I want to do sum between certain outcome "(ADD([layer3, layer3])" and add there Channels</p>
<p><strong>Currently</strong>
I'm doing summation between (ith, i+3th) and (i+1th, i+4th) and (i+2th, i+5th) but I think I will change how i do summation later on</p>
<p><a href="https://i.stack.imgur.com/nmMhm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmMhm.png" alt="my model" /></a></p>
| [
{
"answer_id": 74430271,
"author": "V.M",
"author_id": 8143158,
"author_profile": "https://Stackoverflow.com/users/8143158",
"pm_score": 3,
"selected": true,
"text": "layer = tf.keras.layers.MultiHeadAttention(num_heads = 2, key_dim = 4, use_bias=False) #Set use_bias=False for simplicity.\nx = tf.keras.Input(shape=[3, 5])\nlayer(x, x)\n"
},
{
"answer_id": 74430622,
"author": "Mohammad Ahmed",
"author_id": 7746219,
"author_profile": "https://Stackoverflow.com/users/7746219",
"pm_score": 1,
"selected": false,
"text": "#Take an arbitrarily input of with embed_size = 512\nx_embed = tf.random.normal((64,100,512))\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10535529/"
] |
74,428,472 | <p>I am trying to make a post request in React to the server</p>
<p>my React app is running at port 3000 & express app is running at port 9000</p>
<p>React:</p>
<pre><code> axios.post("/").then((response)=>{
console.log(response.data)
}).catch((e)=>{
console.log(e.response.data)
this.out = e.response.data
})
</code></pre>
<p>Express:</p>
<pre><code>
app.post("/", (req, res) => {
console.clear()
console.log(req.body)
res.end("req")
})
</code></pre>
<p>on the web console it says :
"Failed to load resource: the server responded with a status of 404 (Not Found)"</p>
<p>on the app 'postman' It runs just fine</p>
<p>I tried to follow this YT tutorial <a href="https://www.youtube.com/watch?v=kJA9rDX7azM" rel="nofollow noreferrer">https://www.youtube.com/watch?v=kJA9rDX7azM</a></p>
| [
{
"answer_id": 74430271,
"author": "V.M",
"author_id": 8143158,
"author_profile": "https://Stackoverflow.com/users/8143158",
"pm_score": 3,
"selected": true,
"text": "layer = tf.keras.layers.MultiHeadAttention(num_heads = 2, key_dim = 4, use_bias=False) #Set use_bias=False for simplicity.\nx = tf.keras.Input(shape=[3, 5])\nlayer(x, x)\n"
},
{
"answer_id": 74430622,
"author": "Mohammad Ahmed",
"author_id": 7746219,
"author_profile": "https://Stackoverflow.com/users/7746219",
"pm_score": 1,
"selected": false,
"text": "#Take an arbitrarily input of with embed_size = 512\nx_embed = tf.random.normal((64,100,512))\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20312274/"
] |
74,428,475 | <p>I'm working with <code>Vue 3</code> and <code>Bootstrap 5</code>.</p>
<p>I have a <code>button</code> and two <code>inputs</code>. When I click the <code>button</code> I want to have a <code>"milky" overlay</code> like following:</p>
<p><a href="https://i.stack.imgur.com/K21k8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K21k8.png" alt="enter image description here" /></a></p>
<p>How can I achieve this?</p>
<p>Code to work with:</p>
<pre><code><template>
<div class="row">
<button class="btn btn-dark" @click="overlayMilky()">Button</button>
</div>
<div class="row mt-2">
<div class="col-12">
<span>Input 2</span>
<input class="form-control" />
</div>
<div class="col-12">
<span>Input 3</span>
<input class="form-control" />
</div>
</div>
</template>
<script>
export default {
methods: {
overlayMilky() {
//set overlay to milky
}
}
}
</script>
</code></pre>
| [
{
"answer_id": 74428557,
"author": "Evgeni Dikerman",
"author_id": 1761692,
"author_profile": "https://Stackoverflow.com/users/1761692",
"pm_score": 0,
"selected": false,
"text": "data"
},
{
"answer_id": 74428598,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": 3,
"selected": true,
"text": "container"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16365685/"
] |
74,428,545 | <p>I'm writing my own <code>UICollectionViewLayout</code> subclass to have full control over the layout and arrangement of my collection view cells. When computing the item sizes, I want the layout to start with the cells' fitting sizes, i.e. I want the cells to size themselves to fit their content initially and then modify their frames later based on that information.</p>
<p>To get the fitting sizes, I first ask the collection view's data source for all cells in the layout's <code>prepare()</code> method and layout all the cells using <code>systemLayoutSizeFitting(_:)</code>.</p>
<pre><code>let allCells = allIndedxPaths.compactMap {
collectionView.dataSource?.collectionView(collectionView, cellForItemAt: $0)
}
let allItemSizes = allCells.map { cell in
cell.systemLayoutSizeFitting(.init(width: contentSize.width, height: UIView.noIntrinsicMetric))
}
</code></pre>
<p>Visually, everything works as expected and I get exactly the result I want. However, every time the collection view is laid out, the following warning it printed to the console:</p>
<blockquote>
<p>[CollectionView] An attempt to prepare a layout while a prepareLayout call was already in progress (i.e. reentrant call) has been ignored. Please file a bug.</p>
</blockquote>
<p>So it appears to me that it is prohibited to call any data source method while the layout is being prepared.</p>
<p>Which brings me to my question:</p>
<h4>How can I obtain information from the data source that I need to compute the layout from within my <code>UICollectionViewLayout</code> subclass?</h4>
<p>(Or more specifically: How can I get the concrete cell sizes right before I compute the layout?)</p>
<hr />
<h3>Notes:</h3>
<ol>
<li><p>Since Apple's own <code>UICollectionViewFlowLayout</code> works with automatic cells sizes (<code>estimatedItemSize</code>), there must be a clean way to get this information.</p>
</li>
<li><p>Apple's <em><a href="https://developer.apple.com/library/archive/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/CreatingCustomLayouts/CreatingCustomLayouts.html#//apple_ref/doc/uid/TP40012334-CH5-SW4" rel="nofollow noreferrer">Collection View Programming Guide</a></em> states:</p>
<blockquote>
<p>In a limited number of cases, the layout object might rely on information in the data source to position items. For example, a layout that displays items on a map might retrieve the map location of each item from the data source.</p>
</blockquote>
<p>This also means that there must be a way to query the data source from the layout object.</p>
</li>
</ol>
<hr />
<h3>Supplemental: Minimal Code Example</h3>
<p>Below is a (not so) minimal code for the layout that I'm trying to achieve.</p>
<pre><code>class SelfSizingTagListLayout: UICollectionViewLayout {
private var contentSize: CGSize = .zero
private var frames: [IndexPath: CGRect] = [:]
private var cachedAttributes: [IndexPath: UICollectionViewLayoutAttributes] = [:]
let interItemSpacing: CGFloat = 8
override func prepare() {
guard let collectionView else {
return
}
contentSize = .init(width: collectionView.bounds.width, height: 0)
let itemCount = collectionView.numberOfItems(inSection: 0)
let allIndedxPaths = (0..<itemCount).map { IndexPath(item: $0, section: 0) }
let allCells = allIndedxPaths.compactMap {
collectionView.dataSource?.collectionView(collectionView, cellForItemAt: $0)
}
let allItemSizes = allCells.map { cell in
cell.systemLayoutSizeFitting(.init(width: contentSize.width, height: UIView.noIntrinsicMetric))
}
frames = computeFrames(for: allItemSizes)
cachedAttributes = [:]
for frame in frames {
let attributes = UICollectionViewLayoutAttributes(forCellWith: frame.key)
attributes.frame = frame.value
cachedAttributes[frame.key] = attributes
}
contentSize.height = frames.map(\.value.maxY).max() ?? 0
}
private func computeFrames(for itemSizes: [CGSize]) -> [IndexPath: CGRect] {
let contentWidth = collectionView!.bounds.width
let rowHeight = itemSizes.map(\.height).max() ?? 0
var row: Int = 0
var x: CGFloat = 0
var y: CGFloat {
CGFloat(row) * (rowHeight + interItemSpacing)
}
var item: Int = 0
var frames: [IndexPath: CGRect] = [:]
for itemSize in itemSizes {
if x + itemSize.width > contentWidth {
row += 1
x = 0
}
let frame = CGRect(origin: .init(x: x, y: y), size: itemSize)
frames[IndexPath(item: item, section: 0)] = frame
item += 1
x += itemSize.width + interItemSpacing
}
return frames
}
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
cachedAttributes.map(\.value)
}
override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
cachedAttributes[indexPath]
}
override var collectionViewContentSize: CGSize {
contentSize
}
}
</code></pre>
| [
{
"answer_id": 74463471,
"author": "DonMag",
"author_id": 6257435,
"author_profile": "https://Stackoverflow.com/users/6257435",
"pm_score": 1,
"selected": false,
"text": "cellForItemAt"
},
{
"answer_id": 74488992,
"author": "Mischa",
"author_id": 2062785,
"author_profile": "https://Stackoverflow.com/users/2062785",
"pm_score": 0,
"selected": false,
"text": "cellForItemAt"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2062785/"
] |
74,428,563 | <p>I have a <code>Text</code> tag in <code>expo/react-native</code> which i use on a screen to show live time using JavaScript <code>new Date()</code> object. Its giving me 24 hour format even when i set <code>"en-US"</code> and <code>hour12: true</code> i have tried everything but it doesn't seem to work.</p>
<p>Here is my code:</p>
<pre><code>const [liveTime, setLiveTime] = useState(new Date())
const refreshLiveTime = () => {
setLiveTime(new Date())
}
useEffect(() => {
const timerId = setInterval(refreshLiveTime, 1000)
return function cleanup() {
clearInterval(timerId)
}
}, [])
</code></pre>
<p>And here is how i render it in <code>Text</code> tag:</p>
<pre><code><Text>{liveTime.toLocaleTimeString("en-US", {hour12: true})}</Text>
</code></pre>
<p>Sample Expected output:</p>
<pre><code>01:12:18
</code></pre>
<p>Output i am receiving:</p>
<pre><code>13:12:18
</code></pre>
<p><strong>EDIT:</strong></p>
<p>I tried the same code in <code>reactjs</code> and it works fine there, i think the problem is with <code>react-native</code> here, maybe react-native doesn't support <code>toLocaleTimeString()</code></p>
| [
{
"answer_id": 74428935,
"author": "Vu Phung",
"author_id": 12040727,
"author_profile": "https://Stackoverflow.com/users/12040727",
"pm_score": 0,
"selected": false,
"text": "import moment from 'moment';\n\nconst time = new Date();\nconsole.log(moment(time).format(\"hh:mm:ss\"));\n// if you want display by 24h, change hh:mm:ss to HH:mm:ss\n"
},
{
"answer_id": 74431475,
"author": "Fiston Emmanuel",
"author_id": 12431576,
"author_profile": "https://Stackoverflow.com/users/12431576",
"pm_score": 1,
"selected": false,
"text": "android/app/build.gradle"
},
{
"answer_id": 74431782,
"author": "Nasyx Nadeem",
"author_id": 9663776,
"author_profile": "https://Stackoverflow.com/users/9663776",
"pm_score": 0,
"selected": false,
"text": "moment"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9663776/"
] |
74,428,567 | <pre><code>
import pandas as pd
data1 = [['xx'], ['4']]
data2 = [['4', 'x0'], ['aa', 'bb'], ['cc', 'dd']]
df1 = pd.DataFrame(data=data1, columns=["isin"])
print(df1)
df2 = pd.DataFrame(data=data2, columns=["isin", "data"])
print(df2)
df1.loc[df1['isin'] == df2['isin'], 'data'] = df2['data']
print (df1)
# Exception has occurred: ValueError
# Can only compare identically-labeled Series objects
# df1.loc[df1['isin'] == df2['isin'], 'data'] = df2['data']
# THIS IS IT NOW
# df1:
# isin
# 0 xx
# 1 4
# df2:
# isin data
# 0 4 x0
# 1 aa bb
# 2 cc dd
</code></pre>
<p>Problem:</p>
<ol>
<li>algorithm find the row with the '4' - in column 'isin' in both df</li>
<li>pull from df2 the 'data' at this row (in this case 'x0')</li>
<li>add it to df1 - in this case(x0) - at the row of '4' at new column 'data'</li>
</ol>
<pre><code># df1:
# isin
# 0 xx
# 1 4
# df2:
# isin data
# 0 4 x0
# 1 aa bb
# 2 cc dd
# df3:
# isin data
# 0 xx NaN
# 1 4 x0
</code></pre>
| [
{
"answer_id": 74428935,
"author": "Vu Phung",
"author_id": 12040727,
"author_profile": "https://Stackoverflow.com/users/12040727",
"pm_score": 0,
"selected": false,
"text": "import moment from 'moment';\n\nconst time = new Date();\nconsole.log(moment(time).format(\"hh:mm:ss\"));\n// if you want display by 24h, change hh:mm:ss to HH:mm:ss\n"
},
{
"answer_id": 74431475,
"author": "Fiston Emmanuel",
"author_id": 12431576,
"author_profile": "https://Stackoverflow.com/users/12431576",
"pm_score": 1,
"selected": false,
"text": "android/app/build.gradle"
},
{
"answer_id": 74431782,
"author": "Nasyx Nadeem",
"author_id": 9663776,
"author_profile": "https://Stackoverflow.com/users/9663776",
"pm_score": 0,
"selected": false,
"text": "moment"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20214082/"
] |
74,428,670 | <p><strong>Approach #1:</strong> Recursion</p>
<pre><code>// Recursion
suspend fun findAndHandleFile(fileName: String, timeoutMs: Long, startTiming: Long, intervalMs: Long = 3000) {
val file = findWithFileName(fileName)
if (file != null) {
handleFile(file)
} else {
val passedTime = System.currentTimeMillis() - startTiming
if (passedTime < timeoutMs) {
delay(internalMs)
findAndHandleFile(fileName, timeoutMs, startTiming)
}
}
}
</code></pre>
<p><strong>Approach #2:</strong></p>
<pre><code>suspend fun findAndHandleFile(fileName: String, timeoutMs: Long, startTiming: Long, intervalMs: Long = 3000) {
val file = findFile(fileName, timeoutMs, startTiming, 3000)
if (file != null) {
handleFile(file)
}
}
</code></pre>
<pre><code>suspend fun findFile(fileName: String, timeoutMs: Long, startTiming: Long, intervalMs: Long = 3000): File? {
var file = findWithFileName(fileName)
while(file == null && System.currentTimeMillis() < startTiming + timeoutMs) {
delay(intervalMs)
file = findWithFileName(fileName)
}
}
</code></pre>
<p>Currently, I use Approach #1 and still not see any problem with it (don't cause StackOverflowError)</p>
<ul>
<li>It works well during an hour</li>
</ul>
<p>I want to refactor from Approach #1 to Approach #2, but still not clearly sure what it is benefit from it.</p>
<p>My question for above approaches when running it on Android app:</p>
<ul>
<li>is Approach #2 more effective than Approach #1? what are they?</li>
</ul>
<p>Hope receiving sharing from people. Thanks</p>
| [
{
"answer_id": 74429114,
"author": "Dan Baruch",
"author_id": 8688810,
"author_profile": "https://Stackoverflow.com/users/8688810",
"pm_score": 0,
"selected": false,
"text": "int total=1;\nfor(int i=1; i<num;i++)\n total*=i;\n"
},
{
"answer_id": 74433214,
"author": "Tenfour04",
"author_id": 506796,
"author_profile": "https://Stackoverflow.com/users/506796",
"pm_score": 2,
"selected": true,
"text": "tailrec"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17278086/"
] |
74,428,674 | <p>I am still pretty new to iOS development. I have a (very?) large view that is causing a memory error. My <code>body</code> var looks something like this:</p>
<pre><code>var body: some View {
ZStack {
Color(...)
Rectangle()
ScrollView {
VStack {
ZStack {
RoundedRectangle(...)
RoundedRectangle(...)
VStack {
ZStack{
Circle()
Circle()
Circle()
Image(...)
}.overlay(
HStack {
// more stuff
}
)
}
// many more views
}
}
}
}
}
</code></pre>
<p>I added and removed views to confirm it was a problem related to having too many views. At some point, when I add another view, I get this (or similar) memory error:</p>
<p><code>Thread 1: EXC_BAD_ACCESS (code=2, address=0x16cd27fc8)</code></p>
<p>The address seems to be different each time but always starts with 0x16, which leads me to believe it's a stack overflow... I found <a href="https://stackoverflow.com/questions/61793803/stack-overflow-thread-1-exc-bad-access-code-2-address-0x16d09aa00">this answer/question</a> where they have a very similar problem and were able to solve it by moving large structs to the heap. I am not certain how exactly to accomplish this, even after looking at the example provided in the answer.</p>
<p>My main thought is that there must be a better way to organize my body in the first place that I am just missing. Is using the heap really necessary for rendering a view with a lot of children? Any help or advice is appreciated.</p>
| [
{
"answer_id": 74430111,
"author": "Iftikhar Hussain Orakzai",
"author_id": 14151662,
"author_profile": "https://Stackoverflow.com/users/14151662",
"pm_score": 0,
"selected": false,
"text": "var body: some View {\n ZStack {\n Color(...) \n Rectangle()\n ScrollView {\n//Vstack load the whole content at a time while LazyVstack load as its needed \n LazyVStack{ \n ZStack {\n RoundedRectangle(...)\n RoundedRectangle(...)\n \n VStack {\n ZStack{\n Circle() \n Circle()\n Circle()\n Image(...)\n \n }.overlay(\n HStack {\n // more stuff\n }\n ) \n }\n\n // many more views\n }\n }\n }\n }\n}\n"
},
{
"answer_id": 74432405,
"author": "malhal",
"author_id": 259521,
"author_profile": "https://Stackoverflow.com/users/259521",
"pm_score": 2,
"selected": true,
"text": "body"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19224040/"
] |
74,428,712 | <p>I am getting an array like below after doing the matches.
[ '10 am', '5 pm', 'by appointment only' ]
I would like to append text <strong>to</strong> only for time and return in this format.</p>
<p>"10 am to 5 pm by appointment only"</p>
<p>But when I join like below</p>
<pre><code>[ '10 am', '5 pm', 'by appointment only' ].join( 'to' );
</code></pre>
<p>I am getting result as</p>
<blockquote>
<p>"10 am to 5 pm to by appointment only"</p>
</blockquote>
<p>So with the help of regular expression is there a way to to remove <strong>'to'</strong> only from 3rd element of array so that when joining it won't append <strong>'to '</strong> again.</p>
| [
{
"answer_id": 74428770,
"author": "ryuhojin",
"author_id": 20496118,
"author_profile": "https://Stackoverflow.com/users/20496118",
"pm_score": 2,
"selected": false,
"text": "const [start,end,describe] = [ '10 am', '5 pm', 'by appointment only' ];\nconst finalText = `${start} to ${end} ${describe}`;\nconsole.log(finalText)\n"
},
{
"answer_id": 74428815,
"author": "Yosvel Quintero",
"author_id": 1932552,
"author_profile": "https://Stackoverflow.com/users/1932552",
"pm_score": 0,
"selected": false,
"text": "const arr1 = ['10 am', '5 pm', 'by appointment only']\nconst arr2 = ['By Appointment:', '10 am', '5 pm']\nconst getFormattedAppoiment = arr => {\n const { appointment, startEnd } = arr.reduce(\n (a, c, i) => {\n if (/\\d/.test(c)) {\n a.startEnd.push(c)\n } else {\n a.appointment.text = c\n a.appointment.position = i\n }\n return a\n },\n {\n startEnd: [], \n appointment: { \n text: '',\n position: 0,\n },\n }\n )\n const startEndText = startEnd.join(' to ')\n\n return appointment.position === 0\n ? `${appointment.text} ${startEndText}`\n : `${startEndText} ${appointment.text}`\n}\n\nconsole.log(getFormattedAppoiment(arr1))\nconsole.log(getFormattedAppoiment(arr2))"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/662503/"
] |
74,428,716 | <p>I am new to Pandas and thus I wanted to know if I can convert my text file with a particular format into a Pandas data frame. Below is my text file format</p>
<pre><code>"FACT"|"FSYM"|"POSITION"|"INDIRECT_OPTIONS"|"REPORT"|"SOURCE"|"COMMENTS"|
"ABCX"|"VVG1"|2800000|760000|2022-11-03|"A"|"INCLUDES CAR"|0
</code></pre>
<p>I wanted to convert this format in Pandas with same columns and values as separated by | sign. That is my data frame columns will be FACT, FYSM,POSITION, and so on.</p>
<p>I am trying below code but it does not give me the desired output.</p>
<pre><code>def convert_factset_file_to_dataframe(test_case_name, file_name):
data = pd.read_csv("{}/output/Float_Ingestion_files/{}/{}.txt".format(str(parentDir), test_case_name, file_name), sep=',')
print(data)
</code></pre>
<p>It is printing as follows. Just adding the index.</p>
<pre><code> "FACT"|"FSYM"|"POSITION"|"INDIRECT_OPTIONS"|"REPORT"|"SOURCE"|"COMMENTS"|
0 "ABCX"|"VVG1"|2800000|760000|2022-11-03|"A"|"INCLUDES CAR"|0
</code></pre>
<p>Is there any other way of converting my text file format to a data frame besides reading it as a CSV? Or I need to incorporate some changes in the code?</p>
| [
{
"answer_id": 74428770,
"author": "ryuhojin",
"author_id": 20496118,
"author_profile": "https://Stackoverflow.com/users/20496118",
"pm_score": 2,
"selected": false,
"text": "const [start,end,describe] = [ '10 am', '5 pm', 'by appointment only' ];\nconst finalText = `${start} to ${end} ${describe}`;\nconsole.log(finalText)\n"
},
{
"answer_id": 74428815,
"author": "Yosvel Quintero",
"author_id": 1932552,
"author_profile": "https://Stackoverflow.com/users/1932552",
"pm_score": 0,
"selected": false,
"text": "const arr1 = ['10 am', '5 pm', 'by appointment only']\nconst arr2 = ['By Appointment:', '10 am', '5 pm']\nconst getFormattedAppoiment = arr => {\n const { appointment, startEnd } = arr.reduce(\n (a, c, i) => {\n if (/\\d/.test(c)) {\n a.startEnd.push(c)\n } else {\n a.appointment.text = c\n a.appointment.position = i\n }\n return a\n },\n {\n startEnd: [], \n appointment: { \n text: '',\n position: 0,\n },\n }\n )\n const startEndText = startEnd.join(' to ')\n\n return appointment.position === 0\n ? `${appointment.text} ${startEndText}`\n : `${startEndText} ${appointment.text}`\n}\n\nconsole.log(getFormattedAppoiment(arr1))\nconsole.log(getFormattedAppoiment(arr2))"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20262433/"
] |
74,428,724 | <p>There is a task, to write calculator, which recieves strings cosisting of:</p>
<ul>
<li>chars '0'-'9',</li>
<li>brackest '(', ')',</li>
<li>chars '+', '-', '*', '/', '^',</li>
</ul>
<p>and performing following ops:</p>
<ul>
<li>addition</li>
<li>substraction</li>
<li>multiplication</li>
<li>integer division</li>
<li>power.</li>
</ul>
<p>Arcitecture of solution should include recursive descent</p>
<p>My code:</p>
<pre><code>#include <stdio.h>
#include <setjmp.h>
jmp_buf begin;
char curlex;
void getlex(void);
int expr(void);
int add_sub(void);
int mult_div(void);
int power(void);
void error();
int main() {
int result;
setjmp(begin);
printf("==>");
getlex();
result=expr();
if ( curlex != '\n') error();
printf("\n%d\n",result);
return 0;
}
void getlex() {
while ( ( curlex=getchar()) == ' ');
}
void error(void) {
printf("\nERROR!\n");
while(getchar()!='\n');
longjmp(begin,1);
}
int expr() {
int e=add_sub();
while (curlex == '+' || curlex == '-')
if (curlex == '+')
{getlex(); e+=add_sub();}
else if (curlex == '-')
{getlex(); e-=add_sub();}
return e;
}
int add_sub() {
int a=mult_div();
while (curlex == '*' || curlex == '/')
if (curlex == '*')
{getlex(); a*=mult_div();}
else if (curlex == '/')
{getlex(); a/=mult_div();}
return a;
}
int mult_div() {
int a=power();
while (curlex == '^')
{getlex(); for(int k=0;k<power(); k++, a*=power());}
return a;
}
int power() {
int m;
switch(curlex){
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': m= curlex-'0'; break;
case '(': getlex(); m=expr();
if ( curlex == ')') break;
default : error();
}
getlex();
return m;
}
</code></pre>
<p>Code performs almost everything mentioned, except power-operation. I can't find a bug. There is also an issue with right association of power operation. That means expression 3^1^2 gives 9, but should give 3.</p>
<p>Please help!</p>
| [
{
"answer_id": 74428894,
"author": "mch",
"author_id": 3684343,
"author_profile": "https://Stackoverflow.com/users/3684343",
"pm_score": 1,
"selected": false,
"text": "power()"
},
{
"answer_id": 74459859,
"author": "Stepan Sokol",
"author_id": 9801880,
"author_profile": "https://Stackoverflow.com/users/9801880",
"pm_score": 1,
"selected": true,
"text": "#include <stdio.h>\n#include <setjmp.h>\n\njmp_buf begin;\nchar curlex;\n\nvoid getlex(void); \nint expr(void); \nint add_sub(void); \nint mult_div(void); \nint power(void);\nvoid error(); \n\nint main() {\n int result; \n setjmp(begin); \n printf(\"==>\"); \n getlex(); \n result=expr(); \n if ( curlex != '\\n') error(); \n printf(\"\\n%d\\n\",result);\n return 0;\n}\n\nvoid getlex() {\nwhile ( ( curlex=getchar()) == ' '); \n}\n\n\nvoid error(void) {\n printf(\"\\nОШИБКА!\\n\");\n while(getchar()!='\\n');\n longjmp(begin,1);\n}\n\n\nint expr() {\n int e=add_sub(); \n while (curlex == '+' || curlex == '-') \n if (curlex == '+')\n {getlex(); e+=add_sub();} \n else if (curlex == '-')\n {getlex(); e-=add_sub();} \n return e;\n}\n\nint add_sub() {\n while (curlex == '*' || curlex == '/') \n if (curlex == '*')\n {getlex(); a*=mult_div();} \n else if (curlex == '/')\n {getlex(); a/=mult_div();} \n return a;\n}\n\n\nint mult_div() {\n\n int a=power(), res=1;\n while (curlex == '^') \n {getlex(); \n int m=mult_div();\n for(int k=0 ;k<m; k++, res*=a); \n return res;} \n return a;\n}\n\nint power() {\n int m; \n\n switch(curlex){ \n case '0': \n case '1': \n case '2': \n case '3': \n case '4': \n case '5':\n case '6': \n case '7': \n case '8': \n case '9': m= curlex-'0'; break;\n case '(': getlex(); m=expr(); \n if ( curlex == ')') break; \n default : error();\n }\n \ngetlex();\nreturn m;\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9801880/"
] |
74,428,727 | <p>I have a game in which the character can only move horizontally and vertically, not diagonally.</p>
<p>I have tried to implement this with this code, which should check if the player is pressing down/up or left/right:</p>
<pre class="lang-cs prettyprint-override"><code>if (Input.GetKey("down"))
{
moveHor = false;
moveVer = true;
if(moveVer == true)
{
transform.Translate(Vector3.down * Time.deltaTime * speed);
}
}
if (Input.GetKey("up"))
{
moveHor = false;
moveVer = true;
if (moveVer == true)
{
transform.Translate(Vector3.up * Time.deltaTime * speed);
}
}
if (Input.GetKey("right"))
{
moveVer = false;
moveHor = true;
if(moveHor == true)
{
transform.Translate(Vector3.right * Time.deltaTime * speed);
}
}
if (Input.GetKey("left"))
{
moveVer = false;
moveHor = true;
if (moveHor == true)
{
transform.Translate(Vector3.left * Time.deltaTime * speed);
}
}
</code></pre>
<p>This code is ran in the Update() method.</p>
<p>The thing is, it's not working and I can't figure out why.</p>
<p>I hope someone knows what to do.</p>
| [
{
"answer_id": 74428894,
"author": "mch",
"author_id": 3684343,
"author_profile": "https://Stackoverflow.com/users/3684343",
"pm_score": 1,
"selected": false,
"text": "power()"
},
{
"answer_id": 74459859,
"author": "Stepan Sokol",
"author_id": 9801880,
"author_profile": "https://Stackoverflow.com/users/9801880",
"pm_score": 1,
"selected": true,
"text": "#include <stdio.h>\n#include <setjmp.h>\n\njmp_buf begin;\nchar curlex;\n\nvoid getlex(void); \nint expr(void); \nint add_sub(void); \nint mult_div(void); \nint power(void);\nvoid error(); \n\nint main() {\n int result; \n setjmp(begin); \n printf(\"==>\"); \n getlex(); \n result=expr(); \n if ( curlex != '\\n') error(); \n printf(\"\\n%d\\n\",result);\n return 0;\n}\n\nvoid getlex() {\nwhile ( ( curlex=getchar()) == ' '); \n}\n\n\nvoid error(void) {\n printf(\"\\nОШИБКА!\\n\");\n while(getchar()!='\\n');\n longjmp(begin,1);\n}\n\n\nint expr() {\n int e=add_sub(); \n while (curlex == '+' || curlex == '-') \n if (curlex == '+')\n {getlex(); e+=add_sub();} \n else if (curlex == '-')\n {getlex(); e-=add_sub();} \n return e;\n}\n\nint add_sub() {\n while (curlex == '*' || curlex == '/') \n if (curlex == '*')\n {getlex(); a*=mult_div();} \n else if (curlex == '/')\n {getlex(); a/=mult_div();} \n return a;\n}\n\n\nint mult_div() {\n\n int a=power(), res=1;\n while (curlex == '^') \n {getlex(); \n int m=mult_div();\n for(int k=0 ;k<m; k++, res*=a); \n return res;} \n return a;\n}\n\nint power() {\n int m; \n\n switch(curlex){ \n case '0': \n case '1': \n case '2': \n case '3': \n case '4': \n case '5':\n case '6': \n case '7': \n case '8': \n case '9': m= curlex-'0'; break;\n case '(': getlex(); m=expr(); \n if ( curlex == ')') break; \n default : error();\n }\n \ngetlex();\nreturn m;\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19828325/"
] |
74,428,733 | <p>Need to move data from one dynamodb table to another table after doing a transformation</p>
<p>What is the best approach to do that</p>
<p>Do I need to write a script to read selective data from one table and put in another table</p>
<p>or Do I need to follow CSV export</p>
| [
{
"answer_id": 74428894,
"author": "mch",
"author_id": 3684343,
"author_profile": "https://Stackoverflow.com/users/3684343",
"pm_score": 1,
"selected": false,
"text": "power()"
},
{
"answer_id": 74459859,
"author": "Stepan Sokol",
"author_id": 9801880,
"author_profile": "https://Stackoverflow.com/users/9801880",
"pm_score": 1,
"selected": true,
"text": "#include <stdio.h>\n#include <setjmp.h>\n\njmp_buf begin;\nchar curlex;\n\nvoid getlex(void); \nint expr(void); \nint add_sub(void); \nint mult_div(void); \nint power(void);\nvoid error(); \n\nint main() {\n int result; \n setjmp(begin); \n printf(\"==>\"); \n getlex(); \n result=expr(); \n if ( curlex != '\\n') error(); \n printf(\"\\n%d\\n\",result);\n return 0;\n}\n\nvoid getlex() {\nwhile ( ( curlex=getchar()) == ' '); \n}\n\n\nvoid error(void) {\n printf(\"\\nОШИБКА!\\n\");\n while(getchar()!='\\n');\n longjmp(begin,1);\n}\n\n\nint expr() {\n int e=add_sub(); \n while (curlex == '+' || curlex == '-') \n if (curlex == '+')\n {getlex(); e+=add_sub();} \n else if (curlex == '-')\n {getlex(); e-=add_sub();} \n return e;\n}\n\nint add_sub() {\n while (curlex == '*' || curlex == '/') \n if (curlex == '*')\n {getlex(); a*=mult_div();} \n else if (curlex == '/')\n {getlex(); a/=mult_div();} \n return a;\n}\n\n\nint mult_div() {\n\n int a=power(), res=1;\n while (curlex == '^') \n {getlex(); \n int m=mult_div();\n for(int k=0 ;k<m; k++, res*=a); \n return res;} \n return a;\n}\n\nint power() {\n int m; \n\n switch(curlex){ \n case '0': \n case '1': \n case '2': \n case '3': \n case '4': \n case '5':\n case '6': \n case '7': \n case '8': \n case '9': m= curlex-'0'; break;\n case '(': getlex(); m=expr(); \n if ( curlex == ')') break; \n default : error();\n }\n \ngetlex();\nreturn m;\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5679225/"
] |
74,428,760 | <p>Hi I am getting an error that says "each child in a list should have a unique "key" prop. When I check the Components using React Developer Tools I don't see any duplicates - what am I doing wrong?</p>
<pre><code> return (
<>
<Modal
isOpen={modalIsOpen}
onRequestClose={closeModal}
>
{ modalIsOpen ? (
<Note
key={'ModalNote' + modalNote.id}
id={modalNote.id}
title={modalNote.title}
text={modalNote.text}
date={modalNote.date}
deleteNote={deleteNote}
closeNote={closeModal}
/>
) : ('')
}
</Modal>
<div className="notesForm">
<AddNote addNoteHandler={addNoteHandler}/>
</div>
<div className="notes">
{notes.map((note) => (
<>
<Note
key={note.id}
id={note.id}
title={note.title}
text={note.text}
date={note.date}
deleteNote={deleteNote}
closeNote={closeModal}
openModal={openModal}
modalIsOpen={modalIsOpen}
/>
</>
))}
</div>
</>
);
</code></pre>
| [
{
"answer_id": 74428842,
"author": "Priyen Mehta",
"author_id": 19431815,
"author_profile": "https://Stackoverflow.com/users/19431815",
"pm_score": 2,
"selected": false,
"text": " <div key={note.id}>\n <Note\n key={note.id}\n id={note.id}\n title={note.title}\n text={note.text}\n date={note.date}\n deleteNote={deleteNote}\n closeNote={closeModal}\n openModal={openModal}\n modalIsOpen={modalIsOpen}\n />\n </div>\n"
},
{
"answer_id": 74428864,
"author": "KcH",
"author_id": 11737596,
"author_profile": "https://Stackoverflow.com/users/11737596",
"pm_score": 2,
"selected": true,
"text": "map"
},
{
"answer_id": 74428906,
"author": "Mark Barton",
"author_id": 4357444,
"author_profile": "https://Stackoverflow.com/users/4357444",
"pm_score": 0,
"selected": false,
"text": "<Note\n key={`note-${note.id}`}\n id={note.id}\n title={note.title}\n/>\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4975795/"
] |
74,428,769 | <p>I tried making this navigational bar with click drop-downs which I achieved using a checkbox, however, when I click on the the checkbox, its content drops down like a block element but I want it to sit on-top the image</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.material-symbols-outlined {
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48
}
header {
display: grid;
grid-template-rows: auto 1fr;
}
.drop-down {
grid-row: 1;
width: 100%;
}
label {
cursor: pointer;
background-color: var(--coral);
display: flex;
justify-content: center;
}
[type="checkbox"] {
display: none;
}
header a {
text-decoration: none;
color: white;
display: block;
text-align: center;
width: 100%;
padding: 1rem 0 1rem 0;
}
header a:hover {
background-color: #040628;
}
.content {
display: none;
background-color: var(--blue);
padding: 1rem 0 1rem 0;
z-index: 1000;
}
[type="checkbox"]:checked+.content {
display: block;
}
.puzzles {
width: 100%;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><header>
<div class="drop-down">
<label for="checkbox">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
</label>
<input type="checkbox" id="checkbox" />
<div class="content">
<a href="#">Home</a>
<a href="#">New</a>
<a href="#">Popular</a>
<a href="#">Trending</a>
</div>
</div>
<img src="https://images.unsplash.com/photo-1666609393250-5ddc8fa87fa9?crop=entropy&cs=tinysrgb&fm=jpg&ixid=MnwzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2Njg0MTMxNTc&ixlib=rb-4.0.3&q=80" />
</header></code></pre>
</div>
</div>
</p>
<p>I was expecting the dropdown-content to overlap on the image instead of dropping down</p>
| [
{
"answer_id": 74428842,
"author": "Priyen Mehta",
"author_id": 19431815,
"author_profile": "https://Stackoverflow.com/users/19431815",
"pm_score": 2,
"selected": false,
"text": " <div key={note.id}>\n <Note\n key={note.id}\n id={note.id}\n title={note.title}\n text={note.text}\n date={note.date}\n deleteNote={deleteNote}\n closeNote={closeModal}\n openModal={openModal}\n modalIsOpen={modalIsOpen}\n />\n </div>\n"
},
{
"answer_id": 74428864,
"author": "KcH",
"author_id": 11737596,
"author_profile": "https://Stackoverflow.com/users/11737596",
"pm_score": 2,
"selected": true,
"text": "map"
},
{
"answer_id": 74428906,
"author": "Mark Barton",
"author_id": 4357444,
"author_profile": "https://Stackoverflow.com/users/4357444",
"pm_score": 0,
"selected": false,
"text": "<Note\n key={`note-${note.id}`}\n id={note.id}\n title={note.title}\n/>\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18835651/"
] |
74,428,789 | <p>I have a class that looks like this</p>
<pre><code>class MyCalss
{
public:
std::unordered_map<std::string, std::unique_ptr<Entity>> getMyMap() const;
private:
std::unordered_map<std::string, std::unique_ptr<Entity>> m_myMap;
}
</code></pre>
<p>In the implementation, I simple return m_myMap in getMyMap() like so,</p>
<pre><code>std::unordered_map<std::string, std::unique_ptr<Entity>> MyClass::getMyMap() const
{
return m_myMap;
}
</code></pre>
<p>How come this is not allowed? I get a bunch of compilation error doing this.</p>
| [
{
"answer_id": 74428883,
"author": "Giovanni Cerretani",
"author_id": 3287591,
"author_profile": "https://Stackoverflow.com/users/3287591",
"pm_score": 1,
"selected": false,
"text": "m_myMap"
},
{
"answer_id": 74428914,
"author": "mfnx",
"author_id": 5954825,
"author_profile": "https://Stackoverflow.com/users/5954825",
"pm_score": 0,
"selected": false,
"text": "std::unique_ptr"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1017674/"
] |
74,428,839 | <p>I have a string parameter in my Jenkinsfile which contains a space</p>
<p>parameters {
string(name: 'KW_Issue_resolution', defaultValue: 'Not a Problem', description: 'Marking the issue as Not a problem')
}</p>
<p>I am trying to pass this parameter into a shell script within a stage</p>
<pre><code>stage ('Mark KW issues as not a problem') {
steps {
sh "kwcheck set-status ${params.KW_Issue_IDs} --status ${params.KW_Issue_resolution}"
}
}
</code></pre>
<p>However, the shell doesn't recognize the entire string as "Not a Problem"</p>
<pre><code>+ kwcheck set-status 190 --status Not a Problem
Cannot change status, 'Not' is not a valid status name
</code></pre>
<p>Expected the shell command to be kwcheck set-status 190 --status "Not a Problem"</p>
| [
{
"answer_id": 74428883,
"author": "Giovanni Cerretani",
"author_id": 3287591,
"author_profile": "https://Stackoverflow.com/users/3287591",
"pm_score": 1,
"selected": false,
"text": "m_myMap"
},
{
"answer_id": 74428914,
"author": "mfnx",
"author_id": 5954825,
"author_profile": "https://Stackoverflow.com/users/5954825",
"pm_score": 0,
"selected": false,
"text": "std::unique_ptr"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5820172/"
] |
74,428,865 | <p>I have a file in which i have to remove the duplicate lines with same string at the last three positions</p>
<p>file.txt contains</p>
<p><code>['aabbccj', 'biukghk', 'hgkfhff', 'hsgfccj', ' jflgsfs', 'fskfyhd', 'bfsbkhd', 'fjlfghk']</code></p>
<p>i want the output as</p>
<p><code>['aabbccj', 'biukghk', 'hgkfhff', ' jflgsfs', 'fskfyhd', 'bfsbkhd']</code></p>
| [
{
"answer_id": 74428883,
"author": "Giovanni Cerretani",
"author_id": 3287591,
"author_profile": "https://Stackoverflow.com/users/3287591",
"pm_score": 1,
"selected": false,
"text": "m_myMap"
},
{
"answer_id": 74428914,
"author": "mfnx",
"author_id": 5954825,
"author_profile": "https://Stackoverflow.com/users/5954825",
"pm_score": 0,
"selected": false,
"text": "std::unique_ptr"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12964403/"
] |
74,428,866 | <ol>
<li><p>I am making a travel advisor app. here i have made a getPlacesData function in index.js which fetch data from api return data which i recieve from app.js, i want to know that when i print type of data it gives object, but i know that async function always return promise??</p>
</li>
<li><p>in app.js in useEffect where i have recieve that data there i have also console.log its type it gives object but i know .then return promise.</p>
</li>
</ol>
<p><strong>index.js</strong></p>
<pre><code>// axios is libary which helps us t make call
import axios from "axios";
const URL =
"https://travel-advisor.p.rapidapi.com/restaurants/list-in-boundary";
const options = {
params: {
bl_latitude: "11.847676",
tr_latitude: "12.838442",
bl_longitude: "109.095887",
tr_longitude: "109.149359",
},
headers: {
"X-RapidAPI-Key": "bb4974756dmsh0ecde312f187eb9p175b1djsn7eeab8063995",
"X-RapidAPI-Host": "travel-advisor.p.rapidapi.com",
},
};
export const getPlacesData = async() => {
try {
const { data: { data } } = await axios.get(URL, options);
console.log("data:", data);
console.log("data:", typeof(data));
return data;//returns restaurant data
}
catch (error) {
console.log(error);
}
};
</code></pre>
<p><strong>app.js</strong></p>
<pre><code>
import React,{useState,useEffect} from "react";
import { CssBaseline, Grid } from "@material-ui/core";
import { getPlacesData } from "./api";
import Header from "./components/Header/Header";
import List from "./components/List/List";
import Map from "./components/Map/Map";
import PlaceDetails from "./components/PlaceDetails/PlaceDetails";
const App = () => {
const [places,setPlaces]=useState([]);
useEffect(()=>{
getPlacesData()
.then((data)=>{//we use .then because getPlacesData is async
console.log("appdata",data);
console.log("appdata:", typeof(data));
setPlaces(data);
})
},[])
return (
<>
<CssBaseline />
<Header />
<Grid container spacing={3} style={{ width: "100%" }}>
<Grid item xs={12} md={4}>
<List />
</Grid>
<Grid item xs={12} md={8}>
<Map />
</Grid>
</Grid>
</>
);
};
export default App;
</code></pre>
<p>I want to get rid of my confusion.</p>
| [
{
"answer_id": 74428883,
"author": "Giovanni Cerretani",
"author_id": 3287591,
"author_profile": "https://Stackoverflow.com/users/3287591",
"pm_score": 1,
"selected": false,
"text": "m_myMap"
},
{
"answer_id": 74428914,
"author": "mfnx",
"author_id": 5954825,
"author_profile": "https://Stackoverflow.com/users/5954825",
"pm_score": 0,
"selected": false,
"text": "std::unique_ptr"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15997110/"
] |
74,428,881 | <p>I have my <strong><em>custom</em></strong> <code>Bottom Navigation Bar</code> in one dart file, i.e. <code>bottomnavbar.dart</code>. And I have list of multiple <code>screens</code>(or pages) in my <code>home.dart</code> file. I am using an <code>.obs variable</code> to store my selected index value.
<br>code from <code>home.dart</code> file:</p>
<pre><code>var selectedIndex = 0.obs;
final screen = [
const Page1(),
const Page2(),
const Page3(),
const Page4(),
const Page5(),
];
...
body: screen[selectedIndex.value],
...
</code></pre>
<p>Even if I change the variable value (like <code>0.obs</code> to <code>1.obs</code>), page not changing, why??</p>
<p>next of, In my <code>bottomnavbar.dart</code> file, I have extracted and made a widget for my <code>nav bar 'items'</code>. And I have tried to wrap the item widget with Obx:</p>
<pre><code>Widget bnbItems(String image, int index, double height) {
return Obx(
() => InkWell(
splashColor: Theme.of(context).brightness == Brightness.dark
? Colors.white.withOpacity(0.5)
: Colors.pink.withOpacity(0.5),
enableFeedback: true,
onTap: () => setState(() {
selectedIndex.value = index;
_controller.animateTo(index / 4);
// print(selectedIndex);
}),
child: Container(
alignment: Alignment.center,
width: 50,
height: 50,
child: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Image.asset(
image,
height: height,
),
),
),
),
);}
</code></pre>
<p>and I am getting this error:</p>
<pre><code>[Get] the improper use of a GetX has been detected.
You should only use GetX or Obx for the specific widget that will be updated.
If you are seeing this error, you probably did not insert any observable variables into GetX/Obx
or insert them outside the scope that GetX considers suitable for an update
(example: GetX => HeavyWidget => variableObservable).
If you need to update a parent widget and a child widget, wrap each one in an Obx/GetX.
</code></pre>
<h4>Can anyone give me the solution with some code and explanation? And also how will I be able to set a particular screen as the initial screen?</h4>
| [
{
"answer_id": 74429052,
"author": "Himani",
"author_id": 18416001,
"author_profile": "https://Stackoverflow.com/users/18416001",
"pm_score": 0,
"selected": false,
"text": " onTap: () {\n selectedIndex.value = index;\n _controller.animateTo(index / 4);\n // print(selectedIndex);\n},\n"
},
{
"answer_id": 74520509,
"author": "Paulo",
"author_id": 15649348,
"author_profile": "https://Stackoverflow.com/users/15649348",
"pm_score": 1,
"selected": false,
"text": "onTap: () {\n selectedIndex.value = 1; // page index you want to view\n},\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17411652/"
] |
74,428,888 | <p><code>polars.LazyFrame.var</code> will return variance value for each column in a table as below:</p>
<pre><code>>>> df = pl.DataFrame({"a": [1, 2, 3, 4], "b": [1, 2, 1, 1], "c": [1, 1, 1, 1]}).lazy()
>>> df.collect()
shape: (4, 3)
┌─────┬─────┬─────┐
│ a ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 │
╞═════╪═════╪═════╡
│ 1 ┆ 1 ┆ 1 │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
│ 2 ┆ 2 ┆ 1 │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
│ 3 ┆ 1 ┆ 1 │
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
│ 4 ┆ 1 ┆ 1 │
└─────┴─────┴─────┘
>>> df.var().collect()
shape: (1, 3)
┌──────────┬──────┬─────┐
│ a ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ f64 ┆ f64 ┆ f64 │
╞══════════╪══════╪═════╡
│ 1.666667 ┆ 0.25 ┆ 0.0 │
└──────────┴──────┴─────┘
</code></pre>
<p>I wish to select columns with value > 0 from LazyFrame but couldn't find the solution.</p>
<p>I can iterate over columns in polars dataframe then filter columns by condition as below:</p>
<pre><code>>>> data.var()
shape: (1, 3)
┌──────────┬──────┬─────┐
│ a ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ f64 ┆ f64 ┆ f64 │
╞══════════╪══════╪═════╡
│ 1.666667 ┆ 0.25 ┆ 0.0 │
└──────────┴──────┴─────┘
>>> cols = pl.select([s for s in data.var() if (s > 0).all()]).columns
>>> cols
['a', 'b']
>>> data.select(cols)
shape: (4, 2)
┌─────┬─────┐
│ a ┆ b │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1 ┆ 1 │
├╌╌╌╌╌┼╌╌╌╌╌┤
│ 2 ┆ 2 │
├╌╌╌╌╌┼╌╌╌╌╌┤
│ 3 ┆ 1 │
├╌╌╌╌╌┼╌╌╌╌╌┤
│ 4 ┆ 1 │
└─────┴─────┘
</code></pre>
<p>But it doesn't work in LazyFrame:</p>
<pre><code>>>> data = data.lazy()
>>> data
<polars.internals.lazyframe.frame.LazyFrame object at 0x7f0e3d9966a0>
>>> cols = pl.select([s for s in data.var() if (s > 0).all()]).columns
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
File "/home/jasmine/miniconda3/envs/jupyternb/lib/python3.9/site-packages/polars/internals/lazyframe/frame.py", line 421, in __getitem__
raise TypeError(
TypeError: 'LazyFrame' object is not subscriptable (aside from slicing). Use 'select()' or 'filter()' instead.
</code></pre>
<p>The reason for doing this in LazyFrame is that we want to maximize the performance. Any advice would be much appreciated. Thanks!</p>
| [
{
"answer_id": 74438282,
"author": "Dean MacGregor",
"author_id": 1818713,
"author_profile": "https://Stackoverflow.com/users/1818713",
"pm_score": 1,
"selected": false,
"text": "df.var().melt().filter(pl.col('value')>0).collect()\n"
},
{
"answer_id": 74443225,
"author": "braaannigan",
"author_id": 5387991,
"author_profile": "https://Stackoverflow.com/users/5387991",
"pm_score": 0,
"selected": false,
"text": "variable"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20497072/"
] |
74,428,893 | <p>I'm trying to create an automation to interact with Microsoft Business Central. For that I created a Azure App (daemon).</p>
<p>This app has granted permissions from the admin to Read/Write on BC, permissions such as Financials.ReadWrite.All and API.ReadWrite.All and are consented.</p>
<p>When I generate the access token, I can list environment and companies, but cannot list items <a href="https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_item_get" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_item_get</a></p>
<p>What other permission do I need?</p>
<p>Here is the error I get when trying to list:</p>
<pre class="lang-json prettyprint-override"><code>{
"error": {
"code":"Internal_ServerError",
"message":"Sorry, the current permissions prevented the action.(Page APIV2 - Items Execute: _Exclude_APIV2_)"
}
}
</code></pre>
<p>If I get the token from here, with my user on it, it works: <a href="https://developer.microsoft.com/en-us/graph/graph-explorer" rel="nofollow noreferrer">https://developer.microsoft.com/en-us/graph/graph-explorer</a></p>
| [
{
"answer_id": 74438282,
"author": "Dean MacGregor",
"author_id": 1818713,
"author_profile": "https://Stackoverflow.com/users/1818713",
"pm_score": 1,
"selected": false,
"text": "df.var().melt().filter(pl.col('value')>0).collect()\n"
},
{
"answer_id": 74443225,
"author": "braaannigan",
"author_id": 5387991,
"author_profile": "https://Stackoverflow.com/users/5387991",
"pm_score": 0,
"selected": false,
"text": "variable"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1771963/"
] |
74,428,947 | <p>What is the difference between the static methods <a href="https://learn.microsoft.com/en-us/dotnet/api/system.int32.min" rel="nofollow noreferrer"><code>Int32.Min</code></a> and <a href="https://learn.microsoft.com/en-us/dotnet/api/system.int32.minmagnitude" rel="nofollow noreferrer"><code>Int32.MinMagnitude</code></a>, that were introduced in .NET 7? Their signature and description is the same:</p>
<pre><code>// Compares two values to compute which is lesser.
public static int Min (int x, int y);
// Compares two values to compute which is lesser.
public static int MinMagnitude (int x, int y);
</code></pre>
| [
{
"answer_id": 74429008,
"author": "CodeCaster",
"author_id": 266143,
"author_profile": "https://Stackoverflow.com/users/266143",
"pm_score": 0,
"selected": false,
"text": "INumberBase<TSelf>"
},
{
"answer_id": 74429063,
"author": "Good Night Nerd Pride",
"author_id": 1025555,
"author_profile": "https://Stackoverflow.com/users/1025555",
"pm_score": 3,
"selected": true,
"text": "MinMagnitude()"
},
{
"answer_id": 74429280,
"author": "Guru Stron",
"author_id": 2501279,
"author_profile": "https://Stackoverflow.com/users/2501279",
"pm_score": 1,
"selected": false,
"text": "Int32"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11178549/"
] |
74,428,948 | <p>So I have a question with regards to printing out missing numbers.</p>
<p>I have an array of integers ranging from 0 - 20 and should return a string of missing numbers.</p>
<p>e.g.</p>
<p>[0, 1, 2, 8, 12, 13] would return "3-7,9-11,14-20"</p>
<p>[1, 2, 5, 12, 16] would return "0,3-4,6-11,13-15,17-20"</p>
<p>I'm just having trouble printing out the missing values as a sequence.</p>
<p>Here is my code so far:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function missingNumbers(arr){
let count = 20;
let missing = new Array();
for(let i = 0; i <= count; i++){
if(arr.indexOf(i) === -1){
missing.push(i);
}
}
return missing.toString();
}
console.log(missingNumbers([1,2]))</code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74429008,
"author": "CodeCaster",
"author_id": 266143,
"author_profile": "https://Stackoverflow.com/users/266143",
"pm_score": 0,
"selected": false,
"text": "INumberBase<TSelf>"
},
{
"answer_id": 74429063,
"author": "Good Night Nerd Pride",
"author_id": 1025555,
"author_profile": "https://Stackoverflow.com/users/1025555",
"pm_score": 3,
"selected": true,
"text": "MinMagnitude()"
},
{
"answer_id": 74429280,
"author": "Guru Stron",
"author_id": 2501279,
"author_profile": "https://Stackoverflow.com/users/2501279",
"pm_score": 1,
"selected": false,
"text": "Int32"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74428948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20408624/"
] |
74,429,020 | <p>I am wondering what type of alternatives are best to use in this situation.</p>
<pre><code>if (method1(parameters)
method2(parameters);
if (method1(differentParameters)
method2(differentParameters;
//and so on.
</code></pre>
<p>The code is for an othello game implementation, the first method checks if there are any opponent pieces that can be fliped, the inner method flips the pieces. We check all 8 directions to and flip pieces accordingly.</p>
<p>The code works, but I am searching for alternatives to refactor it.</p>
| [
{
"answer_id": 74429248,
"author": "Elemental",
"author_id": 98636,
"author_profile": "https://Stackoverflow.com/users/98636",
"pm_score": 1,
"selected": false,
"text": "Check"
},
{
"answer_id": 74429270,
"author": "Marco Anastasio",
"author_id": 19290920,
"author_profile": "https://Stackoverflow.com/users/19290920",
"pm_score": -1,
"selected": false,
"text": "Object o = method1(param);\n\nswitch (o)\n case o == 1:\n method2(o)\n case o == 2:\n method2(o)\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20127861/"
] |
74,429,033 | <p>I'm trying to handle silent notification sent to me from by backend which triggers Firebase services and it (probably?) triggers Apple servers to send the push.</p>
<p>I've selected Remote notifications and Background fetch in project's Signing & Capabilities: <a href="https://i.stack.imgur.com/RTr5G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RTr5G.png" alt="remote notifications and background fetch setting in xcode project" /></a></p>
<p>The usual notifications tested by Firebase console backend are working fine. Yet, while I want to handle the silent notifications (which I cannot send directly on Firebase console) by implementing the</p>
<pre><code>func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
</code></pre>
<p>method, I got nothing - the method <strong>is not called</strong> - while backend developer assures me that the silent push notification has been is sent (at least to Firebase).</p>
<p>The piece of code run on the backend to trigger Firebase silent notification looks somehow like this:</p>
<pre><code>ApnsConfig.builder()
.setAps(
Aps.builder()
.setCategory(pushType.toString())
.setContentAvailable(true)
</code></pre>
<p>I'm testing it while the app is running - since this silent notification is used to update the state of the app when user triggered something on the web just after he/she interacted with the website (by scanning the website QR code).</p>
<p>To debug it I'm trying to intercept all the connections using Charles application - but for now without any success (I'm not able to see even standard push notification being received - which is being shown). Maybe I should be able to see some logs in the Firebase console which I have not found yet?</p>
<p>How can I prove (or disprove) that the correct notification to the correct device is not being sent and received?</p>
<p>UPDATE:
Using Curl to fire background push is working - while using legacy method of sending the push</p>
<pre><code>curl --location --request POST 'https://fcm.googleapis.com/fcm/send' \
--header 'Authorization: key=HERE_AUTH_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"to" : "HERE_FIREBASE_MESSAGING_IDENTIFIER",
"content_available": true,
"apns-priority": 5
}'
</code></pre>
| [
{
"answer_id": 74544693,
"author": "Paul Brewczynski",
"author_id": 1364174,
"author_profile": "https://Stackoverflow.com/users/1364174",
"pm_score": 0,
"selected": false,
"text": "putHeader(\"apns-push-type\", \"background\")"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1364174/"
] |
74,429,049 | <p>I am using Java 8 stream</p>
<pre><code>executeRequest(requestId).stream()
.map(d-> (Response) d).collect(Collectors.toList());
</code></pre>
<p>the Response object is like this</p>
<pre><code>@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Response {
String title;
String id;
}
</code></pre>
<p>when the responses are null, I am getting an error because it is trying to collect null values in a list, I want to have a condition that when title is null, stream does not continue, or any thing that helps me to handle it</p>
| [
{
"answer_id": 74544693,
"author": "Paul Brewczynski",
"author_id": 1364174,
"author_profile": "https://Stackoverflow.com/users/1364174",
"pm_score": 0,
"selected": false,
"text": "putHeader(\"apns-push-type\", \"background\")"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18845587/"
] |
74,429,056 | <p>I'm trying to compare the data on my csv file to web table.
`</p>
<pre><code>WebElement mytable1 = driver.findElement(By.cssSelector("#dStocks1"));
// To locate rows of table.
List<WebElement> rows_table1 = mytable1.findElements(By.tagName("tr"));
// To calculate no of rows In table.
int rows_count1 = rows_table1.size();
String path = (filePath);
BufferedReader br = null;
String line;
String splitBy = ",(?=([^\"]|\"[^\"]*\")*$)";
br = new BufferedReader(new FileReader(path));
System.out.println("\n CSV data: ");
br.readLine();
while ((line = br.readLine()) != null) {
for (int col = 1; col < line.length();) {
for (int row = 1; row < rows_count1;) {
System.out.println(" ");
String[] cells = line.split(splitBy);
List<WebElement> rows_table2 = mytable1.findElements(By.tagName("tr"));
List<WebElement> Columns_row = rows_table2.get(row).findElements(By.tagName("td"));
int columns_count = Columns_row.size();
System.out.println("Number of cells In Row " + row + " are " + columns_count);
for (int column = 1; column < columns_count; column++) {
String celtext = Columns_row.get(column).getText();
String col1 = cells[col].substring(1, cells[col].length() - 1);
assertEquals(celtext, col1);
System.out.print(" CELL: " + column + " " + col1 +"\n");
br.readLine();
col++;
}
row++;
System.out.println(" ");
}
}
}
</code></pre>
<p>`</p>
<p>This is the result
`</p>
<pre><code>Number of cells In Row 1 are 9
CELL: 1 Requested
CELL: 2 PO0815454781
CELL: 3 Main Office Stockroom
CELL: 4 09/13/2022
CELL: 5 DR1212475112
CELL: 6 09/20/2022
CELL: 7 TGP
CELL: 8 3,000,000.00
Number of cells In Row 2 are 9
PASSED: export
FAILED: exportRequested
Index 9 out of bounds for length 9
</code></pre>
<p>`</p>
<p>The last index of my csv file is '8' but after printing the <code>line.length</code> it display '115' and that is the problem. My index is out of bounds. Can someone help me with this. Thank you in advance</p>
| [
{
"answer_id": 74544693,
"author": "Paul Brewczynski",
"author_id": 1364174,
"author_profile": "https://Stackoverflow.com/users/1364174",
"pm_score": 0,
"selected": false,
"text": "putHeader(\"apns-push-type\", \"background\")"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19698621/"
] |
74,429,201 | <pre><code>window.addEventListener('scroll',function(){
if(window.pageYOffset > 100)
{
document.getElementById('fade').style.opacity=1;
}
else
{
document.getElementById('fade').style.opacity=0;
}
});
</code></pre>
<p>JavaScript fad-in fade-out animation with scrolling event or without using libraries API, only with logics</p>
| [
{
"answer_id": 74429278,
"author": "Rory McCrossan",
"author_id": 519413,
"author_profile": "https://Stackoverflow.com/users/519413",
"pm_score": 1,
"selected": false,
"text": "transition"
},
{
"answer_id": 74429780,
"author": "NathanaelDousa",
"author_id": 16420813,
"author_profile": "https://Stackoverflow.com/users/16420813",
"pm_score": 0,
"selected": false,
"text": "<!DOCTYPE html>\n<html lang=\"en\">\n<body>\n<section>\n <div class=\"tile bottom-right\"></div>\n <div class=\"tile bottom-right\"></div>\n <div class=\"tile bottom-right\"></div>\n <div class=\"tile\"></div>\n <div class=\"tile\"></div>\n <div class=\"tile\"></div>\n</section>\n</body>\n</html>\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19052139/"
] |
74,429,226 | <p>I installed mongodb as a replicaset with 3 replicas on my k8s cluster using the bitnami helm chart.</p>
<p>So I get these pods:</p>
<pre><code>mongodb-0.mongodb-headless.mongodb.svc.cluster.local:27017
mongodb-1.mongodb-headless.mongodb.svc.cluster.local:27017
mongodb-2.mongodb-headless.mongodb.svc.cluster.local:27017
</code></pre>
<p>Now I would like to get access using mongodb compass.</p>
<p>I set a port forward (at 27017 I'm running a local mongodb)</p>
<pre><code>kubectl port-forward svc/mongodb-headless -n mongodb 27018:27017
</code></pre>
<p>and tried to connect compass with the uri</p>
<pre><code>mongodb://localhost:27018
</code></pre>
<p>But this gives me the error</p>
<pre><code>getaddrinfo ENOTFOUND mongodb-0.mongodb-headless.mongodb.svc.cluster.local
</code></pre>
<p>What am I doing wrong to connect to my k8s cluster mongodb using compass?</p>
<hr />
<p><em>Update</em></p>
<pre><code>% kubectl get all -n mongodb
NAME READY STATUS RESTARTS AGE
pod/mongodb-0 1/1 Running 0 25h
pod/mongodb-1 1/1 Running 0 25h
pod/mongodb-2 1/1 Running 0 25h
pod/mongodb-arbiter-0 1/1 Running 0 2d14h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/mongodb-arbiter-headless ClusterIP None <none> 27017/TCP 2d14h
service/mongodb-headless ClusterIP None <none> 27017/TCP 2d14h
NAME READY AGE
statefulset.apps/mongodb 3/3 2d14h
statefulset.apps/mongodb-arbiter 1/1 2d14h
</code></pre>
<p><strong>values.yaml for bitnami helm chart</strong></p>
<pre><code>image:
registry: docker.io
repository: bitnami/mongodb
digest: "sha256:916202d7af766dd88c2fff63bf711162c9d708ac7a3ffccd2aa812e3f03ae209" # tag: 4.4.15
pullPolicy: IfNotPresent
architecture: replicaset
replicaCount: 2
updateStrategy:
type: RollingUpdate
containerPorts:
mongodb: 27017
auth:
enabled: true
rootUser: root
rootPassword: "password"
usernames: ["user"]
passwords: ["userpass"]
databases: ["db"]
service:
portName: mongodb
ports:
mongodb: 27017
persistence:
enabled: true
accessModes:
- ReadWriteOnce
size: 8Gi
volumePermissions:
enabled: true
livenessProbe:
enabled: false
readinessProbe:
enabled: false
</code></pre>
| [
{
"answer_id": 74467992,
"author": "R2D2",
"author_id": 10415047,
"author_profile": "https://Stackoverflow.com/users/10415047",
"pm_score": 0,
"selected": false,
"text": "kind: Service \napiVersion: v1 \nmetadata:\n name: mongodb-0\nspec:\n type: NodePort\n selector:\n statefulset.kubernetes.io/pod-name: mongodb-0\n ports:\n - nodePort: 30117\n port: 27017\n targetPort: 27017\n protocol: TCP\n"
},
{
"answer_id": 74473738,
"author": "Konstantin Vustin",
"author_id": 9065705,
"author_profile": "https://Stackoverflow.com/users/9065705",
"pm_score": 3,
"selected": true,
"text": "$ k create ns mongo-test\nnamespace/mongo-test created\n\n$ k -n mongo-test create -f mongo-svc-sts.yaml\nstatefulset.apps/mongo created\nservice/mongo-headless created\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3142695/"
] |
74,429,227 | <p>I have a call method on button click</p>
<pre><code>button_call=(Button) findViewById(R.id.button_call);
button_call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:+79142214017"));
startActivity(intent);
}
});
</code></pre>
<p>And the data transfer method in Firebase</p>
<pre><code>private void validateClientInfo() {
if (TextUtils.isEmpty(client_edit.getText().toString())) {
Toast.makeText(this, "Введите имя", Toast.LENGTH_SHORT).show();
}
if (TextUtils.isEmpty(client_number.getText().toString())){
Toast.makeText(this, "Введите номер", Toast.LENGTH_SHORT).show();
}
else {
HashMap<String, Object> userMap = new HashMap<>();
userMap.put("uid", mAuth.getCurrentUser().getUid());
userMap.put("numberphone_client",client_number.getText().toString());
clientRef.child(mAuth.getCurrentUser().getUid()).updateChildren(userMap);
startActivity(new Intent(ClientName.this,HomeActivity.class));
}
}
</code></pre>
<p>transcripts</p>
<pre><code>client_number=(EditText) findViewById(R.id.client_number);
mAuth=FirebaseAuth.getInstance();
</code></pre>
<p>how to make it so that when the call button is pressed, the number is received and called?</p>
<p>I want that when the button _call button is pressed, the data transmitted by the transfer method is received and a call is made on them.</p>
| [
{
"answer_id": 74429994,
"author": "BadDa3mon",
"author_id": 16564674,
"author_profile": "https://Stackoverflow.com/users/16564674",
"pm_score": 1,
"selected": false,
"text": "<uses-permission android:name=\"android.permission.CALL_PHONE\" />"
},
{
"answer_id": 74432104,
"author": "Shyam Sunder",
"author_id": 18542740,
"author_profile": "https://Stackoverflow.com/users/18542740",
"pm_score": 0,
"selected": false,
"text": "Intent intentCallForward = new Intent(Intent.ACTION_DIAL); // ACTION_CALL\n Uri uri2 = Uri.fromParts(\"tel\", \"79142214017, \"#\");\n intentCallForward.setData(uri2);\n startActivityForResult(intentCallForward, 101);\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20467834/"
] |
74,429,245 | <p>I'm trying to save unique name in the database but the problem I can save the same with different letters, for example I can save (IT, it, iT, It) I don't want to save it like that.</p>
<p><strong>Model:</strong></p>
<pre><code>class Service(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=127, unique=True, null=False, blank=False) # that field
is_active = models.BooleanField(default=True)
is_deleted = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
created_by = models.ForeignKey(
"accounts.User",
on_delete=SET_NULL,
blank=False,
null=True,
related_name="service_created_by",
)
def __str__(self):
return f"{self.name}"
</code></pre>
| [
{
"answer_id": 74429994,
"author": "BadDa3mon",
"author_id": 16564674,
"author_profile": "https://Stackoverflow.com/users/16564674",
"pm_score": 1,
"selected": false,
"text": "<uses-permission android:name=\"android.permission.CALL_PHONE\" />"
},
{
"answer_id": 74432104,
"author": "Shyam Sunder",
"author_id": 18542740,
"author_profile": "https://Stackoverflow.com/users/18542740",
"pm_score": 0,
"selected": false,
"text": "Intent intentCallForward = new Intent(Intent.ACTION_DIAL); // ACTION_CALL\n Uri uri2 = Uri.fromParts(\"tel\", \"79142214017, \"#\");\n intentCallForward.setData(uri2);\n startActivityForResult(intentCallForward, 101);\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16165474/"
] |
74,429,267 | <p>I am trying to build following functionality:</p>
<p>User can type number on keyboard while the tab is active, and this can be a number with several digits. How can I get the whole number after the delay time between the <strong>keyup</strong> event is finished?</p>
<p>I have written following code, but I am getting the <strong>buffer</strong> on every <strong>keyup</strong>, and I only need to get the final result. What am I doing wrong?</p>
<p>The code so far:</p>
<pre><code>const delay = 1000
const keystrokeDelay = delay;
let state = {
buffer: [],
lastKeyTime: Date.now()
};
document.addEventListener('keyup', event => {
const key = event.key;
const currentTime = Date.now();
let buffer = [];
if (currentTime - state.lastKeyTime > keystrokeDelay) {
buffer = [key];
} else {
buffer = [...state.buffer, key];
}
state = {buffer: buffer, lastKeyTime: currentTime};
});
</code></pre>
| [
{
"answer_id": 74429381,
"author": "Lain",
"author_id": 4728913,
"author_profile": "https://Stackoverflow.com/users/4728913",
"pm_score": 2,
"selected": true,
"text": "setTimeout"
},
{
"answer_id": 74429487,
"author": "Jay Vaghasiya",
"author_id": 10562084,
"author_profile": "https://Stackoverflow.com/users/10562084",
"pm_score": 0,
"selected": false,
"text": "const input = document.getElementById('input')\n\nfunction debounce(func, timeout = 1000){\n let timer;\n return (...args) => {\n clearTimeout(timer);\n timer = setTimeout(() => { func.apply(this, args); }, timeout);\n };\n}\n\nfunction submit(){\n console.log('Saving data', input.value);\n}\n\ninput.addEventListener(\"keyup\", debounce(submit));"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/934703/"
] |
74,429,325 | <p>I try to calculate some stats for a list. But somehow these are not correct:
Code:
import pandas as pd</p>
<pre><code>import statistics
list_runs_stats=[4.149432, 3.133142, 3.182976, 2.620959, 3.200038, 2.66668, 2.604444, 2.683382, 3.249564, 3.149947]
list_stats=pd.Series(list_runs_stats).describe()
print (list_stats.mean())
print (list_stats.min())
print (list_stats.max())
print (list_stats.median())
print (list_stats.count())
</code></pre>
<p>Result:</p>
<pre><code>3.6617099664905832
0.467574831924664
10.0
3.10280045
8
</code></pre>
<p>I think min, max and count is quite obvious that it is not correct.
Excel gives me mean: 3.0640564 and median:3,1415445</p>
<p>What I am doing wrong?</p>
| [
{
"answer_id": 74429371,
"author": "abhilash966",
"author_id": 20494569,
"author_profile": "https://Stackoverflow.com/users/20494569",
"pm_score": 3,
"selected": true,
"text": "describe()"
},
{
"answer_id": 74429383,
"author": "hjun",
"author_id": 19399320,
"author_profile": "https://Stackoverflow.com/users/19399320",
"pm_score": 1,
"selected": false,
"text": "print(statistics.mean(list_runs_stats)) # would print 3.0640564\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11378968/"
] |
74,429,364 | <p>I have a list of strings in python which are in form of an arithmetic problem. So:</p>
<p><code>p_list = ['32 + 5', '4 - 1', '345 + 2390']</code></p>
<p>I would love each of the list to be arranged in this manner</p>
<pre><code> 32 4 345
+ 5 - 1 + 2390
---- --- ------
</code></pre>
<p>So essentially i want the numbers to be right aligned and four spaces between each expression.</p>
<p>I tried doing something like this</p>
<pre><code>final = f"{final} {problem_list[key]['operand1']}\n{problem_list[key]['operator']} {problem_list[key]['operand2']}"
</code></pre>
<p>but i got this instead</p>
<pre><code>213
+ 4 3234
+ 4 3
- 3 5
+ 7
</code></pre>
<p>thanks in advance</p>
| [
{
"answer_id": 74429689,
"author": "Timo",
"author_id": 12888866,
"author_profile": "https://Stackoverflow.com/users/12888866",
"pm_score": 1,
"selected": false,
"text": "def arithmetic_format(eq_list, sep = 4):\n top = mid = bot = \"\"\n sep = \" \" * sep\n for eq in eq_list:\n chars = eq.split()\n width = len(max(chars, key=len)) + 2\n top += chars[0].rjust(width) + sep\n mid += chars[1] + chars[2].rjust(width - 1) + sep\n bot += \"-\" * width + sep \n return f\"{top}\\n{mid}\\n{bot}\"\n\np_list = ['32 + 5', '4 - 1', '345 + 2390']\nanswer = arithmetic_format(p_list)\nprint(answer) \n"
},
{
"answer_id": 74429779,
"author": "Snorko",
"author_id": 12075658,
"author_profile": "https://Stackoverflow.com/users/12075658",
"pm_score": -1,
"selected": false,
"text": "p_list = ['32 + 5', '4 - 1', '345 + 2390']\nup= []\ndown=[]\n\nfor op in p_list:\n new = op.split(' ')\n up.append(new[0] + ' '*4)\n if new[1] == '-':\n down.append(str(0 - int(new[-1])) + ' '*4)\n else:\n down.append('+' + new[-1] + ' '*3)\nfor index,value in enumerate(up):\n print(value, end=' ')\nprint('')\nfor index,value in enumerate(down):\n print(value, end=' ')\n\n\n\n\n# 32 4 345 \n# +5 -1 +2390 \n"
},
{
"answer_id": 74430415,
"author": "Cobra",
"author_id": 17580381,
"author_profile": "https://Stackoverflow.com/users/17580381",
"pm_score": 0,
"selected": false,
"text": "plist = ['32 + 5', '4 - 1', '345 + 2390']\nspaces = ' ' * 4\n\ndef parts(plist):\n return [e.split() for e in plist]\n\ndef widths(plist):\n return [max(map(len, e))+2 for e in parts(plist)]\n\ndef get_tokens(plist, idx):\n if idx == 0:\n return [f'{e:>{w}}' for (e, _, _), w in zip(parts(plist), widths(plist))]\n if idx == 1:\n return [f'{s}{n:>{w-1}}' for (_, s, n), w in zip(parts(plist), widths(plist))]\n return ['-' * w for w in widths(plist)]\n\nfor idx in range(3):\n print(spaces.join(get_tokens(plist, idx)))\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19979182/"
] |
74,429,365 | <p>Consider the following Array:</p>
<pre><code>julia> test_mat3 = rand(2, 3, 2)
2×3×2 Array{Float64, 3}:
[:, :, 1] =
0.539697 0.17689 0.944783
0.537687 0.660573 0.19497
[:, :, 2] =
0.726739 0.798789 0.0900478
0.00744727 0.837076 0.25798
</code></pre>
<p>I want to reshape it into a 2d Array with a specific order. First, I want to concatenate <strong>each row of each inner matrix</strong> (here with shape 2x3). So for the first step, I expect several 1x6 inner matrixes. Second, I want to concatenate these matrixes vertically. The expected output on the <code>test_mat3</code> would be:</p>
<pre><code>2×6 Array{Float64, 2}:
0.539697 0.17689 0.944783 0.537687 0.660573 0.19497
0.726739 0.798789 0.0900478 0.00744727 0.837076 0.25798
</code></pre>
<p>However, I wrote this code:</p>
<pre><code>using SplitApplyCombine
function flatten_3d(arr::Array{Float64, 3})
mat = zeros(
Float64,
size(arr, 3),
size(arr, 1)*size(arr, 2)
)
for (idx, arr)=enumerate(splitdimsview(arr, 3))
the_vec = vcat(eachrow(arr)...)
mat[idx, :] = the_vec
end
return mat
end
</code></pre>
<p>The script does the job:</p>
<pre><code>julia> flatten_3d(test_mat3)
2×6 Matrix{Float64}:
0.539697 0.17689 0.944783 0.537687 0.660573 0.19497
0.726739 0.798789 0.0900478 0.00744727 0.837076 0.25798
</code></pre>
<p>But I wonder if there is any better way to do this? Any built-in function, etc.</p>
| [
{
"answer_id": 74430027,
"author": "Dan Getz",
"author_id": 3580870,
"author_profile": "https://Stackoverflow.com/users/3580870",
"pm_score": 2,
"selected": false,
"text": "using Combinatorics\n\ntest_mat3 = zeros(2, 3, 2); \ntest_mat3[:, :, 1] = \n [0.539697 0.17689 0.944783 ; \n 0.537687 0.660573 0.19497 ] \ntest_mat3[:, :, 2] = \n [ 0.726739 0.798789 0.0900478; \n 0.00744727 0.837076 0.25798]\n\nfor p in permutations(1:3)\n A = reshape(permutedims(test_mat3,p),(2,6))\n @show p\n display(A)\nend\n"
},
{
"answer_id": 74430595,
"author": "mcabbott",
"author_id": 13706735,
"author_profile": "https://Stackoverflow.com/users/13706735",
"pm_score": 3,
"selected": true,
"text": "julia> using TensorCast\n\njulia> @cast mat[k,(j,i)] := test_mat3[i,j,k];\n\njulia> mat == flatten_3d(test_mat3)\ntrue\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11747148/"
] |
74,429,385 | <p>I am trying to download all CSV files from the <code>\tmp\</code> directory with a PS script and convert them to one excel file as a report and place it in the <code>\reports\</code> directory under the name <code>LDAP.xlsx</code> . My CSV files have varying amounts of saved data.</p>
<p>In the forum I found this <a href="https://stackoverflow.com/questions/17688468/how-to-export-a-csv-to-excel-using-powershell">how-to-export-a-csv-to-excel-using-powershell</a> and my code looks like this:</p>
<pre><code>Clear-Host
# SOURCE
##########
# config file
$conf_file = "C:\PS_LDAP_searchlight\config\searchlight_conf.conf"
$conf_values = Get-Content $conf_file | Out-String | ConvertFrom-StringData
# variables from config file
$main_path = $conf_values.main_path
$tmp_path = $conf_values.tmp_path
$reports_path = $conf_values.reports_path
# PROGRAM
##########
$workingdir = $main_path + $tmp_path + "*.csv"
$reportsdir = $main_path + $reports_path
$csv = dir -path $workingdir
foreach($inputCSV in $csv){
$outputXLSX = $reportsdir + "\" + $inputCSV.Basename + ".xlsx"
### Create a new Excel Workbook with one empty sheet
$excel = New-Object -ComObject excel.application
$excel.DisplayAlerts = $False
$workbook = $excel.Workbooks.Add(1)
$worksheet = $workbook.worksheets.Item(1)
### Build the QueryTables.Add command
### QueryTables does the same as when clicking "Data » From Text" in Excel
$TxtConnector = ("TEXT;" + $inputCSV)
$Connector = $worksheet.QueryTables.add($TxtConnector,$worksheet.Range("A1"))
$query = $worksheet.QueryTables.item($Connector.name)
### Set the delimiter (, or ;) according to your regional settings
### $Excel.Application.International(3) = ,
### $Excel.Application.International(5) = ;
$query.TextFileOtherDelimiter = $Excel.Application.International(5)
### Set the format to delimited and text for every column
### A trick to create an array of 2s is used with the preceding comma
$query.TextFileParseType = 1
$query.TextFileColumnDataTypes = ,2 * $worksheet.Cells.Columns.Count
$query.AdjustColumnWidth = 1
### Execute & delete the import query
$query.Refresh()
$query.Delete()
### Save & close the Workbook as XLSX. Change the output extension for Excel 2003
$Workbook.SaveAs($outputXLSX,51)
$excel.Quit()
# Cleaner
$inputCSV = $null
$outputXLSX = $null
}
## To exclude an item, use the '-exclude' parameter (wildcards if needed)
#remove-item -path $workingdir -exclude *Crab4dq.csv
# CLEANER
###############################
# SOURCE
###############################
# config file
$conf_file = $null
$conf_values = $null
# variables from config file
$main_path = $null
$tmp_path = $null
$reports_path = $null
# PROGRAM
###############################
$workingdir = $null
$csv = $null
$reportsdir = $null
</code></pre>
<p>the code reads all files but writes one to one. I need help and explanation on how to make a many-to-one option. I would like each CSV file to be saved as a separate sheet under its own name like:</p>
<p>users_all_inf.csv in excel\sheet1 => users_all_inf<br />
active_users_last_logon_year_ago.csv in excel\sheet2 => active_users_last_logon_year_ago<br />
nextfilename.csv in excel\next_sheet => nextfilename</p>
<p>so that all data will be available in one excel report.xlsx file.<br />
I will be grateful for any hint or help in converting the code.</p>
| [
{
"answer_id": 74445495,
"author": "Kubix",
"author_id": 20164393,
"author_profile": "https://Stackoverflow.com/users/20164393",
"pm_score": 0,
"selected": false,
"text": "# variables from config file\n$main_path = $conf_values.main_path\n$tmp_path = $conf_values.tmp_path\n$reports_path = $conf_values.reports_path\n$system_name = $conf_values.system_name\n\n$tmp_dir = $main_path + $tmp_path + \"*\"\n$csvs = Get-ChildItem $tmp_dir -Include *.csv\n$y = $csvs.Count\nWrite-Host \"Detected the following CSV files: ($y)\"\nforeach ($csv in $csvs)\n{\nWrite-Host \" \"$csv.Name\n}\n\n$outputfilename = $(get-date -f yyyyMMdd) + \"_\" + $system_name + \"_report.xlsx\" #creates file name with date/username\nWrite-Host Creating: $outputfilename\n\n$excelapp = new-object -comobject Excel.Application\n$excelapp.sheetsInNewWorkbook = $csvs.Count\n$xlsx = $excelapp.Workbooks.Add()\n$sheet=1\n\nforeach ($csv in $csvs) {\n $row=1\n $column=1\n $worksheet = $xlsx.Worksheets.Item($sheet)\n $worksheet.Name = $csv.Name\n $file = (Get-Content $csv)\n foreach($line in $file) {\n $linecontents=$line -split ',(?!\\s*\\w+\")'\n foreach($cell in $linecontents) {\n $worksheet.Cells.Item($row,$column) = $cell\n $column++\n }\n $column=1\n $row++\n }\n $sheet++\n}\n\n$output = $main_path + $reports_path + $outputfilename\n$xlsx.SaveAs($output)\n$excelapp.quit()\n"
},
{
"answer_id": 74447087,
"author": "Dilly B",
"author_id": 2670623,
"author_profile": "https://Stackoverflow.com/users/2670623",
"pm_score": 0,
"selected": false,
"text": "$outputFile = \"C:\\Temp\\OutputExcelFile.xlsx\" #Output File\n$csvFiles = Get-childItem -Filter *.csv # Filtering CSV file in my present working dir\nforeach ($csvFile in $csvFiles) {\n#Import csv file and export it contents to Output excel file and rename the sheet.\nImport-csv $csvFile | Export-Excel $outputFile -WorksheetName $csvFile.BaseName\n}\n"
},
{
"answer_id": 74456542,
"author": "Kubix",
"author_id": 20164393,
"author_profile": "https://Stackoverflow.com/users/20164393",
"pm_score": 2,
"selected": true,
"text": "Clear-Host\n# config file\n$conf_file = \"C:\\SEARCHLIGHT\\config\\searchlight_conf.conf\"\n$conf_values = Get-Content $conf_file | Out-String | ConvertFrom-StringData\n\n# variables from config file\n$main_path = $conf_values.main_path\n$tmp_path = $conf_values.tmp_path\n$reports_path = $conf_values.reports_path\n$system_name = $conf_values.system_name\n\n$tmp_dir = $main_path + $tmp_path + \"*\" # source file\n$outputfilename = $(get-date -f yyyyMMdd) + \"_\" + $system_name + \"_report.xlsx\" # destination file with date\n \n# get list of csvs files\n$csvs = Get-ChildItem $tmp_dir -Include *.csv\n$y = $csvs.Count\nWrite-Host \"Detected the following CSV files: ($y)\"\nforeach ($csv in $csvs) {\n Write-Host \" \"$csv.Name\n}\n\nWrite-Host Creating: $outputfilename\n# Create a new Excel workbook\n$excelapp = new-object -comobject Excel.Application\n$excelapp.sheetsInNewWorkbook = $csvs.Count\n$xlsx = $excelapp.Workbooks.Add()\n$sheet=1\n$delimiter = \";\" # delimiter used in the csv file\nforeach ($csv in $csvs) {\n #$row=1\n #$column=1\n $worksheet = $xlsx.Worksheets.Item($sheet)\n $worksheet.Name = $csv.Name\n # Build the QueryTables.Add command and reformat the data\n $TxtConnector = (\"TEXT;\" + $csv)\n $Connector = $worksheet.QueryTables.add($TxtConnector,$worksheet.Range(\"A1\"))\n $query = $worksheet.QueryTables.item($Connector.name)\n $query.TextFileOtherDelimiter = $delimiter\n $query.TextFileParseType = 1\n $query.TextFileColumnDataTypes = ,1 * $worksheet.Cells.Columns.Count\n $query.AdjustColumnWidth = 1\n # Execute & delete the import query\n $query.Refresh()\n $query.Delete()\n $sheet++\n} # end foreach ($csv in $csvs)\n# Save & close the Workbook as XLSX\n$output = $main_path + $reports_path + $outputfilename\n$xlsx.SaveAs($output)\n$excelapp.quit()\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20164393/"
] |
74,429,410 | <p>I want to use <strong>Wrap</strong> on large amount of objects.</p>
<p>I tried to just map all object to <strong>children</strong> but it cause <em>serious performance issue</em>.</p>
<p>I want some alternative way to build only currently displayed widgets but with style of <strong>Wrap</strong>.</p>
<p>Some code:</p>
<pre class="lang-dart prettyprint-override"><code>Wrap(
children: list.map(createCardFromData), // List contains 20'000 items
);
</code></pre>
| [
{
"answer_id": 74429504,
"author": "Vym",
"author_id": 14251124,
"author_profile": "https://Stackoverflow.com/users/14251124",
"pm_score": 1,
"selected": false,
"text": "ListView"
},
{
"answer_id": 74430559,
"author": "Ivo",
"author_id": 1514861,
"author_profile": "https://Stackoverflow.com/users/1514861",
"pm_score": 1,
"selected": false,
"text": "import 'dart:math';\nimport 'package:flutter/cupertino.dart';\n\ntypedef ValueWidgetBuilder<T> = Widget Function(T value);\n\nclass WrapBuilder extends StatelessWidget {\n final double itemWidth;\n final List items;\n final ValueWidgetBuilder itemBuilder;\n\n const WrapBuilder(\n {Key? key,\n required this.itemWidth,\n required this.items,\n required this.itemBuilder})\n : super(key: key);\n\n @override\n Widget build(BuildContext context) {\n return LayoutBuilder(builder: (context, constraints) {\n var cardsPerRow = max(1, constraints.maxWidth ~/ itemWidth);\n return ListView.builder(\n shrinkWrap: true,\n controller: ScrollController(),\n itemCount: (items.length / cardsPerRow).ceil(),\n itemBuilder: (BuildContext context, int index) {\n var rowItems = items.sublist(cardsPerRow * index,\n min(cardsPerRow * (index + 1), items.length));\n return Row(children: [\n for (final item in rowItems)\n SizedBox(\n width: itemWidth,\n child: itemBuilder(item))\n ]);\n },\n );\n });\n }\n}\n"
},
{
"answer_id": 74433655,
"author": "Rahul",
"author_id": 16569443,
"author_profile": "https://Stackoverflow.com/users/16569443",
"pm_score": 3,
"selected": true,
"text": "name: scrollable_wrap\ndescription: A new Flutter project.\n\npublish_to: \"none\"\n\nversion: 1.0.0+1\n\nenvironment:\n sdk: \">=2.18.4 <3.0.0\"\n\ndependencies:\n cupertino_icons: ^1.0.2\n flutter:\n sdk: flutter\n flutter_svg: ^1.1.6\n random_avatar: ^0.0.7\n random_words: ^1.0.2\n dynamic_layouts:\n git:\n url: git@github.com:flutter/packages.git\n path: packages/dynamic_layouts\n\ndev_dependencies:\n flutter_lints: ^2.0.0\n flutter_test:\n sdk: flutter\n\nflutter:\n uses-material-design: true\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11962301/"
] |
74,429,412 | <p>With reduce function this was supposed to return 9000 but how come does it return 256000?
I tested similar code before and it worked fine</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function combined(...s) {
return s.flat().reduce(x => x + x)
}
console.log(combined([1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000]))</code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74429464,
"author": "Axekan",
"author_id": 12519793,
"author_profile": "https://Stackoverflow.com/users/12519793",
"pm_score": 2,
"selected": false,
"text": "reduce"
},
{
"answer_id": 74429491,
"author": "Harun Yilmaz",
"author_id": 1331040,
"author_profile": "https://Stackoverflow.com/users/1331040",
"pm_score": 1,
"selected": false,
"text": "Array.reduce()"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,429,453 | <p>Good Morning</p>
<p>I need your help with a formula please, I have a list of items in one cell:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Column A</th>
</tr>
</thead>
<tbody>
<tr>
<td>Apple</td>
</tr>
<tr>
<td>Banana</td>
</tr>
<tr>
<td>Pear</td>
</tr>
<tr>
<td>Grape</td>
</tr>
<tr>
<td>Apple / Banana</td>
</tr>
<tr>
<td>Grape / Pear / Apple</td>
</tr>
</tbody>
</table>
</div>
<p>I would like the result to say:</p>
<pre><code>Apples 3
Banana 3
Pear 2
Grape 2
</code></pre>
<p>I have done the following =countif(Range, list) this counts all the individual items, but it won't count the items when included with other items.</p>
<p>Can you help please?</p>
<p>Thanks</p>
<p>Wayne</p>
| [
{
"answer_id": 74429464,
"author": "Axekan",
"author_id": 12519793,
"author_profile": "https://Stackoverflow.com/users/12519793",
"pm_score": 2,
"selected": false,
"text": "reduce"
},
{
"answer_id": 74429491,
"author": "Harun Yilmaz",
"author_id": 1331040,
"author_profile": "https://Stackoverflow.com/users/1331040",
"pm_score": 1,
"selected": false,
"text": "Array.reduce()"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10495277/"
] |
74,429,458 | <p>I'm using Deadline monitor to automate a few processes. I don't think you'll need to know about Deadline to answer my question though.</p>
<p>I've created a Python script that takes a few arguments to be able to create the .bat file. I then want the same python script to run the .bat file to do what I need it to do. However, I'm not having any luck.</p>
<pre><code>def main(project_path, nuke_job_id):
dependencies_file = project_path + "\\" + "dependencies.txt"
with open(dependencies_file, 'r') as f:
Job_IDs = f.readlines()
# ------------- remove unwanted characters
list_string = str(Job_IDs)
beginning_ids = list_string.split("[")
end_ids = beginning_ids[1].split("]")
job_ids_string = end_ids[0].split("'") # position 1 has what is needed
# -------------
temp_id = '636e4b2a518c9b626412f608'
command = '"%deadline_path%"' + "\\deadlinecommand" + " " + "-SetJobSetting" + " " + temp_id + " " + "JobDependencies" + " " + job_ids_string[1]
bat_file = open(project_path + "\\" + "create_dependencies.bat", 'w+')
bat_file.write("@echo off" + "\r\r" + command)
bat_file.close()
print ('bat file closed')
bat_file_to_run = project_path + "\\" + "create_dependencies.bat"
time.sleep(5)
run_bat(bat_file_to_run)
def run_bat(bat_file_to_run):
print ("run_bat")
process = subprocess.Popen(bat_file_to_run, stdout=subprocess.PIPE)
# process = subprocess.call(bat_file_to_run)
process.wait()
</code></pre>
<p>If I run the script as it is, the .bat file is created but then nothing happens.
I tried to manually double click on it to make sure that it works, and interestingly it doesn't work either. However, if I copy the contents of the .bat file into a new one, and then run that one everything works as I want to.</p>
<p>Have I missed something on the automatic creation on the .bat file that it doesn't like it and nothing runs? I've run this script multiple times and I always get the same result. The automatically created .bat file doesn't do anything, but a new one with the exact same contents does work.</p>
<p>I'll share the .bat file code here as well just as reference.</p>
<pre><code>@echo off
"%deadline_path%"\deadlinecommand -SetJobSetting 636e4b2a518c9b626412f608 JobDependencies 636e3fb4d4682e9cb0790c47,636e3fbf76741b65388982ae,636e3fcc4ad53e99c0426f2a,636e3fd846409c9d10aff124,636e3fe5e740b57ee4e48ef7,636e3ff57883fc8c10294a0b,636e4000f47c7671583bfe1d,636e400b885d6e8970186399,636e40176be6ce9d80ce357c,636e4021b75ec99c8074b34b
</code></pre>
<p>I tried adding a pause at the end to be able to see what's happening, but it doesn't do it either. And like I said, if I create the .bat file manually, it works just as expected.</p>
<p>Thank you for your time. Hopefully someone will be able to point me in the right direction as I don't really know what's happening or why it's happening.</p>
| [
{
"answer_id": 74448654,
"author": "rramirez",
"author_id": 19885876,
"author_profile": "https://Stackoverflow.com/users/19885876",
"pm_score": 0,
"selected": false,
"text": "bat_file = open(project_path + \"\\\\\" + \"create_dependencies.bat\", 'w+')\nbat_file.write(\"@echo off\" + \"\\r\\r\" + command)\nbat_file.close()\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19885876/"
] |
74,429,460 | <p>I want to implement transparent status bar in jetpack compose.</p>
<p>I have integrated the Accompanist library for this but it has no transparent effect on status bar.</p>
<pre><code>implementation "com.google.accompanist:accompanist-systemuicontroller:0.18.0"
// Remember a SystemUiController
val systemUiController = rememberSystemUiController()
val useDarkIcons = !isSystemInDarkTheme()
DisposableEffect(systemUiController, useDarkIcons) {
// Update all of the system bar colors to be transparent, and use
// dark icons if we're in light theme
systemUiController.setStatusBarColor(
color = Color.Transparent,
darkIcons = useDarkIcons
)
// setStatusBarColor() and setNavigationBarColor() also exist
onDispose {}
}
</code></pre>
<p>Tried this as well, but it has problem with the gesture navigation</p>
<pre><code>val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
val insets = WindowCompat.getInsetsController(window, view)
window.statusBarColor = Color.Transparent.toArgb() // choose a status bar color
window.navigationBarColor = Color.Transparent.toArgb() // choose a navigation bar color
insets.isAppearanceLightStatusBars = !useDarkTheme
insets.isAppearanceLightNavigationBars = !useDarkTheme
}
}
</code></pre>
<p>Kindly suggest a better solution for the transparent status bar.</p>
<p><a href="https://i.stack.imgur.com/cMfuT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cMfuT.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74429581,
"author": "Mayur",
"author_id": 7760687,
"author_profile": "https://Stackoverflow.com/users/7760687",
"pm_score": 0,
"selected": false,
"text": "<item name=\"android:windowTranslucentStatus\">true</item>\n<item name=\"android:windowTranslucentNavigation\">true</item>\n"
},
{
"answer_id": 74430798,
"author": "Javlon",
"author_id": 12153321,
"author_profile": "https://Stackoverflow.com/users/12153321",
"pm_score": 2,
"selected": false,
"text": "override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n WindowCompat.setDecorFitsSystemWindows(window, false)\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5989261/"
] |
74,429,469 | <p>I'm trying to understand how child_process works and I don't see any options to pass a variable to the child.
My situation:</p>
<blockquote>
<p>Main.js</p>
</blockquote>
<pre><code>[const arr = [10,20,30,40,50]
for (let g of arr ){
function(g) // I want to launch every loop in a separate process because there are a lot of async functions inside and it takes a lot of time to process.
}
</code></pre>
<blockquote>
<p>First I tried child_process.fork :</p>
</blockquote>
<p><code>//Main.js</code></p>
<pre><code>const { fork } = require('child_process');
const forked = fork('test/child.js');
for (let g of arr){
forked.send(g);
}
</code></pre>
<p><code>//Child.js</code></p>
<pre><code>process.on('message', (msg) => {
console.log('Message from parent:', function(msg));
});
</code></pre>
<p>Child.js received variable g, but the process of the function's execution became much longer than a simple loop.</p>
<blockquote>
<p>Second I tried child_process.execFile</p>
</blockquote>
<p><code>//I made a simple loop from 0 to 5 to see the speed without sending variables</code></p>
<pre><code>for (let i = 0;i< arr.length;i++){
const { execFile } = require('child_process');
const child = execFile('node', ['test/child.js'],
(error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});
}
</code></pre>
<p>Here I got a perfect result. 5 fast and paralleled executions. But as I see there is no way to send this integer from the array to the child.js and other child methods allow only to send arguments for the command line, but not variable? Maybe there are some ways to do it?
Sorry for my confusing text and thanks.</p>
| [
{
"answer_id": 74429581,
"author": "Mayur",
"author_id": 7760687,
"author_profile": "https://Stackoverflow.com/users/7760687",
"pm_score": 0,
"selected": false,
"text": "<item name=\"android:windowTranslucentStatus\">true</item>\n<item name=\"android:windowTranslucentNavigation\">true</item>\n"
},
{
"answer_id": 74430798,
"author": "Javlon",
"author_id": 12153321,
"author_profile": "https://Stackoverflow.com/users/12153321",
"pm_score": 2,
"selected": false,
"text": "override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n WindowCompat.setDecorFitsSystemWindows(window, false)\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19522083/"
] |
74,429,477 | <p>Write a PLSQL function that checks whether the salary of an employee
is less than the average salary of all the employees. If the salary is lees,
the program should update the salary of that employee by 5% of their current salary and print
the old employee salary, the average salary of all the employees, and the new employee
salary after update. Your program should handle all the possible exceptions.
Your output should be formatted as below:</p>
<pre><code>O/P: Old salary is: $510
Avg salary is: $957.05
New salary is: $765
1-Huguette Sandrine: $765
</code></pre>
<pre><code>CREATE OR REPLACE FUNCTION checkEMPsal()
return number
IS
avg_sal number;
BEGIN
select AVG(emp_sal) into avg_sal from employee;
</code></pre>
| [
{
"answer_id": 74429581,
"author": "Mayur",
"author_id": 7760687,
"author_profile": "https://Stackoverflow.com/users/7760687",
"pm_score": 0,
"selected": false,
"text": "<item name=\"android:windowTranslucentStatus\">true</item>\n<item name=\"android:windowTranslucentNavigation\">true</item>\n"
},
{
"answer_id": 74430798,
"author": "Javlon",
"author_id": 12153321,
"author_profile": "https://Stackoverflow.com/users/12153321",
"pm_score": 2,
"selected": false,
"text": "override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n WindowCompat.setDecorFitsSystemWindows(window, false)\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20497770/"
] |
74,429,488 | <p>How can I select all rows/unselect all rows of a WPF datagrid on a button click without messing up the MVVM pattern ?</p>
<p>Currently I doing something like this:</p>
<h1>XAML</h1>
<pre><code><Button Command="{Binding SelButtonClicked}" .../>
</code></pre>
<p>and in the Mainviewmodel</p>
<pre><code>public RelayCommand SelButtonClicked { get; set; }
...
Public Mainviewmodel()
{
SelButtonClicked = new RelayCommand(SelUnsel);
}
...
public void SelUnsel(object param)
{
var win = Application.Current.Windows
.Cast<Window>()
.FirstOrDefault(window => window is MainWindow) as MainWindow;
if (win.myGrid.SelectedItems.Count > 0)
{
win.myGrid.UnselectAll();
}
else
{
win.myGrid.SelectAll();
}
}
</code></pre>
<p>But I'm pretty sure it is not the MVVM way ...</p>
| [
{
"answer_id": 74429581,
"author": "Mayur",
"author_id": 7760687,
"author_profile": "https://Stackoverflow.com/users/7760687",
"pm_score": 0,
"selected": false,
"text": "<item name=\"android:windowTranslucentStatus\">true</item>\n<item name=\"android:windowTranslucentNavigation\">true</item>\n"
},
{
"answer_id": 74430798,
"author": "Javlon",
"author_id": 12153321,
"author_profile": "https://Stackoverflow.com/users/12153321",
"pm_score": 2,
"selected": false,
"text": "override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n WindowCompat.setDecorFitsSystemWindows(window, false)\n}\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6119995/"
] |
74,429,498 | <p>In a Doctrine Collection, I have identical objects, each with an integer property '<code>player</code>' and another integer property called '<code>team</code>'. Player could be <code>1,2,3...</code> and Team can be <code>0,1,2,3,...</code> and so on. <code>0</code> means '<code>default team</code>'. All players belong to the default team first and foremost. A player can then become a member of other teams too. For example, player <code>2</code> can be a member of team <code>0, 2</code> and <code>3</code>.</p>
<p>Now, I would like to get the object where <code>Player 3</code> is a member of <code>Team 2</code>. If not, return the object where <code>Player 3</code> is a member of <code>Team 0</code>.</p>
<p>How would I achieve this?</p>
| [
{
"answer_id": 74438588,
"author": "ceadreak",
"author_id": 3191181,
"author_profile": "https://Stackoverflow.com/users/3191181",
"pm_score": 1,
"selected": false,
"text": "// get all your player 3 data\n$player3Collection = Collection->filter(function(ObjectType $object) {\n return ($object->getPlayer() == 3);\n});\n\n// then filter again or do other stuff ... \nif ($player3Collection->filter(///filter team callback///)->isEmpty() {\n throw new NoTeamException();\n}\n\nif ($player3Collection->count() == 1) {\n return $player3Collection->first(); // default team\n}\n\n// etc ...\n"
},
{
"answer_id": 74456851,
"author": "John Miller",
"author_id": 2078535,
"author_profile": "https://Stackoverflow.com/users/2078535",
"pm_score": 0,
"selected": false,
"text": "$team=2;\n\nreturn $player3Collection\n ->filter(static function(Player $player) use ($team, $player3Collection){\n if($player->team===$team){\n return true;#/Got it\n } elseif($player3Collection->filter(static fn(Player $p) => $p->id===$player->id && $p->team===$team)){\n return false;#/A counterpart Player object with correct team exists in player3Collection, so skip it here.\n } elseif($player->team===0){\n return true;#/Fallback team record\n }\n\n return false;#/Exclude other teams\n });\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2078535/"
] |
74,429,513 | <p>I have an excel here as shown in this picture:</p>
<p><a href="https://i.stack.imgur.com/Q5QTl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q5QTl.png" alt="enter image description here" /></a></p>
<p>I am using pandas to read my excel file and it is working fine, this code below can print all the data in my excel:</p>
<pre><code>import pandas as pd
df = pd.read_csv('alpha.csv')
print(df)
</code></pre>
<p>I want to get the values from C2 cell to H9 cell which month is <strong>October</strong> and day is <strong>Monday</strong> only. And I want to store these values in my python array below:</p>
<pre><code>mynumbers= []
</code></pre>
<p>but I am not sure how should I do it, can you please help me?</p>
| [
{
"answer_id": 74438588,
"author": "ceadreak",
"author_id": 3191181,
"author_profile": "https://Stackoverflow.com/users/3191181",
"pm_score": 1,
"selected": false,
"text": "// get all your player 3 data\n$player3Collection = Collection->filter(function(ObjectType $object) {\n return ($object->getPlayer() == 3);\n});\n\n// then filter again or do other stuff ... \nif ($player3Collection->filter(///filter team callback///)->isEmpty() {\n throw new NoTeamException();\n}\n\nif ($player3Collection->count() == 1) {\n return $player3Collection->first(); // default team\n}\n\n// etc ...\n"
},
{
"answer_id": 74456851,
"author": "John Miller",
"author_id": 2078535,
"author_profile": "https://Stackoverflow.com/users/2078535",
"pm_score": 0,
"selected": false,
"text": "$team=2;\n\nreturn $player3Collection\n ->filter(static function(Player $player) use ($team, $player3Collection){\n if($player->team===$team){\n return true;#/Got it\n } elseif($player3Collection->filter(static fn(Player $p) => $p->id===$player->id && $p->team===$team)){\n return false;#/A counterpart Player object with correct team exists in player3Collection, so skip it here.\n } elseif($player->team===0){\n return true;#/Fallback team record\n }\n\n return false;#/Exclude other teams\n });\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13416645/"
] |
74,429,538 | <p>i know this may be stupid question but how can i access value of object that has '@' in it key</p>
<pre><code>{
id: 'v6y4fra9dd3xxys',
created: '2022-10-29 08:48:12.585',
updated: '2022-11-14 08:03:46.477',
'@collectionId': 'x16irtg922kc0cg',
'@collectionName': 'products',
condition: 'new',
image: 'short4.jpg',
name: 'Short 4',
price: 19000,
productImg: 'short4_iKD5NIhZWX.jpg',
quantity: 1,
type: 'shortboard',
'@expand': {}
}
</code></pre>
<p>i want to use collectionName but don't know how to access it. i try but it got Unexpected character '@' error. what i supposed to do</p>
| [
{
"answer_id": 74429573,
"author": "Moussa Bistami",
"author_id": 15628525,
"author_profile": "https://Stackoverflow.com/users/15628525",
"pm_score": 0,
"selected": false,
"text": "\n try {\n if (Object['@collectionId'])\n //Do whatever with Object['@collectionId'];\n }catch(err){\n console.log(err)\n }\n\n"
},
{
"answer_id": 74429604,
"author": "Jay Vaghasiya",
"author_id": 10562084,
"author_profile": "https://Stackoverflow.com/users/10562084",
"pm_score": -1,
"selected": false,
"text": "obj['@collectionId'] "
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19817113/"
] |
74,429,550 | <p>I have a UTC date-time like this (a String): <code>2022-11-22T17:15:00</code></p>
<p>And a ZoneID like this: <code>"America/Tijuana"</code></p>
<p>Using java.time API, I want to get the actual datetime for that zone, which is: <code>2022-11-22T09:15:00</code> (the time is 09:15 instead of 17:15)</p>
<ul>
<li>ZonedDateTime.toLocalDateTime() returns: <code>2022-11-22T17:15</code></li>
<li>ZonedDateTime.toString() returns:
<code>2022-11-22T17:15-08:00[America/Tijuana]</code></li>
</ul>
<p>None of the above gives me what I'm looking for.</p>
<p>This is my code:</p>
<pre><code> ZoneId zonaID = ZoneId.of('America/Tijuana');
CharSequence dateUTC = "2022-11-22T17:15:00";
LocalDateTime dateTimeL = LocalDateTime.parse(dateUTC);
ZonedDateTime myZDT = ZonedDateTime.now();
ZonedDateTime myZDTFinal = myZDT.of(dateTimeL, zonaID);
System.out.println("using toLocalDateTime: " + myZDTFinal.toLocalDateTime());
System.out.println("using toString: " + myZDTFinal.toString());
</code></pre>
<p>I know that this might be a duplicated question but there's so many questions about date-times and I just haven't been able to figure out this.</p>
<p>Any help will be really appreciated.</p>
| [
{
"answer_id": 74429653,
"author": "YCF_L",
"author_id": 5558072,
"author_profile": "https://Stackoverflow.com/users/5558072",
"pm_score": 3,
"selected": false,
"text": "withZoneSameInstant"
},
{
"answer_id": 74430001,
"author": "Arvind Kumar Avinash",
"author_id": 10819573,
"author_profile": "https://Stackoverflow.com/users/10819573",
"pm_score": 3,
"selected": true,
"text": "LocalDateTime"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2906157/"
] |
74,429,558 | <p>I am executing the following code but getting error</p>
<pre><code>//preparing upload parameters
const params = {
Bucket: `${config.s3bucket}`,
Key: `${objectDirectory}/${objectKey}`,
};
//geenerating signed url, valid only for 15 minutes
const command = new PutObjectCommand(params);
const signedUrl = await getSignedUrl(s3Client, command, {
expiresIn: 900,
});
</code></pre>
<p>Code 2</p>
<pre><code>const bucketParams = {
Bucket: config.s3bucket,
Key: `Profiles/${result.profilePicture}`,
};
const command = new GetObjectCommand(bucketParams);
const urls = await getSignedUrl(s3Client, command, {
expiresIn: 60 * 60 * 168,
});
</code></pre>
<p>Error Message:</p>
<pre><code>{
"message": "TypeError: Cannot read properties of undefined (reading 'sso_session')"
}
</code></pre>
<p>the error occurs whenever I am executing <code>getSignedUrl</code></p>
| [
{
"answer_id": 74429653,
"author": "YCF_L",
"author_id": 5558072,
"author_profile": "https://Stackoverflow.com/users/5558072",
"pm_score": 3,
"selected": false,
"text": "withZoneSameInstant"
},
{
"answer_id": 74430001,
"author": "Arvind Kumar Avinash",
"author_id": 10819573,
"author_profile": "https://Stackoverflow.com/users/10819573",
"pm_score": 3,
"selected": true,
"text": "LocalDateTime"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18087962/"
] |
74,429,635 | <p>Following is the Clojure code:</p>
<pre><code>(reduce (fn [r x] (if (nil? x) r (conj r x)))
[]
[:mouse nil :duck nil :lory nil])
</code></pre>
<p>In REPL, it evaluates to <code>[:mouse :duck :lory]</code>.</p>
<p>My question is, how is the code evaluating?</p>
<p>According to me, <code>r</code> is <code>[]</code> and <code>x</code> is <code>[:mouse nil :duck nil :lory nil]</code>. <code>nil? x</code> is false as so it evaluates to <code>(conj r x)</code>. But x is a vector, not an element so how it will add an element to the empty vector r in <code>conj</code>? I don't know but I am wrong somewhere in my approach. The output is the animals' name vector without nil values.
Can anyone please explain me the execution of code. Thanks.</p>
| [
{
"answer_id": 74430057,
"author": "Thumbnail",
"author_id": 1562315,
"author_profile": "https://Stackoverflow.com/users/1562315",
"pm_score": 2,
"selected": true,
"text": "reduce"
},
{
"answer_id": 74443790,
"author": "user2609980",
"author_id": 2609980,
"author_profile": "https://Stackoverflow.com/users/2609980",
"pm_score": 0,
"selected": false,
"text": "fn"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20499245/"
] |
74,429,665 | <p>I am new to Typescript and trying to use Redux-Toolkit with it in my React application. Here I am trying to create a To Do application with a nested state where each <code>ToDo</code> contains a array of <code>Comment</code>. Here are the interfaces:</p>
<p><code>Comment.ts</code></p>
<pre><code>export interface Comment {
id: number;
comment: string;
}
</code></pre>
<p><code>ToDo.ts</code></p>
<pre><code>export interface ToDo {
id: number;
title: string;
description: string;
comments: Array<Comment>;
}
</code></pre>
<p>Then in my <code>ToDoSlice</code>:</p>
<pre><code>export const toDoSlice = createSlice({
name: 'toDoSlice',
initialState: [] as Array<ToDo>,
reducers: {
addToDo: (state, action: PayloadAction<ToDo> ) => {
state.push(action.payload);
},
}
});
</code></pre>
<p>The TS compiler throws this on the line <code>state.push(action.payload)</code>:</p>
<pre><code>TS2345: Argument of type 'ToDo' is not assignable to parameter of type 'WritableDraft<ToDo>'.
Types of property 'comments' are incompatible.
Type 'Comment[]' is not assignable to type 'WritableDraft<Comment>[]'.
Type 'Comment' is not assignable to type 'WritableDraft<Comment>'.
The types of 'ownerDocument.all' are incompatible between these types.
Type 'HTMLAllCollection' is not assignable to type 'WritableDraft<HTMLAllCollection>'.
'number' index signatures are incompatible.
Type 'Element' is not assignable to type 'WritableDraft<Element>'.
Types of property 'attributes' are incompatible.
Type 'NamedNodeMap' is not assignable to type 'WritableDraft<NamedNodeMap>'.
'number' index signatures are incompatible.
Type 'Attr' is not assignable to type 'WritableDraft<Attr>'.
Types of property 'childNodes' are incompatible.
Type 'NodeListOf<ChildNode>' is not assignable to type 'WritableDraft<NodeListOf<ChildNode>>'.
'number' index signatures are incompatible.
Type 'ChildNode' is not assignable to type 'WritableDraft<ChildNode>'.
Types of property 'parentElement' are incompatible.
Type 'HTMLElement | null' is not assignable to type 'WritableDraft<HTMLElement> | null'.
Type 'HTMLElement' is not assignable to type 'WritableDraft<HTMLElement>'.
Types of property 'shadowRoot' are incompatible.
Type 'ShadowRoot | null' is not assignable to type 'WritableDraft<ShadowRoot> | null'.
Type 'ShadowRoot' is not assignable to type 'WritableDraft<ShadowRoot>'.
Types of property 'adoptedStyleSheets' are incompatible.
Type 'CSSStyleSheet[]' is not assignable to type 'WritableDraft<CSSStyleSheet>[]'.
Type 'CSSStyleSheet' is not assignable to type 'WritableDraft<CSSStyleSheet>'.
Types of property 'ownerNode' are incompatible.
Type 'Element | ProcessingInstruction | null' is not assignable to type 'WritableDraft<Element> | WritableDraft<ProcessingInstruction> | null'.
Type 'ProcessingInstruction' is not assignable to type 'WritableDraft<Element> | WritableDraft<ProcessingInstruction> | null'.
</code></pre>
<hr />
<br>
<p>I tried to cast the <code>action.payload</code> to type <code>WritableDraft<ToDo></code>, and the error does go away.</p>
<pre><code>addToDo: (state, action: PayloadAction<ToDo> ) =>
{state.push(action.payload as WritableDraft<ToDo>);
},
</code></pre>
<p>However, similar problem arises when I try to add a <code>Comment</code> into an existing <code>ToDo</code>:</p>
<pre><code>addComment: (state, action: PayloadAction<{toDoId: number, comment: Comment}>) => {
const toDo = state.find(toDo => toDo.id === action.payload.toDoId);
if (toDo) {
toDo.comments.push(action.payload.comment);
}
}
</code></pre>
<p>where it gives another error:</p>
<pre><code>Argument of type 'Comment' is not assignable to parameter of type 'WritableDraft<Comment>'.
Type 'Comment' is missing the following properties from type 'WritableDraft<Comment>': data, length, ownerDocument, appendData, and 59 more.
</code></pre>
<p>and casting <code>action.payload.comment as WritableDraft<Comment></code> won't do. The error almost remains the same.</p>
<hr />
<br>
<p>The version of the dependencies inside of the <code>package.json</code>:</p>
<pre class="lang-json prettyprint-override"><code>"dependencies": {
"@reduxjs/toolkit": "^1.9.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^13.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-router-dom": "^6.4.3",
"react-scripts": "5.0.1",
"typescript": "^4.4.2",
"web-vitals": "^2.1.0"
},
</code></pre>
| [
{
"answer_id": 74431634,
"author": "paria",
"author_id": 17815399,
"author_profile": "https://Stackoverflow.com/users/17815399",
"pm_score": 0,
"selected": false,
"text": "reducers: {\n addToDo: (state, action: PayloadAction<ToDo> ) => {\n state.push(action.payload as ToDo);\n },\n"
},
{
"answer_id": 74446269,
"author": "Muhammad Nouman Rafique",
"author_id": 19932999,
"author_profile": "https://Stackoverflow.com/users/19932999",
"pm_score": 2,
"selected": true,
"text": "ToDo.ts"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14033758/"
] |
74,429,686 | <p>This question was asked to me in Razorpay. I could not come up with a solution. Can anyone help me in writing Java code for this.</p>
<pre class="lang-java prettyprint-override"><code>Object[] array = { 1, 2, new Object[]{ 3, 4, new Object[]{ 5 }, 6, 7 }, 8, 9, 10};
</code></pre>
<p>Answer should be:</p>
<pre class="lang-java prettyprint-override"><code>Integer[] = {1,2,3,4,5,6,7,8,9,10};
</code></pre>
<p>i.e. all the Integer elements should be stored</p>
<p>What I did is</p>
<pre><code>for(Object obj: array){
if(obj instanceof Integer) list.add((int)(obj));
}
</code></pre>
<p>Which results in -> 1,2,8,9,10. How do I add 3,4,5,6,7 inside list?</p>
| [
{
"answer_id": 74429917,
"author": "tgdavies",
"author_id": 11002,
"author_profile": "https://Stackoverflow.com/users/11002",
"pm_score": 1,
"selected": false,
"text": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class Answer {\n static void extractIntegers(Object[] source, List<Integer> destination) {\n for (Object i : source) {\n if (i instanceof Object[] array) {\n extractIntegers(array, destination);\n } else if (i instanceof Integer integer) {\n destination.add(integer);\n } else {\n throw new IllegalArgumentException(\"Unexpected: \" + i);\n }\n }\n }\n\n public static void main(String[] args) {\n List<Integer> ints = new ArrayList<>();\n Object[] array = { 1, 2, new Object[]{ 3, 4, new Object[]{ 5 }, 6, 7 }, 8, 9, 10};\n extractIntegers(array, ints);\n System.out.println(ints);\n }\n}\n"
},
{
"answer_id": 74429932,
"author": "AdmiJW",
"author_id": 14033758,
"author_profile": "https://Stackoverflow.com/users/14033758",
"pm_score": 1,
"selected": false,
"text": "Object"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20499295/"
] |
74,429,701 | <p>I'm currently building a program in JavaScript that is making requests of the google sheets API based on activity occurring in a Discord Server (messaging app). However, I've been running into the API RateLimits in cases where multiple users do the same action at the same time, causing too many API Requests in too short of a time.</p>
<p>My idea to get around this is to implement a parallel queue of async function calls, so that whenever I want to make a request of the google API, I queue that function call, and another function or thread or <em>something</em> will keep checking this queue and if there is a function available, it will run that function, wait a little bit, and then check the queue again, and so on.</p>
<p>I'm struggling to figure out how to do this in regular asynchronous (async/await) programming. I've been referring to the following posts/pages, but they all seem focused on a predefined queue that is then dequeued in order - I want to be able to keep adding to the queue even after the functions have started being run.
<a href="https://stackoverflow.com/questions/899102/how-do-i-store-javascript-functions-in-a-queue-for-them-to-be-executed-eventuall">How do I store javascript functions in a queue for them to be executed eventually</a>
<a href="https://stackoverflow.com/questions/17528749/semaphore-like-queue-in-javascript/17528961#17528961">Semaphore-like queue in javascript?</a>
<a href="https://www.codementor.io/@edafeadjekeemunotor/building-a-concurrent-promise-queue-with-javascript-1ano2eof0v" rel="nofollow noreferrer">https://www.codementor.io/@edafeadjekeemunotor/building-a-concurrent-promise-queue-with-javascript-1ano2eof0v</a></p>
<p>Any help or guidance would be very appreciated, thank you!</p>
| [
{
"answer_id": 74429917,
"author": "tgdavies",
"author_id": 11002,
"author_profile": "https://Stackoverflow.com/users/11002",
"pm_score": 1,
"selected": false,
"text": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class Answer {\n static void extractIntegers(Object[] source, List<Integer> destination) {\n for (Object i : source) {\n if (i instanceof Object[] array) {\n extractIntegers(array, destination);\n } else if (i instanceof Integer integer) {\n destination.add(integer);\n } else {\n throw new IllegalArgumentException(\"Unexpected: \" + i);\n }\n }\n }\n\n public static void main(String[] args) {\n List<Integer> ints = new ArrayList<>();\n Object[] array = { 1, 2, new Object[]{ 3, 4, new Object[]{ 5 }, 6, 7 }, 8, 9, 10};\n extractIntegers(array, ints);\n System.out.println(ints);\n }\n}\n"
},
{
"answer_id": 74429932,
"author": "AdmiJW",
"author_id": 14033758,
"author_profile": "https://Stackoverflow.com/users/14033758",
"pm_score": 1,
"selected": false,
"text": "Object"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14579133/"
] |
74,429,721 | <p>Hey guys so I am trying to resize my tkinter window using the geometry function if the master window.</p>
<p>I am able to resize it when I tried to do that without creating a class.</p>
<p>But when I tried to resize the window made by the class method I came across a method where the master was resized before passing it as a parameter in the class initialization.</p>
<p>But when I tried to do that without passing the master without passing it as a parameter my interpreter crashes.</p>
<p>What I want to know is what I am doing is it correct?</p>
<p>If not please help me understand why is the interpreter crashing.</p>
<p>Here is the code that I Tried to run.</p>
<pre><code>class App(Tk):
def __init__(self):
self.geometry('300x300')
#self.tk.Tk.geometry('300x300') Tried this but it didn't do anything.
Label(text='Post Navigation Button').grid(row=0,column=0)
self.listbox = Listbox(selectmode='multiple',height=len(x))
for each_item in range(len(x)):
self.listbox.insert(END, x[each_item])
self.listbox.itemconfig(each_item, bg = "lime")
self.listbox.grid(row=0,column=1)
self.tag = Text(height=1,width=100)
self.tag.grid(row=0,column=2)
Button(text='click me',command=self.submit).place(x=500,y=50)
def submit(self):
text = self.tag.get('0.0',END)
selection = [self.listbox.get(i) for i in self.listbox.curselection()]
print(text.strip(),','.join(selection))
app = App()
mainloop()
</code></pre>
<p>I don't want to create a master and pass it as a parameter like this.</p>
<pre><code>root = tk.Tk()
root.geometry('300x300')
app = App(root)
mainloop()
</code></pre>
<p>So I just want to know the way to resize the the window from inside the class.</p>
<p>I don't know how correct my code is. So any help is welcome.</p>
| [
{
"answer_id": 74429928,
"author": "Martin Wettstein",
"author_id": 13969611,
"author_profile": "https://Stackoverflow.com/users/13969611",
"pm_score": -1,
"selected": false,
"text": "def __init__(self):\n top=self.winfo_toplevel() #Flexible Toplevel of the window\n top.geometry(\"300x300\")\n"
},
{
"answer_id": 74429977,
"author": "mnikley",
"author_id": 12892026,
"author_profile": "https://Stackoverflow.com/users/12892026",
"pm_score": 2,
"selected": false,
"text": "Tk"
},
{
"answer_id": 74430498,
"author": "toyota Supra",
"author_id": 4136999,
"author_profile": "https://Stackoverflow.com/users/4136999",
"pm_score": 0,
"selected": false,
"text": "super().__init__()"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6088792/"
] |
74,429,726 | <p>I found this that seems exactly what I'm looking for if it worked with ";" instead of "," but I can't get it to work. Is it possible?
<a href="https://stackoverflow.com/a/48551211/20499116">https://stackoverflow.com/a/48551211/20499116</a></p>
<p>The data I'm working with gives me an email column with somewhere between 1 to 10 email separated by a Semi-colons.</p>
<p>Really appreciate any help.</p>
<p>I tried amending</p>
<pre><code>=if(countif(arrayformula(ISEMAIL(split(A1,","))),False)>0,False,TRUE)
</code></pre>
<p>to</p>
<pre><code>=if(countif(arrayformula(ISEMAIL(split(A1,";"))),False)>0,False,TRUE)
</code></pre>
| [
{
"answer_id": 74429928,
"author": "Martin Wettstein",
"author_id": 13969611,
"author_profile": "https://Stackoverflow.com/users/13969611",
"pm_score": -1,
"selected": false,
"text": "def __init__(self):\n top=self.winfo_toplevel() #Flexible Toplevel of the window\n top.geometry(\"300x300\")\n"
},
{
"answer_id": 74429977,
"author": "mnikley",
"author_id": 12892026,
"author_profile": "https://Stackoverflow.com/users/12892026",
"pm_score": 2,
"selected": false,
"text": "Tk"
},
{
"answer_id": 74430498,
"author": "toyota Supra",
"author_id": 4136999,
"author_profile": "https://Stackoverflow.com/users/4136999",
"pm_score": 0,
"selected": false,
"text": "super().__init__()"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20499116/"
] |
74,429,952 | <p>I have the following Pd series</p>
<pre><code> count area volume formula quantity
0 1.0 22 NaN count 1.0
1 1.0 15 NaN count 1.0
2 1.0 1.4 NaN area 1.4
3 1.0 0.6 10 volume 100
</code></pre>
<p>The quantity column is based on the value in the formula column via a lookup e.g. row(0) is "count" so it is 1, row(2) is "area" so it's 1.4</p>
<p>For this I have a the following formula</p>
<pre><code>Merged['quantity']=Merged.apply(lambda x: x[x['QuantityFormula']] , axis=1)
</code></pre>
<p>However quantity for volume is a calculated field: volume * 10. I've written a function to calculate both</p>
<pre><code>def func(x):
if x[x['QuantityFormula']] == Volume:
return volume * 10
else:
return x[x['QuantityFormula']]
df['Classification'] = Merged['QuantityFormula'].apply(func)
</code></pre>
<p>However I get the following error</p>
<pre><code>Error: string indices must be integers
</code></pre>
<p>Any ideas? Thanks</p>
<p>Answer</p>
<pre><code>def func(row):
if row['QuantityFormula'] == 'Volume':
return row['Volume'] * 10
return row[row['quantity']]
Merged['Ans'] = Merged.apply(func, axis=1)
</code></pre>
| [
{
"answer_id": 74430136,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 0,
"selected": false,
"text": "import numpy as np\n\ns = df['formula'].str.lower()\nm = s.eq('volume')\n\nidx, cols = pd.factorize(s)\n\ndf['quantity'] = (df.reindex(cols, axis=1).to_numpy()[np.arange(len(df)), idx]\n * np.where(m, 10, 1)\n )\n"
},
{
"answer_id": 74430187,
"author": "YOLO",
"author_id": 9299259,
"author_profile": "https://Stackoverflow.com/users/9299259",
"pm_score": 2,
"selected": true,
"text": "df.apply(lambda x: x['volume']*10 if x['formula'] == 'volume' else x['quantity'], axis=1)\n\nprint(df)\n\n count area volume formula quantity ans\n0 1.0 22.0 NaN count 1.0 1.0\n1 1.0 15.0 NaN count 1.0 1.0\n2 1.0 1.4 NaN area 1.4 1.4\n3 1.0 0.6 10.0 volume 100.0 100.0\n"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20479479/"
] |
74,429,956 | <p>I'm confused on how do I add a column to another in pandas</p>
<p>Here is what I'm trying to do :</p>
<pre><code>from pandas import DataFrame
df1 = DataFrame({'a':[1,2], 'b':[3,4]})
concat((df1['a'], df1['b'].rename({'b':'a'}))).reset_index(drop=True)
</code></pre>
<p>Which do return what I want : A serie with my 4 values. What I don't understand is : Why I can't assign it to column 'a' ?</p>
<pre><code>>>> from pandas import DataFrame
>>> df1 = DataFrame({'a':[1,2], 'b':[3,4]})
>>> concat((df1['a'], df1['b'].rename({'b':'a'}))).reset_index(drop=True)
0 1
1 2
2 3
3 4
dtype: int64
>>> df1['a'] = concat((df1['a'], df1['b'].rename({'b':'a'}))).reset_index(drop=True)
>>> df1
a b
0 1 3
1 2 4
</code></pre>
<p>Is there any way to make it more readable by the way? I'm confused on how it should worked... Note that I don't need column 'b' afterward.</p>
<p>Thanks for your help :)</p>
<p>Sam</p>
| [
{
"answer_id": 74429997,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "pd.concat((df1['a'], df1['b'].rename({'b':'a'}))).reset_index(drop=True)\n"
},
{
"answer_id": 74430112,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 3,
"selected": true,
"text": "pandas series"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2086127/"
] |
74,429,998 | <p>I wanted to declare an array with a pointer in character type, and the length of the array can be determined by my input string.</p>
<p>I wrote it in this way:</p>
<pre class="lang-cpp prettyprint-override"><code>char *s;
cout << "Enter a string: " << endl;
cin >> s;
</code></pre>
<p>I expected that I can initialize the string by the <code>cin</code> operation, but an error showed up when compiling. The error is about "invalid operands to binary expression".</p>
<p>I'm not sure why the lines I wrote was wrong.
I though not only the built in <code>string</code> class is used for declaring an array.</p>
<p>Isn't the <code>string</code> data type in C++ the same as "a character array"?</p>
<p>Isn't the line <code>char *s</code> means the pointer <code>s</code> points to an character array (or string)?</p>
<p>Thank you!</p>
| [
{
"answer_id": 74430072,
"author": "StellarClown",
"author_id": 10026471,
"author_profile": "https://Stackoverflow.com/users/10026471",
"pm_score": 0,
"selected": false,
"text": "char *s = new char[10];\n"
},
{
"answer_id": 74430207,
"author": "wohlstad",
"author_id": 18519921,
"author_profile": "https://Stackoverflow.com/users/18519921",
"pm_score": 3,
"selected": true,
"text": "std::string"
},
{
"answer_id": 74430213,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 1,
"selected": false,
"text": "cin"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74429998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17754131/"
] |
74,430,017 | <p>For my accessibility related question, I googled "accessibility shopping cart" and visited many popular online stores but didn't find a clear answer on my question. From the accessibility point of view, for the shopping cart, should I add a tabindex="0" (the code is slightly simplified) for</p>
<pre><code><ul>
<li><span tabindex="0">Merchandise: $40</span></li>
<li><span tabindex="0">Shipping: $10</span></li>
<li><span tabindex="0">Taxes: $0.40</span></li>
<li><span tabindex="0">Total: $50.40</span></li>
</ul>
</code></pre>
<p>or simply</p>
<pre><code><ul>
<li><span>Merchandise: $40</span></li>
<li><span>Shipping: $10</span></li>
<li><span>Taxes: $0.40</span></li>
<li><span>Total: $50.40</span></li>
</ul>
</code></pre>
<p>, or separate merchandise and $40 as</p>
<pre><code><li><span tabindex="0">Merchandise</span>: <span tabindex="0">$40</span></li>
</code></pre>
<p>, or even add (if Twitter Bootstrap is used with its <code>sr-only</code> class)</p>
<pre><code><li><span tabindex="0">Merchandise</span>:
<span tabindex="0">
<span aria-hidden="true">$</span>40<span class="sr-only"> American dollars</span>
</span>
</li>
</code></pre>
| [
{
"answer_id": 74432244,
"author": "Glen Stautland",
"author_id": 17611060,
"author_profile": "https://Stackoverflow.com/users/17611060",
"pm_score": 1,
"selected": false,
"text": "<ul> or <ol>"
},
{
"answer_id": 74446356,
"author": "Alejandro Suárez",
"author_id": 17751007,
"author_profile": "https://Stackoverflow.com/users/17751007",
"pm_score": 1,
"selected": false,
"text": "tabindex=\"0\""
},
{
"answer_id": 74617365,
"author": "Andy",
"author_id": 608042,
"author_profile": "https://Stackoverflow.com/users/608042",
"pm_score": 1,
"selected": false,
"text": "tabindex"
}
] | 2022/11/14 | [
"https://Stackoverflow.com/questions/74430017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/886906/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.