qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,120,082
<p>I have one function <code>funA</code> on component A, <code>ComponentA</code> and another component B, <code>componentB</code>. Now, I want to <code>ComponentB</code> to use this same function, <code>funA</code>.</p> <p>How can I share this <code>funA</code> to <code>ComponentB</code>?</p> <p>I was thinking about <code>redux</code>, but redux doesn't suggest passing a non-serializable value, like a function, to a state.</p> <p>What's the solution for this?</p> <p>Edit: the <code>funA</code> persisting some states of <code>componentA</code>, I want to keeping these states when using on <code>componentB</code>. I was trying to create a custom hook, however the hook is a individual closure for each time call the hook, which means I cannot hold the state.</p> <p>Edit: I have created a custom hook, but it's not working, maybe I should include some codes.</p> <p>On my custom hook:</p> <pre><code>const useActionsHook = () =&gt; { const [action, setAction] = useState([]) const addAction = (actionNew) =&gt; { setAction(prev=&gt;[...prev, actionNew]) } const getActions = () =&gt; { return action } return { getActions, addAction } } </code></pre> <p>In ComponentA, I call <code>const {addAction} = useActionsHook</code> then save the action. And on ComponentB, I call <code>const {getActions} = useActionsHook</code> then to get actions, but that <code>getActions</code> value is still the empty array.</p>
[ { "answer_id": 74120125, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": "// fun-a.js\nexport function funA () {\n return \"woo\";\n}\n" }, { "answer_id": 74123435, "author": "Dmitriy...
2022/10/19
[ "https://Stackoverflow.com/questions/74120082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14397986/" ]
74,120,130
<p>I'd like to use a protocol as an interface but I'm having trouble working it out in Swift. Can someone make sense of this error and point me in the right direction?</p> <p>Maybe I'm thinking of protocols in a completely improper way.</p> <p>Here is sample code:</p> <pre class="lang-swift prettyprint-override"><code>protocol State { associatedtype U: State static func fromString(_: String) -&gt; U } class ConcreteState1: State { static func fromString(_ value: String) -&gt; ConcreteState1 { return ConcreteState1() } } protocol Loader { associatedtype T: State func load(completion: (Result&lt;T.U, Error&gt;) -&gt; Void) } extension Loader { func load(completion: (Result&lt;T.U, Error&gt;) -&gt; Void) { let value = T.fromString(&quot;&quot;) completion(.success(value)) } } class ConcreteState1Loader: Loader { typealias T = ConcreteState1 } // Abstraction to deal with various types of state var mainState: (any State)? // Needs to be an abstraction using the protocol because the specific loader is injected // This is just a simplified reproduction of the issue var loader: any Loader = ConcreteState1Loader() // ERROR: Member 'load' cannot be used on value of type 'any Loader'; consider using a generic constraint instead loader.load { result in if let state = try? result.get() { mainState = state } } </code></pre>
[ { "answer_id": 74120125, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": "// fun-a.js\nexport function funA () {\n return \"woo\";\n}\n" }, { "answer_id": 74123435, "author": "Dmitriy...
2022/10/19
[ "https://Stackoverflow.com/questions/74120130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/174507/" ]
74,120,133
<p>I have this text file and I want to exclude the word &quot;access&quot; because a is followed by a, b or c at second, third or forth position.</p> <pre><code># cat tt.txt access ample taxing </code></pre> <p>I tried this, but it returns all 3 words.</p> <pre><code># grep '[a-c][^a-c][^a-c][^a-c]' tt.txt access ample taxing </code></pre> <hr /> <p>Update 1:</p> <p>I used over-simplified example above.</p> <pre><code># cat tt.txt access bccess ample taxing tacking not # grep -Ev '[a-c].{0,2}[a-c]' tt.txt ample taxing not # grep -E '[a-c].{0,2}[^a-c]' tt.txt access bccess ample taxing tacking # Expected ample taxing </code></pre>
[ { "answer_id": 74120329, "author": "anubhava", "author_id": 548225, "author_profile": "https://Stackoverflow.com/users/548225", "pm_score": 3, "selected": true, "text": "access" }, { "answer_id": 74200540, "author": "TLP", "author_id": 725418, "author_profile": "https...
2022/10/19
[ "https://Stackoverflow.com/questions/74120133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/139150/" ]
74,120,165
<p>The list in C# can be traversed by for, but is there a special reason why Dictionary can be referred to as a[0] with a declaration of &lt;int, int&gt; type, but not for for, but only with foreach? And why can the List be toured with the for repeat statement?</p>
[ { "answer_id": 74120256, "author": "jmcilhinney", "author_id": 584183, "author_profile": "https://Stackoverflow.com/users/584183", "pm_score": 1, "selected": false, "text": "List" }, { "answer_id": 74120303, "author": "ProgrammingLlama", "author_id": 3181933, "author_...
2022/10/19
[ "https://Stackoverflow.com/questions/74120165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20253261/" ]
74,120,182
<p>I have an extra field in a django form that triggers javascript to change the fields in other forms:</p> <pre><code>class MyForm(forms.ModelForm): my_extra_form_field = forms.ChoiceField() class Meta: model = MyModel fields = [&quot;field1&quot;, &quot;field2&quot;] field_order = [&quot;field1&quot;, &quot;my_extra_form_field&quot;, &quot;field2&quot;] </code></pre> <p>How can I ensure that <code>my_extra_form_field</code> is not included in the submiteed form?</p>
[ { "answer_id": 74120256, "author": "jmcilhinney", "author_id": 584183, "author_profile": "https://Stackoverflow.com/users/584183", "pm_score": 1, "selected": false, "text": "List" }, { "answer_id": 74120303, "author": "ProgrammingLlama", "author_id": 3181933, "author_...
2022/10/19
[ "https://Stackoverflow.com/questions/74120182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19936284/" ]
74,120,199
<p>I have an asp.net web app to send emails, and I have tried to send an html file template. I can send my file, but the images from the template dont load on the message sent!</p> <pre><code>public void SendEmail(string EmailAddress) { try { MailMessage mail = new MailMessage(); mail.To.Add(EmailAddress); mail.From = new MailAddress(&quot;myemail@gmail.com&quot;); mail.Subject = txtSubject.Text; string FilePath = Server.MapPath(&quot;templateHtml.html&quot;); StreamReader str = new StreamReader(FilePath); string body = str.ReadToEnd(); //string body = Server.HtmlEncode(str.ReadToEnd()); mail.IsBodyHtml = true; mail.Body = body; SmtpClient smtp = new SmtpClient(); smtp.Host = smtpClient; smtp.Credentials = new NetworkCredential(email, password); smtp.EnableSsl = true; smtp.Send(mail); str.Close(); Response.Write(&quot;ok!&quot;) } catch { Response.Write(&quot;so bad&quot;); } } </code></pre> <p>...</p> <p>My htmltemplate is like:</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot; /&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;br /&gt; &lt;p&gt;This is an image&lt;/p&gt; &lt;img src=&quot;Images/image1.jpg&quot;&gt; &lt;p&gt;This is an image&lt;/p&gt; &lt;img src=&quot;http://localhost:1114/WebBody/Images/image2.jpg&quot;&gt; &lt;p&gt;image from net&lt;/p&gt; &lt;img src=&quot;https://cdn.mos.cms.futurecdn.net/FVqUjfbiHS9imyJiRiM53-970-80.jpg.webp&quot; width=&quot;40%&quot;&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>... When I send this html file, just the last image is loaded.</p> <p>Any ideas?</p>
[ { "answer_id": 74120291, "author": "Xinran Shen", "author_id": 17438579, "author_profile": "https://Stackoverflow.com/users/17438579", "pm_score": 1, "selected": true, "text": "transcoding website" }, { "answer_id": 74120292, "author": "Tut", "author_id": 10881959, "a...
2022/10/19
[ "https://Stackoverflow.com/questions/74120199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20267796/" ]
74,120,204
<p>Consider this situation: (undirected graph) we dont have number of nodes but have the edges like 1&lt;-&gt;3 , 6&lt;-&gt;7, 3&lt;-&gt;7. So how do we declare a graph using this?</p> <p>Generally we have n that is no. of node and e edges but in this case we only have e edges and that too not continuous i.e. instead of 1,2,3,4(or zero indexed) we have 1,3,6,7. I know we should use a map to convert these 1,3,6,7 values to 1,2,3,4 but how?</p> <p>how we generally declare a graph</p> <pre><code>vector&lt;int&gt; adj[100000]; for(int i=0;i&lt;e;i++) { int u,v; cin&gt;&gt;u&gt;&gt;v; //need some mapping technique here to make this continuous adj[u].push_back(v); adj[v].push_back(u); } //iterate according to situation </code></pre>
[ { "answer_id": 74120291, "author": "Xinran Shen", "author_id": 17438579, "author_profile": "https://Stackoverflow.com/users/17438579", "pm_score": 1, "selected": true, "text": "transcoding website" }, { "answer_id": 74120292, "author": "Tut", "author_id": 10881959, "a...
2022/10/19
[ "https://Stackoverflow.com/questions/74120204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14718204/" ]
74,120,217
<p>I have implemented a CSS-based sticky header using CSS like</p> <pre><code>nav { position: sticky; top: 0; } </code></pre> <p>I implemented it just find this page in edcint.co.nz/public/data/scenery (copy and paste this link otherwise it will load a blank page)</p> <p>But in a related page, that uses a lot of the same code and css (same lazy loading and infinite scroll), the header seems to come and go as you scroll down the page. Once you reach the bottom of page (lazy loading and infinite scroll are in play here - but same as on the page that works ok), then the header works ok. <a href="https://www.edcint.co.nz/cgi-bin/webalbum_search.cgi?searchterms=.&amp;mode=search&amp;searchfile=.webalbum_search_data_public.conf_2&amp;albumtophtmldir=%2Fpublic%2Fdata%2F&amp;resultnumber=0&amp;linkback=%2Fpublic%2Fdata%2Findex.shtml&amp;modtime=0&amp;shortform=n&amp;submit=&amp;approxsearch=1&amp;showimages=1&amp;showvideos=1&amp;showfolders=1&amp;showwithcomments=1&amp;showwithnocomments=1&amp;imageheight=200&amp;displayimageinfo=1&amp;maxresults=10&amp;modtimedays=0&amp;ssdelay=15" rel="nofollow noreferrer">Intermittent Page Sample</a></p> <p>I can't work out why it does not work. None of the parent items have overflow set etc</p> <p>Any ideas?</p>
[ { "answer_id": 74120291, "author": "Xinran Shen", "author_id": 17438579, "author_profile": "https://Stackoverflow.com/users/17438579", "pm_score": 1, "selected": true, "text": "transcoding website" }, { "answer_id": 74120292, "author": "Tut", "author_id": 10881959, "a...
2022/10/19
[ "https://Stackoverflow.com/questions/74120217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3421823/" ]
74,120,238
<p>I have a very long line in SAS coding because there are so many variables that needed to include. How to make a turn to shorten the line and wrap to another line in SAS?</p>
[ { "answer_id": 74120291, "author": "Xinran Shen", "author_id": 17438579, "author_profile": "https://Stackoverflow.com/users/17438579", "pm_score": 1, "selected": true, "text": "transcoding website" }, { "answer_id": 74120292, "author": "Tut", "author_id": 10881959, "a...
2022/10/19
[ "https://Stackoverflow.com/questions/74120238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20278900/" ]
74,120,259
<pre><code>from collections import defaultdict d=defaultdict(list) d['A']=[('a',20,30), ('b', 13, 1)] d['B']=[('c',2,1), ('b', 3, 21)] for k, v in d.items(): d[k] = sorted(v, key=lambda tup: (tup[1], tup[2]), reverse=True) print(d) defaultdict(&lt;class 'list'&gt;, {'A': [('a', 20, 30), ('b', 13, 1)], 'B': [('b', 3, 21), ('c', 2, 1)]}) </code></pre> <p>I want it to be sorted based on the 2nd and 3rd value of the list in reverse order. But the result is wrong. For example, For 'A' it should be:</p> <pre><code>'A' = ('a', 30, 20) </code></pre> <p>EDIT:</p> <p>Sorry. My original solution is what I want and I am confused.</p>
[ { "answer_id": 74120431, "author": "Julien", "author_id": 4565947, "author_profile": "https://Stackoverflow.com/users/4565947", "pm_score": 0, "selected": false, "text": "def my_reverse(tup):\n return (tup[0],) + tup[:0:-1]\nfor k, v in d.items():\n d[k] = sorted(map(my_reverse, v)...
2022/10/19
[ "https://Stackoverflow.com/questions/74120259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3943868/" ]
74,120,275
<p>How do I remove the comma after the number 19?</p> <pre><code>class Main { public static void main(String[] args) { int numbers[] = {23, 79, 41, 68, 17, 39, 51, 75, 95, 19}; System.out.print(&quot;Integer values: &quot;); for(int i = 0; i &lt; numbers.length; i++){ System.out.print(numbers[i] + &quot;,&quot;); } int smallestNumber = numbers[0]; for(int i = 0; i &lt; numbers.length; i++){ if (numbers[i] &lt; smallestNumber){ smallestNumber = numbers[i]; } } System.out.println(&quot;\nSmallest integer: &quot; + smallestNumber); } } </code></pre> <p>This is how it looks like after its run</p> <pre class="lang-none prettyprint-override"><code>Integer values: 23,79,41,68,17,39,51,75,95,19, Smallest integer: 17 </code></pre> <p>This is how I want it to look</p> <pre class="lang-none prettyprint-override"><code>Integer values: 23,79,41,68,17,39,51,75,95,19 Smallest integer: 17 </code></pre>
[ { "answer_id": 74120319, "author": "Zahid Khan", "author_id": 6073148, "author_profile": "https://Stackoverflow.com/users/6073148", "pm_score": 1, "selected": false, "text": "," }, { "answer_id": 74120343, "author": "m.antkowicz", "author_id": 4153426, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20217226/" ]
74,120,289
<p>I have started learning React and redux and I created a simple login application using redux.</p> <p>The reducer is not being called. I get an error in console.</p> <p><a href="https://i.stack.imgur.com/I3ywL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I3ywL.png" alt="enter image description here" /></a></p> <p>I tried to create a <a href="https://stackblitz.com/edit/react-4tbkdu?file=src/components/Login.js" rel="nofollow noreferrer">stackblitz</a> but react is not working in it. The stackblitz has all the code same as my application.</p> <p>Could somebody have a look and tell me my mistake.</p> <p>Thanks Shruti Nair</p>
[ { "answer_id": 74120319, "author": "Zahid Khan", "author_id": 6073148, "author_profile": "https://Stackoverflow.com/users/6073148", "pm_score": 1, "selected": false, "text": "," }, { "answer_id": 74120343, "author": "m.antkowicz", "author_id": 4153426, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215485/" ]
74,120,298
<p>I have difficulty breaking a class consisting of one method into smaller methods. I have a simple socket class that Initiate, send and receive a message in one step (one method). Now I would like to divide this into separate steps of Initialization, Send, Receive, and End as below. I have tried so many different combinations but I could not get it working.</p> <p>My program that works fine:</p> <pre><code>using System; using System.Net; using System.Net.Sockets; using System.Text; using System.IO; namespace SocketCom { internal class Program { public class SyncSocketClient { public static void StartClient() \\&lt;&lt;----------- { byte[] bytes = new byte[1024]; var hostName = Dns.GetHostName(); IPHostEntry ipHost = Dns.GetHostEntry(hostName); IPAddress ip = ipHost.AddressList[1]; IPEndPoint remoteEP = new IPEndPoint(ip, 11111); Socket sender = new Socket(ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp); sender.Connect(remoteEP); sender.RemoteEndPoint.ToString(); byte[] msg = Encoding.ASCII.GetBytes(&quot;Hello&quot;); int byteSent = sender.Send(msg); int byteReceived = sender.Receive(msg); Console.WriteLine($&quot;[ECHO TEST] {Encoding.ASCII.GetString(bytes, 0, byteReceived)}&quot;); sender.Shutdown(SocketShutdown.Both); sender.Close(); } } static void Main(string[] args) { SyncSocketClient.StartClient(); } } } </code></pre> <p>What I would like to below (not working). I do not care about the access modifier or being static or not. I just want to break one method into three separate methods in any possible way.</p> <pre><code>using System; using System.Net; using System.Net.Sockets; using System.Text; using System.IO; namespace SocketCom { internal class Program { public class SyncSocketClient { public static void StartClient()\\&lt;&lt;----------- { byte[] bytes = new byte[1024]; var hostName = Dns.GetHostName(); IPHostEntry ipHost = Dns.GetHostEntry(hostName); IPAddress ip = ipHost.AddressList[1]; IPEndPoint remoteEP = new IPEndPoint(ip, 11111); Socket sender = new Socket(ip.AddressFamily, SocketType.Stream, ProtocolType.Tcp); sender.Connect(remoteEP); } public static void Send(string message)\\&lt;&lt;----------- { sender.RemoteEndPoint.ToString(); byte[] msg = Encoding.ASCII.GetBytes(message); int byteSent = sender.Send(msg); } public static void Receive()\\&lt;&lt;----------- { int byteReceived = sender.Receive(msg); Console.WriteLine($&quot;[ECHO TEST] {Encoding.ASCII.GetString(bytes, 0, byteReceived)}&quot;); } public static void EndClient()\\&lt;&lt;----------- { sender.Shutdown(SocketShutdown.Both); sender.Close(); } } static void Main(string[] args) { SyncSocketClient.StartClient(); SyncSocketClient.StartClient(&quot;Hello&quot;); SyncSocketClient.Receive(); SyncSocketClient.EndClient(); } } } </code></pre> <p>I appreciate your help.</p>
[ { "answer_id": 74122224, "author": "madmonk46", "author_id": 9796331, "author_profile": "https://Stackoverflow.com/users/9796331", "pm_score": 1, "selected": true, "text": "sender" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74120298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279091/" ]
74,120,308
<p>I have a step buttons where they need to occupy the entire top page no matter how many they are like</p> <p><a href="https://i.stack.imgur.com/crHsG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/crHsG.png" alt="enter image description here" /></a></p> <p>But my buttons are not stretching the whole page</p> <p><a href="https://i.stack.imgur.com/1YiLa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1YiLa.png" alt="enter image description here" /></a> My code is here:</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-html lang-html prettyprint-override"><code>&lt;style&gt; .carousel-indicators { display: flex!important; position: inherit!important; justify-content: space-between!important; } .carousel-indicators .active { border-bottom: blue 5px solid!important; } .page{ width:200px!important; height:50px!important; background:#efefef!important; margin:10px!important; } &lt;/style&gt; &lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous"&gt; &lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;div class="accordion" id="accordionExample"&gt; &lt;div class="accordion-item"&gt; &lt;h2 class="accordion-header" id="headingOne"&gt; &lt;button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne"&gt; &lt;input class="workflowTitle" value="Accordion Item #1" /&gt; &lt;/button&gt; &lt;/h2&gt; &lt;div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample"&gt; &lt;div class="accordion-body"&gt; &lt;div id="carouselExampleDark" class="carousel carousel-dark slide" data-bs-ride="false" data-bs-interval="false"&gt; &lt;div class="carousel-indicators"&gt; &lt;div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="0" class="page active" aria-current="true" aria-label="Slide 1"&gt;&lt;/div&gt; &lt;div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="1" class="page" aria-label="Slide 2"&gt;&lt;/div&gt; &lt;div type="button" data-bs-target="#carouselExampleDark" data-bs-slide-to="2" class="page" aria-label="Slide 3"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="carouselExampleControls" class="carousel slide" data-bs-ride="false" data-bs-wrap="false"&gt; &lt;div class="carousel-inner"&gt; &lt;div class="carousel-item active"&gt; &lt;p class="d-block w-100"&gt;I have a Bootstrap Accordion I need to prevent opening of the accordion when textbox is clicked While, if anyone clicks outside the texbox (blue color region) let it expand and shrink as usual. &lt;/p&gt; &lt;div class="carousel-caption d-none d-md-block"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="carousel-item"&gt; &lt;p class="d-block w-100"&gt;I have a Bootstrap Accordion I need to prevent opening of the accordion when textbox is clicked While, if anyone clicks outside the texbox (blue color region) let it expand and shrink as usual. &lt;/p&gt; &lt;div class="carousel-caption d-none d-md-block"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="carousel-item"&gt; &lt;p class="d-block w-100"&gt;I have a Bootstrap Accordion I need to prevent opening of the accordion when textbox is clicked While, if anyone clicks outside the texbox (blue color region) let it expand and shrink as usual. &lt;/p&gt; &lt;div class="carousel-caption d-none d-md-block"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;button class="btn btn-light" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="prev"&gt; &lt;span class=""&gt;Previous&lt;/span&gt; &lt;/button&gt; &lt;button class="btn btn-light" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="next"&gt; &lt;span class=""&gt;Next&lt;/span&gt; &lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74120434, "author": "Jean Seven", "author_id": 16150493, "author_profile": "https://Stackoverflow.com/users/16150493", "pm_score": 0, "selected": false, "text": "margin-left: 15%;" }, { "answer_id": 74120483, "author": "Oren Zur-Shavit", "author_id": 423122...
2022/10/19
[ "https://Stackoverflow.com/questions/74120308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5549354/" ]
74,120,323
<p><strong>JSON RESPONSE</strong></p> <pre><code>{ &quot;cookie&quot;: &quot;user1@gmail.com|1697625092|Vp3S5R4HYCnBZvzObZXn3lxELeppURrwzkDNsueAcMT|86e608657c3293607142b8e1f04bcf477e7d7607bae4166424b0b21f517c83e4&quot;, &quot;cookie_name&quot;: &quot;wordpress_logged_in_756f7f794e89ac60ad1c3919face90fa&quot;, &quot;user&quot;: { &quot;id&quot;: 13, &quot;username&quot;: &quot;user1@gmail.com&quot;, &quot;nicename&quot;: &quot;user1gmail-com&quot;, &quot;email&quot;: &quot;user1@gmail.com&quot;, &quot;url&quot;: &quot;&quot;, &quot;registered&quot;: &quot;2022-10-18 05:48:42&quot;, &quot;displayname&quot;: &quot;user1@gmail.com&quot;, &quot;firstname&quot;: &quot;&quot;, &quot;lastname&quot;: &quot;&quot;, &quot;nickname&quot;: &quot;user1@gmail.com&quot;, &quot;description&quot;: &quot;&quot;, &quot;capabilities&quot;: { &quot;subscriber&quot;: true }, &quot;role&quot;: [ &quot;subscriber&quot; ], &quot;shipping&quot;: null, &quot;billing&quot;: null, &quot;avatar&quot;: &quot;https://secure.gravatar.com/avatar/59029276955677351421b3ff6bf5ee4c?s=96&amp;d=mm&amp;r=g&quot;, &quot;is_driver_available&quot;: false, &quot;dokan_enable_selling&quot;: &quot;&quot; } } </code></pre> <p>I want to access <code>role</code> value in <code>user</code> in my flutter code, i am not sure how can i get role value from my JSON Response.<br /> Here is my <strong>Flutter Code</strong></p> <pre><code>LoginResponseModel.fromJson(Map&lt;String, dynamic&gt; json) { token = json['cookie']; data = Data.fromJson(json['user']); } Map&lt;String, dynamic&gt; toJson() { Map&lt;String, dynamic&gt; data = Map&lt;String, dynamic&gt;(); data['user'] = this.data.toJson(); return data; } </code></pre> <p><strong>DATA CLASS</strong></p> <pre><code>class Data { late String token; late int id; late String email; late String nicename; late String firstName; late String lastName; late String displayName; Data( {required this.token, required this.id, required this.email, required this.firstName, required this.lastName, required this.displayName, required this.nicename}); Data.fromJson(Map&lt;String, dynamic&gt; json) { id = json['id']; token = json['cookie'] ?? ''; email = json['email'] ?? ''; firstName = json['firstName'] ?? ''; lastName = json['lastName'] ?? ''; displayName = json['displayName'] ?? ''; nicename = json['nicename'] ?? ''; } Map&lt;String, dynamic&gt; toJson() { final Map&lt;String, dynamic&gt; data = Map&lt;String, dynamic&gt;(); data['id'] = id; data['email'] = email; data['firstName'] = firstName; data['lastName'] = lastName; data['displayName'] = displayName; data['nicename'] = nicename; return data; } </code></pre>
[ { "answer_id": 74120434, "author": "Jean Seven", "author_id": 16150493, "author_profile": "https://Stackoverflow.com/users/16150493", "pm_score": 0, "selected": false, "text": "margin-left: 15%;" }, { "answer_id": 74120483, "author": "Oren Zur-Shavit", "author_id": 423122...
2022/10/19
[ "https://Stackoverflow.com/questions/74120323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279177/" ]
74,120,324
<p>erro : One or more plugins require a higher Android SDK version. Fix this issue by adding the following to D:\Flutter Project\ivy\android\app\build.gradle: android { compileSdkVersion 33 ... }</p> <p>This is my app/build.gradle code</p> <pre><code>android { compileSdkVersion 33 compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId &quot;com.example.ivy&quot; // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName } </code></pre> <p>Isn't it already fixed?</p>
[ { "answer_id": 74120584, "author": "Himani", "author_id": 18416001, "author_profile": "https://Stackoverflow.com/users/18416001", "pm_score": 0, "selected": false, "text": " android {\ncompileSdkVersion 33\ncompileSdkVersion flutter.compileSdkVersion //REMOVE THIS LINE\nndkVersion flu...
2022/10/19
[ "https://Stackoverflow.com/questions/74120324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20004246/" ]
74,120,381
<p><a href="https://stackoverflow.com/questions/50431055/what-is-the-difference-between-the-const-and-final-keywords-in-dart">What is the difference between the &quot;const&quot; and &quot;final&quot; keywords in Dart?</a></p> <p>The value of variables marked final can be changed at run time, so why bother marking them final anyway?</p> <p>What would be the difference between:-</p> <pre><code>String x; final y; </code></pre> <p>Both can be changed at run time, so why use the final keyword?</p> <p>Please explain.</p>
[ { "answer_id": 74120584, "author": "Himani", "author_id": 18416001, "author_profile": "https://Stackoverflow.com/users/18416001", "pm_score": 0, "selected": false, "text": " android {\ncompileSdkVersion 33\ncompileSdkVersion flutter.compileSdkVersion //REMOVE THIS LINE\nndkVersion flu...
2022/10/19
[ "https://Stackoverflow.com/questions/74120381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/462608/" ]
74,120,410
<p>I made two apps with similar code on Spring Boot.</p> <ol> <li>Reactive Netty spring boot webflux r2dbc.</li> <li>Nonreactive Tomcat spring boot postgres.</li> </ol> I expect reactive one is faster or has the same speed. But it is slower 6th time. I don't see any blocks there. In my opinion it is fully nonblocking app. Why so slowly? For testing I have been using J-METER. 200 threads 200 times getAll 400 strings Latency of response nonreactive app - 190-240 ms. Latency of response reactive app - 1290-1350 ms. <p>reactive pom</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;2.6.6&lt;/version&gt; &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt; &lt;/parent&gt; &lt;groupId&gt;com.example&lt;/groupId&gt; &lt;artifactId&gt;reactive&lt;/artifactId&gt; &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;war&lt;/packaging&gt; &lt;name&gt;reactive&lt;/name&gt; &lt;description&gt;reactive&lt;/description&gt; &lt;properties&gt; &lt;java.version&gt;1.8&lt;/java.version&gt; &lt;mapstruct.version&gt;1.4.2.Final&lt;/mapstruct.version&gt; &lt;lombok-mapstruct-binding.version&gt;0.2.0&lt;/lombok-mapstruct-binding.version&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-r2dbc&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.r2dbc&lt;/groupId&gt; &lt;artifactId&gt;r2dbc-postgresql&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.projectlombok&lt;/groupId&gt; &lt;artifactId&gt;lombok&lt;/artifactId&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.mapstruct&lt;/groupId&gt; &lt;artifactId&gt;mapstruct&lt;/artifactId&gt; &lt;version&gt;${mapstruct.version}&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt; &lt;version&gt;2.4&lt;/version&gt; &lt;configuration&gt; &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;excludes&gt; &lt;exclude&gt; &lt;groupId&gt;org.projectlombok&lt;/groupId&gt; &lt;artifactId&gt;lombok&lt;/artifactId&gt; &lt;/exclude&gt; &lt;/excludes&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;3.5.1&lt;/version&gt; &lt;configuration&gt; &lt;source&gt;1.8&lt;/source&gt; &lt;target&gt;1.8&lt;/target&gt; &lt;annotationProcessorPaths&gt; &lt;path&gt; &lt;groupId&gt;org.projectlombok&lt;/groupId&gt; &lt;artifactId&gt;lombok&lt;/artifactId&gt; &lt;version&gt;${lombok.version}&lt;/version&gt; &lt;/path&gt; &lt;path&gt; &lt;groupId&gt;org.mapstruct&lt;/groupId&gt; &lt;artifactId&gt;mapstruct-processor&lt;/artifactId&gt; &lt;version&gt;${mapstruct.version}&lt;/version&gt; &lt;/path&gt; &lt;/annotationProcessorPaths&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;repositories&gt; &lt;repository&gt; &lt;id&gt;spring-milestones&lt;/id&gt; &lt;name&gt;Spring Milestones&lt;/name&gt; &lt;url&gt;https://repo.spring.io/milestone&lt;/url&gt; &lt;snapshots&gt; &lt;enabled&gt;false&lt;/enabled&gt; &lt;/snapshots&gt; &lt;/repository&gt; &lt;repository&gt; &lt;id&gt;spring-snapshots&lt;/id&gt; &lt;name&gt;Spring Snapshots&lt;/name&gt; &lt;url&gt;https://repo.spring.io/snapshot&lt;/url&gt; &lt;releases&gt; &lt;enabled&gt;false&lt;/enabled&gt; &lt;/releases&gt; &lt;/repository&gt; &lt;/repositories&gt; &lt;pluginRepositories&gt; &lt;pluginRepository&gt; &lt;id&gt;spring-milestones&lt;/id&gt; &lt;name&gt;Spring Milestones&lt;/name&gt; &lt;url&gt;https://repo.spring.io/milestone&lt;/url&gt; &lt;snapshots&gt; &lt;enabled&gt;false&lt;/enabled&gt; &lt;/snapshots&gt; &lt;/pluginRepository&gt; &lt;pluginRepository&gt; &lt;id&gt;spring-snapshots&lt;/id&gt; &lt;name&gt;Spring Snapshots&lt;/name&gt; &lt;url&gt;https://repo.spring.io/snapshot&lt;/url&gt; &lt;releases&gt; &lt;enabled&gt;false&lt;/enabled&gt; &lt;/releases&gt; &lt;/pluginRepository&gt; &lt;/pluginRepositories&gt; &lt;/project&gt; </code></pre> <p>Spring boot entry point</p> <pre><code>@SpringBootApplication(exclude = {ReactiveSecurityAutoConfiguration.class}) @Configuration @EnableR2dbcRepositories public class ReactiveApplication { public static void main(String[] args) { SpringApplication.run(ReactiveApplication.class, args); } } </code></pre> <p>application.yml</p> <pre><code>server: port : 8083 spring: data: r2dbc: repositories: enabled: true r2dbc: url: r2dbc:postgresql://localhost:5432/reactive username: postgres password: 12345 properties: schema: bookshop logging: level: org: springframework: r2dbc: DEBUG </code></pre> <p>Controller</p> <pre><code>package com.example.reactive.controller; import com.example.reactive.entity.Book; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @RequestMapping(&quot;/book&quot;) public interface BookController { @ResponseStatus(code = HttpStatus.OK) @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE) Mono&lt;Book&gt; saveBook(@RequestBody Book book); @ResponseStatus(code = HttpStatus.OK) @GetMapping(&quot;/{id}&quot;) Mono&lt;Book&gt; getBookById(@PathVariable Long id); @ResponseStatus(code = HttpStatus.OK) @GetMapping(&quot;/all&quot;) Flux&lt;Book&gt; getAllBooks(); } </code></pre> <p>ControllerImpl</p> <pre><code>package com.example.reactive.controller.impl; import com.example.reactive.controller.BookController; import com.example.reactive.entity.Book; import com.example.reactive.repository.BookRepository; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @RestController @RequiredArgsConstructor public class BookControllerImpl implements BookController { private final BookRepository bookRepository; @Override public Mono&lt;Book&gt; saveBook(Book book) { return bookRepository.save(book); } @Override public Mono&lt;Book&gt; getBookById(Long id) { return bookRepository.findById(id); } @Override public Flux&lt;Book&gt; getAllBooks() { return bookRepository.findAll(); } } </code></pre> <p>Entity</p> <pre><code>package com.example.reactive.entity; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.data.annotation.Id; @Data @NoArgsConstructor @AllArgsConstructor @Builder public class Book { @Id private Long id; private String name; private String author; private String text; } </code></pre> <p>Repository</p> <pre><code>package com.example.reactive.repository; import com.example.reactive.entity.Book; import org.springframework.data.repository.reactive.ReactiveCrudRepository; public interface BookRepository extends ReactiveCrudRepository&lt;Book, Long&gt; { } </code></pre> <p>If you need more information, feel free to write comments.</p> <p>EDITED</p> <p>After adding thread-pool parameters of min value 50 and max value 100, reactive app become faster. I don't use get All property to compare apps. For testing I have been using J-METER.200 threads 200 times</p> <p>get 1 different string</p> <p>Latency of response nonreactive app - middle 6 ms. Latency of response reactive app - middle 10 ms.</p> <p>post 1 string Latency of response nonreactive app - middle 37 ms. Latency of response reactive app - middle 6 ms!!!!!!!!</p> <p>Computer parameters Processor Intel® Core™ i 5-10400 CPU @ 2.90 GHz × 12. RAM 16,0 GB.</p>
[ { "answer_id": 74133528, "author": "cpigeon", "author_id": 13003044, "author_profile": "https://Stackoverflow.com/users/13003044", "pm_score": 2, "selected": false, "text": "org.springframework.r2dbc" }, { "answer_id": 74185122, "author": "Игорь Ходыко", "author_id": 1875...
2022/10/19
[ "https://Stackoverflow.com/questions/74120410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18754816/" ]
74,120,420
<p>Given:</p> <pre class="lang-js prettyprint-override"><code>type UserObj = { name: string; age: number; role: &quot;admin&quot; | &quot;standard&quot;; }; type ObjValues = UserObj[string]; type UserTuple = [ string, number, &quot;admin&quot; | &quot;standard&quot; ]; type TupleValues = UserTuple[number]; </code></pre> <p>Why does <code>TupleValues</code> type-check but <code>ObjValues</code> not?</p> <p>I’m well aware that I can use <code>keyof</code></p>
[ { "answer_id": 74120501, "author": "mahooresorkh", "author_id": 15235482, "author_profile": "https://Stackoverflow.com/users/15235482", "pm_score": 0, "selected": false, "text": "UserObj[string]" }, { "answer_id": 74147602, "author": "jcalz", "author_id": 2887218, "au...
2022/10/19
[ "https://Stackoverflow.com/questions/74120420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1312987/" ]
74,120,451
<p>I have a list of hours, showing like this <em>2.52 (meaning 2hours 52 minutes) 3 3.63<br /> 3.33<br /> 2.94<br /> 2.52</em> How can I convert this to # of minutes?</p>
[ { "answer_id": 74121389, "author": "Marcel", "author_id": 12480431, "author_profile": "https://Stackoverflow.com/users/12480431", "pm_score": 0, "selected": false, "text": "WITH hours AS (SELECT 3.63 as hour_value UNION SELECT 3.33 UNION SELECT 2.94)\nselect substr(hour_value, 0, positio...
2022/10/19
[ "https://Stackoverflow.com/questions/74120451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11233604/" ]
74,120,461
<p>header titles looks like: <code>['name', 'lastname', 'age']</code> and the body looks like: <code>['lastnameText', 15, 'nameText']</code>, its order may be different from titles list</p> <pre><code>&lt;table&gt; &lt;thead&gt; {titles.map(item =&gt; ( &lt;tr&gt;{item}&lt;/tr&gt; ))} &lt;/thead&gt; &lt;tbody&gt; {content.map(item =&gt; ( &lt;tr&gt;{item}&lt;/tr&gt; ))} &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>the result looks like this way:</p> <pre><code> name lastname age lastnametext 15 name </code></pre> <p>How can I explicitly sync the titles with the content?</p>
[ { "answer_id": 74121389, "author": "Marcel", "author_id": 12480431, "author_profile": "https://Stackoverflow.com/users/12480431", "pm_score": 0, "selected": false, "text": "WITH hours AS (SELECT 3.63 as hour_value UNION SELECT 3.33 UNION SELECT 2.94)\nselect substr(hour_value, 0, positio...
2022/10/19
[ "https://Stackoverflow.com/questions/74120461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18671377/" ]
74,120,524
<p>I would like a support on doing melt without providing all the column names. I have a dataframe with 5000+ columns and it is quite dynamic. Hence, would like to see if there is any way to do melt without providing columns (using <code>df.columns</code>).</p> <pre><code># Sample df #| sub1 sub2 subN #| Student max min mean max min mean max min mean #| 0 Joy 7 2 0 8 3 1 7 2 0 #| 1 Red 9 2 5 8 3 4 7 1 0 #| 2 CTL 5 0 4 4 1 7 7 2 5 </code></pre> <p>I would like to have</p> <pre><code># Sample df #| #| Student Sub type #| 0 Joy sub1 max 7 #| 0 Joy sub1 min 2 #| 0 Joy sub1 mean 0 #| 0 Joy sub2 max 8 #| 0 Joy sub2 min 3 #| 0 Joy sub2 mean 1 #| 0 Joy subN max 7 #| 0 Joy subN min 2 #| 0 Joy subN mean 0 #| 1 Red ........ </code></pre>
[ { "answer_id": 74120572, "author": "Selva", "author_id": 6225526, "author_profile": "https://Stackoverflow.com/users/6225526", "pm_score": 1, "selected": false, "text": "melt()" }, { "answer_id": 74120697, "author": "jezrael", "author_id": 2901002, "author_profile": "...
2022/10/19
[ "https://Stackoverflow.com/questions/74120524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6225526/" ]
74,120,532
<pre><code>HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); HashMap&lt;String, String&gt; newMap = new HashMap&lt;String, String&gt;(); map.put(&quot;A&quot;,&quot;1&quot;); map.put(&quot;B&quot;,&quot;2&quot;); map.put(&quot;C&quot;,&quot;2&quot;); map.put(&quot;D&quot;,&quot;1&quot;); </code></pre> <p>Expected Output: &quot;AD&quot;, &quot;1&quot; and &quot;BC&quot;, &quot;2&quot; present inside the newMap which means, if the data values were same it needs combine its keys to have only one data value by combining its keys inside the newMap created how to achieve this in Java?</p>
[ { "answer_id": 74120848, "author": "Nikolas Charalambidis", "author_id": 3764965, "author_profile": "https://Stackoverflow.com/users/3764965", "pm_score": 2, "selected": false, "text": "Collectors.groupingBy" }, { "answer_id": 74121113, "author": "IamGroot", "author_id": ...
2022/10/19
[ "https://Stackoverflow.com/questions/74120532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15977973/" ]
74,120,558
<p>Given an array A of size 10<sup>5</sup>.</p> <p>Then given m (m is very large, m&gt;&gt; the size of A) operations, each operation is for position p, increasing t.</p> <p>A[p]+=t</p> <p>Finally, I output the value of each position of the whole array.</p> <p>Is there any constant optimization to speed up the intermediate modification operations?</p> <p>For example, if I sort the positions, I can modify them sequentially to avoid random access. However, this operation will incur an additional sorting cost. Is there any other way to speed it up?</p> <p>Trying to re-execute all operations after sorting can be an order of magnitude faster than executing them directly. But the cost of sorting is too high.</p>
[ { "answer_id": 74128609, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "A[p]" }, { "answer_id": 74162195, "author": "Xin Cheng", "author_id": 4708399, "author_p...
2022/10/19
[ "https://Stackoverflow.com/questions/74120558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279362/" ]
74,120,617
<p>I am a beginner in Django and I want to display page-y when the user refreshes the page-x</p>
[ { "answer_id": 74128609, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "A[p]" }, { "answer_id": 74162195, "author": "Xin Cheng", "author_id": 4708399, "author_p...
2022/10/19
[ "https://Stackoverflow.com/questions/74120617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20129933/" ]
74,120,624
<p>I am getting the points dynamically, I have to fill the area under the polyline. I have tried the <strong>fill</strong> property but that would not result in what I have expected, screenshot attached.</p> <pre><code> &lt;svg viewBox={`0 0 ${points.length * 10} 100`} height=&quot;100%&quot; width=&quot;150px&quot; &gt; &lt;polyline fill=&quot;rgba(0,116,217,0.5)&quot; stroke=&quot;#0074d9&quot; stroke-width=&quot;5&quot; points={points} /&gt; &lt;/svg&gt; </code></pre> <p>the output is something like this</p> <p><a href="https://i.stack.imgur.com/vNIkc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vNIkc.png" alt="the output is something like this" /></a></p> <p>and I want it to be something like this</p> <p><a href="https://i.stack.imgur.com/p431U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p431U.png" alt="enter image description here" /></a></p> <p>I have already tried different solutions to that, like by using a <strong>path</strong> instead of using a polyline, but It is a little bit more complex if we have dynamic co-ordinates (points).</p>
[ { "answer_id": 74128609, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "A[p]" }, { "answer_id": 74162195, "author": "Xin Cheng", "author_id": 4708399, "author_p...
2022/10/19
[ "https://Stackoverflow.com/questions/74120624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16477101/" ]
74,120,626
<p>I'm able to compile both Tcl and Tk just fine on Windows 10 using Visual Studio 2019 developer command prompt. Both have <code>win\makefile.vc</code> file. <code>nmake -f makefile.vc</code> will build them successfully.</p> <p>However, TkTreeCtrl source code located at the following location doesn't seem to have <code>makefile.vc</code> anywhere.</p> <p><a href="https://sourceforge.net/projects/tktreectrl/files/tktreectrl/tktreectrl-2.4.1/tktreectrl-2.4.1.tar.gz/download" rel="nofollow noreferrer">https://sourceforge.net/projects/tktreectrl/files/tktreectrl/tktreectrl-2.4.1/tktreectrl-2.4.1.tar.gz/download</a></p> <p>I had compiled TkTreeCtrl successfully several years ago. But I can't for the life of me remember how I did it!</p>
[ { "answer_id": 74128609, "author": "Jérôme Richard", "author_id": 12939557, "author_profile": "https://Stackoverflow.com/users/12939557", "pm_score": 2, "selected": true, "text": "A[p]" }, { "answer_id": 74162195, "author": "Xin Cheng", "author_id": 4708399, "author_p...
2022/10/19
[ "https://Stackoverflow.com/questions/74120626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1188656/" ]
74,120,636
<p>I want to count what is the number of each age for each gender, basically to see the distribution of age and gender.</p> <p>A sample of the data is like</p> <pre><code>state poi_name gender age aichi starbucks shop E 2 3 aichi starbucks shop G 0 2 aichi starbucks shop G 1 2 chiba starbucks shop A 0 1 chiba starbucks shop D 1 1 chiba starbucks shop A 0 2 tokyo starbucks shop B 2 1 tokyo starbucks shop B 1 0 tokyo starbucks shop C 2 3 tokyo starbucks shop F 1 2 aichi starbucks shop E 1 2 </code></pre> <p>I could get the gender distribution but not the age range, how can I do this.</p> <pre><code>SELECT state, poi_name, count(gender) all_cnt, count( gender = '0' or null) as Unknown, count( gender = '1' or null) as Total_Male, count( gender = '2' or null) as Total_Female, count('gender') OVER(PARTITION BY state) AS cnt_for_state FROM `geo_data_working.hw0160_infoDemographic` GROUP BY state,poi_name ORDER BY state,poi_name </code></pre> <pre><code>age range: -1:13-17 1:18-24 2:25-34 3:35-44 4:45- 0:unknown </code></pre> <p>Thanks in advance</p> <p>add-on: I was asked about my expected results, good point. Unfortunately, I am not sure, this is my first SQL try. Maybe something like bellow or if you have a better advise I will appreciate it</p> <p>1)</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>state</th> <th>poi_name</th> <th>gender</th> <th>ageRange0</th> <th>ageRangeage1</th> </tr> </thead> <tbody> <tr> <td>Tokyo</td> <td>ShopA</td> <td>F</td> <td>200</td> <td>100</td> </tr> <tr> <td>Tokyo</td> <td>ShopA</td> <td>M</td> <td>100</td> <td>150</td> </tr> </tbody> </table> </div> <p>2)</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>state</th> <th>poi_name</th> <th>F_ageRange0</th> <th>F_ageRangeage1</th> <th>M_ageRange0</th> <th>M_ageRangeage1</th> </tr> </thead> <tbody> <tr> <td>Tokyo</td> <td>ShopA</td> <td>200</td> <td>100</td> <td>30</td> <td>9000</td> </tr> </tbody> </table> </div>
[ { "answer_id": 74121090, "author": "reza ramezani matin", "author_id": 3585050, "author_profile": "https://Stackoverflow.com/users/3585050", "pm_score": 1, "selected": true, "text": " select res.state,\n res.POI_NAME,\n res.gender,\n res.range,\n count(*) as cn...
2022/10/19
[ "https://Stackoverflow.com/questions/74120636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19955962/" ]
74,120,650
<p>I'm trying to create a todolist with React which when you double click on one of the to do list that will show input that allow you to edit the value. But I want to show the before value in the input edit when user click on it and the user can erase the before value and change to new and change the value.</p> <p>I know, my explanation is very bad. I will show the example that I want in here <a href="https://todomvc.com/examples/react/#/" rel="nofollow noreferrer">https://todomvc.com/examples/react/#/</a>. I want to make just like this person todo mvc which when you double click the todolist the edit input value still shown the before value.</p> <pre><code>import {useState} from 'react'; export default function App() { const [todo, setTodo] = useState([]) const [input, setInput] = useState('') const [edit, setEditing]= useState(null) const [edittext , setEditingText] = useState('') const InputHandler = (e)=&gt;{ setInput(e.target.value) } const SubmitHandler = ()=&gt;{ setTodo([...todo, {text:input, id: Math.random()*1000}]) setInput('') } const EditHandler = (e)=&gt;{ setEditingText(e.target.value) console.log(e.target.value) } const SubmitEdit = (id)=&gt;{ setTodo([...todo].map((todos)=&gt;{ if(todos.id === id){ todos.text = edittext } return todos })) setEditing(null) setEditingText(&quot;&quot;) } return ( &lt;div className=&quot;App&quot;&gt; &lt;input value={input} onChange={InputHandler}/&gt; &lt;button onClick={SubmitHandler}&gt;Add&lt;/button&gt; {todo.map(todos =&gt; &lt;div key={todos.id}&gt; {edit === todos.id ? (&lt;&gt;&lt;input type=&quot;text&quot; value={edittext} onChange={EditHandler}/&gt; &lt;button onClick={()=&gt;SubmitEdit(todos.id)}&gt;Edit&lt;/button&gt;&lt;/&gt;) : (&lt;p onDoubleClick={()=&gt;setEditing(todos.id)}&gt;{todos.text}&lt;/p&gt;) } &lt;/div&gt; )} &lt;/div&gt; ); } </code></pre> <p>I'm sorry if my explanation is a little confusing.</p> <p>Thank you.</p>
[ { "answer_id": 74121090, "author": "reza ramezani matin", "author_id": 3585050, "author_profile": "https://Stackoverflow.com/users/3585050", "pm_score": 1, "selected": true, "text": " select res.state,\n res.POI_NAME,\n res.gender,\n res.range,\n count(*) as cn...
2022/10/19
[ "https://Stackoverflow.com/questions/74120650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19660851/" ]
74,120,668
<p>In react, There is one component A inside there is one component B I have used. There is one more component C, and inside C there is one button which is when clicked it hides the component B from component A. How can I achieve this functionality</p>
[ { "answer_id": 74121261, "author": "Anu", "author_id": 20212948, "author_profile": "https://Stackoverflow.com/users/20212948", "pm_score": 0, "selected": false, "text": "import { useState } from \"react\";\nimport \"./styles.css\";\n\nexport default function App() {\n const [isVisible, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74120668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10578470/" ]
74,120,684
<p>I have an issue with adding a point to the existing/old score value after I refresh the web page. Instead of adding a point to the existing/old score, it replaces it, which means if there's an existing/old score already, it will reset and start from 1 again. I don't want that. I want it continues.</p> <p>Here's my current code, the localStorage code is on the bottom:</p> <pre><code>function addPhoto(data, mode) { // DATA let userName = data.uniqueId; let userAvatar = data.profilePictureUrl; let word = ['Nice going','That’s better than ever','That’s first class work','I’m impressed','Nothing can stop you now','Well done','Good job','You did it','That’s the way','You rock','I knew you could do it','Keep up the good work','That’s clever','Way to go','Outstanding','Tremendous','Fantastic','You are amazing','No one can beat you','You are the chosen one']; let words = word[Math.floor(Math.random()*word.length)]; if (mode == &quot;winner&quot;) { wins[userName] = wins[userName] || 0 wins[userName]++ addContent( `&lt;div style=&quot;text-align:center;font-size: .8rem;&quot;&gt; &lt;div style='padding-bottom:.25rem;color:#1881FF;'&gt; `+ words + `&lt;/div&gt; &lt;div style='padding-bottom:.5rem;font-weight: bold;color:#20B601;'&gt;`+ userName + ` ❗&lt;/div&gt; &lt;div&gt; &lt;img src=&quot;`+ userAvatar + `&quot; style=&quot;width:135px;height:135px;border-radius: 30%;border: 1px solid #20B601;box-shadow: 0 0 7px 1px #20B601;&quot;/&gt; &lt;span style='color:#EA0C0C; font-weight: bold;'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Wins: x`+ wins[userName] + `&lt;/span&gt; &lt;/div&gt; &lt;/div&gt;` ); } // Set $(&quot;#lastWinner&quot;).html(`&lt;div class=&quot;lastWinPopUp winnerpopup&quot;&gt; &lt;p&gt;Winner:&lt;/p&gt; &lt;/br&gt;`+ userName + ` &lt;/br&gt;&lt;/br&gt;&lt;img src=&quot;`+ userAvatar + `&quot; style=&quot;width:80px;height:80px;border-radius: 10%;box-shadow: 0 0 7px 1px #000000;&quot;/&gt; &lt;/br&gt;&lt;/br&gt;Win streak:&lt;p id=&quot;score&quot;&gt;&lt;/p&gt; &lt;/div&gt;` ); //&lt;span style='color:#EA0C0C; font-weight: bold;'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Wins: x`+ wins[userName] + `&lt;/span&gt; // Sound playSound(3); const username = userName; const score = wins[userName]; localStorage.setItem(username, score) var existing = localStorage.getItem(username); var data = existing ? existing + score : score; localStorage.setItem(username, data); document.getElementById(&quot;score&quot;).innerHTML = localStorage.getItem(username); } </code></pre> <p>The result from this current code is:</p> <p>After refreshing the page, it will replace the existing/old score, and start again from 1 point. As you can see I tried adding the <code>var existing</code> an attempt to add a point to the existing/old score.</p> <p>But instead of adding 1 point, it adds number <code>1</code> literally next to the current value which will become <code>11</code>(becomes 1 because it still replaces the existing/old score), and becomes <code>22</code>, <code>33</code>, and so on as it adds more points.</p> <p>Could anyone modify the code for me?</p>
[ { "answer_id": 74120774, "author": "Haim Abeles", "author_id": 15298697, "author_profile": "https://Stackoverflow.com/users/15298697", "pm_score": 1, "selected": false, "text": "parseInt" }, { "answer_id": 74120832, "author": "aghashamim", "author_id": 6457679, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74120684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7676733/" ]
74,120,689
<p>I'm trying to create a functional inheritance hierarchy. We are working with implementing our own priority queue class template, and the program includes lists such as buy orders.</p> <p>My idea was to have &quot;p_queue&quot; as the base class, and let the &quot;orders&quot; class inherit from it, and then let subclasses such as &quot;buy_orders&quot; inherit from the orders class. My reasoning is that every order in this program is a priority queue, as they will be sorted by it.</p> <p>Normally I would understand the error &quot;type 'base_class' is not a direct base of 'sub_class'&quot; if the derived class wasn't directly inheriting the superclass. But since the orders class inherits the p_queue class and no other class directly inherits from priority queue class, I'm confused why I get this error message.</p> <p>Here is the code</p> <pre><code>//main.cpp #include &quot;orders.h&quot; int main(){ return 0; } </code></pre> <pre><code>//orders.h #include &quot;p_queue.h&quot; template&lt;typename T&gt; struct less{ bool operator()(const T&amp; a, const T&amp; b){ return a &lt; b; } }; template&lt;typename T&gt; class Orders : public p_queue&lt;T, decltype(less&lt;T&gt;())&gt; { private: size_t m_Size; std::vector&lt;T&gt; list; public: Orders(const size_t&amp; sz, const std::vector&lt;T&gt;&amp; l) : list(l), m_Size(sz), p_queue&lt;T&gt;(&amp;(*list.begin()), &amp;(*list.end()), less&lt;T&gt;()){} virtual const size_t getSize() const { return m_Size; } virtual const std::vector&lt;T&gt; getList() const = 0; }; struct buy_orders : public Orders&lt;size_t&gt;{ std::vector&lt;size_t&gt; buy_prices; buy_orders(const size_t&amp; sz) : Orders(sz, buy_prices) {} }; </code></pre> <pre><code>//p_queue.h #include &lt;functional&gt; template&lt;typename T, typename Compare = std::less&lt;T&gt;&gt; class p_queue{ protected: T* m_first; T* m_last; Compare m_comp; public: p_queue(T* first, T* last, Compare comp = Compare()) : m_first(first), m_last(last), m_comp(comp) {} }; </code></pre> <p>The above code produces the error:</p> <pre class="lang-none prettyprint-override"><code>&lt;source&gt;: In instantiation of 'Orders&lt;T&gt;::Orders(const size_t&amp;, const std::vector&lt;T&gt;&amp;) [with T = long unsigned int; size_t = long unsigned int]': &lt;source&gt;:39:57: required from here &lt;source&gt;:31:59: error: type 'p_queue&lt;long unsigned int, std::less&lt;long unsigned int&gt; &gt;' is not a direct base of 'Orders&lt;long unsigned int&gt;' 31 | p_queue&lt;T&gt;(&amp;(*list.begin()), &amp;(*list.end()), less&lt;T&gt;()){} | ^ &lt;source&gt;:31:59: error: no matching function for call to 'p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;::p_queue()' &lt;source&gt;:13:5: note: candidate: 'p_queue&lt;T, Compare&gt;::p_queue(T*, T*, Compare) [with T = long unsigned int; Compare = less&lt;long unsigned int&gt;]' 13 | p_queue(T* first, T* last, Compare comp = Compare()) : | ^~~~~~~ &lt;source&gt;:13:5: note: candidate expects 3 arguments, 0 provided &lt;source&gt;:7:7: note: candidate: 'constexpr p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;::p_queue(const p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;&amp;)' 7 | class p_queue{ | ^~~~~~~ &lt;source&gt;:7:7: note: candidate expects 1 argument, 0 provided &lt;source&gt;:7:7: note: candidate: 'constexpr p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;::p_queue(p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;&amp;&amp;)' &lt;source&gt;:7:7: note: candidate expects 1 argument, 0 provided ASM generation compiler returned: 1 &lt;source&gt;: In instantiation of 'Orders&lt;T&gt;::Orders(const size_t&amp;, const std::vector&lt;T&gt;&amp;) [with T = long unsigned int; size_t = long unsigned int]': &lt;source&gt;:39:57: required from here &lt;source&gt;:31:59: error: type 'p_queue&lt;long unsigned int, std::less&lt;long unsigned int&gt; &gt;' is not a direct base of 'Orders&lt;long unsigned int&gt;' 31 | p_queue&lt;T&gt;(&amp;(*list.begin()), &amp;(*list.end()), less&lt;T&gt;()){} | ^ &lt;source&gt;:31:59: error: no matching function for call to 'p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;::p_queue()' &lt;source&gt;:13:5: note: candidate: 'p_queue&lt;T, Compare&gt;::p_queue(T*, T*, Compare) [with T = long unsigned int; Compare = less&lt;long unsigned int&gt;]' 13 | p_queue(T* first, T* last, Compare comp = Compare()) : | ^~~~~~~ &lt;source&gt;:13:5: note: candidate expects 3 arguments, 0 provided &lt;source&gt;:7:7: note: candidate: 'constexpr p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;::p_queue(const p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;&amp;)' 7 | class p_queue{ | ^~~~~~~ &lt;source&gt;:7:7: note: candidate expects 1 argument, 0 provided &lt;source&gt;:7:7: note: candidate: 'constexpr p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;::p_queue(p_queue&lt;long unsigned int, less&lt;long unsigned int&gt; &gt;&amp;&amp;)' &lt;source&gt;:7:7: note: candidate expects 1 argument, 0 provided </code></pre> <p>If I remove the buy_orders struct from orders.h, the problem disappears. Why is this? How can I solve this issue?</p>
[ { "answer_id": 74120774, "author": "Haim Abeles", "author_id": 15298697, "author_profile": "https://Stackoverflow.com/users/15298697", "pm_score": 1, "selected": false, "text": "parseInt" }, { "answer_id": 74120832, "author": "aghashamim", "author_id": 6457679, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74120689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14637811/" ]
74,120,694
<p>I'm building a dynamic list of trees that starts with Oak, Pine, Aspen, Bald Cypress.</p> <p>Which includes a button to add a 'Redwood' tree to the end of the list, and a 'Pear' tree to the start of the list.</p> <p>I then included a button that onclick would change the strings to lowercase but I can't seem to get it right. I know the push() method will add the lowercase strings to the end of the list but I can't figure out how to get rid of the old strings with uppercase letters, and it also keeps adding more items to the list when the button is pushed again. I also tried the map method, however it did not seem to work unless created a new variable.</p> <pre><code> const trees = ['Oak', 'Pine', 'Aspen', 'Bald Cypress'] const listTrees = () =&gt; { let treeList = '' trees.forEach(tree =&gt; { //console.log(tree) treeList += `${tree} &lt;br&gt;` }) displayResults.innerHTML = `${treeList} &lt;span&gt;${trees.length} elements long&lt;/span&gt;` } listTrees() * ------adding redwood to the end ------------*/ document.querySelector('#add_redwood').onclick = () =&gt; { trees.push('Redwood') listTrees() } /* --------------------adding a pear to the start ----------------------*/ document.querySelector('#add_pear').onclick = () =&gt; { trees.unshift('Pear') listTrees() } document.querySelector('#lowerTrees').onclick = () =&gt; { trees.forEach(tree =&gt; { trees.push(tree.toLowerCase()) }) listTrees() } </code></pre>
[ { "answer_id": 74120904, "author": "Muhammad Ahsan", "author_id": 11420134, "author_profile": "https://Stackoverflow.com/users/11420134", "pm_score": 0, "selected": false, "text": " document.querySelector('#lowerTrees').onclick = () => {\n trees.forEach(tree => {\n trees.push(t...
2022/10/19
[ "https://Stackoverflow.com/questions/74120694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279098/" ]
74,120,703
<p>I am trying to create a custom implementation of List where my list IntegrityList enforces some business rules.</p> <pre><code>[Serializable] public class IntegrityList&lt;TSource&gt; : List&lt;TSource&gt; where TSource : IEvent { ... business logic... } </code></pre> <p>But I also need to have some custom extension methods like LINQ's ToList() and EF's ToListAsync(). I looked into the implementation of Microsoft and created a simple ToIntegrityList() extension method, but I cannot find the implementation of ToListAsync(). Does anyone have any idea how to implement such method?</p> <pre><code>public static class IntegrityListExtensions { public static IntegrityList&lt;TSource&gt; ToIntegrityList&lt;TSource&gt;(this IEnumerable&lt;TSource&gt; source) where TSource : IEvent { if (source == null) throw new ArgumentNullException(nameof(source)); return new IntegrityList&lt;TSource&gt;(source); } public static Task&lt;IntegrityList&lt;TSource&gt;&gt; ToIntegrityListAsync&lt;TSource&gt;(this IQueryable&lt;TSource&gt; source) where TSource : IEvent { if (source == null) throw new ArgumentNullException(nameof(source)); throw new NotImplementedException(&quot;Missing implementation&quot;); } public static Task&lt;IntegrityList&lt;TSource&gt;&gt; ToIntegrityListAsync&lt;TSource&gt;(this IQueryable&lt;TSource&gt; source, CancellationToken cancellationToken) where TSource : IEvent { if (source == null) throw new ArgumentNullException(nameof(source)); else if (cancellationToken == null) throw new ArgumentNullException(nameof(cancellationToken)); throw new NotImplementedException(&quot;Missing implementation&quot;); } } </code></pre>
[ { "answer_id": 74120904, "author": "Muhammad Ahsan", "author_id": 11420134, "author_profile": "https://Stackoverflow.com/users/11420134", "pm_score": 0, "selected": false, "text": " document.querySelector('#lowerTrees').onclick = () => {\n trees.forEach(tree => {\n trees.push(t...
2022/10/19
[ "https://Stackoverflow.com/questions/74120703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15853751/" ]
74,120,708
<p>What is the difference between geopandas plots and matplotlib plots? Why are not all keywords available? <br> In geopandas there is markersize, but not markeredgecolor... <br> In the example below I plot a pandas df with some styling, then transform the pandas df to a geopandas df. Simple plotting is working, but no additional styling.<br> This is just an example. In my geopandas plots I would like to customize, markers, legends, etc. How can I access the relevant matplotlib objects?</p> <pre><code>import numpy as np import matplotlib.pyplot as plt import pandas as pd import geopandas as gpd X = np.linspace(-6, 6, 1024) Y = np.sinc(X) df = pd.DataFrame(Y, X) plt.plot(X,Y,linewidth = 3., color = 'k', markersize = 9, markeredgewidth = 1.5, markerfacecolor = '.75', markeredgecolor = 'k', marker = 'o', markevery = 32) # alternatively: # df.plot(linewidth = 3., color = 'k', markersize = 9, markeredgewidth = 1.5, markerfacecolor = '.75', markeredgecolor = 'k', marker = 'o', markevery = 32) plt.show() # create GeoDataFrame from df df.reset_index(inplace=True) df.rename(columns={'index': 'Y', 0: 'X'}, inplace=True) gdf = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df['Y'], df['X'])) gdf.plot(linewidth = 3., color = 'k', markersize = 9) # working gdf.plot(linewidth = 3., color = 'k', markersize = 9, markeredgecolor = 'k') # not working plt.show() </code></pre>
[ { "answer_id": 74121294, "author": "Rutger Kassies", "author_id": 1755432, "author_profile": "https://Stackoverflow.com/users/1755432", "pm_score": 3, "selected": true, "text": ".plot(" }, { "answer_id": 74121924, "author": "wl_", "author_id": 8521115, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8521115/" ]
74,120,748
<p>I am trying to find abbreviations in a sentence with python, for example, u.s.a. equals to usa, so I want to find u.s.a. and remove the full stop in this abbreviation and get usa as the result. 'I come from u.s.a..' Then will become 'I come from usa.' How to do with it? Now I can only find all the abbreviations with regex <code>pattern = re.compile(r'(?:[a-z]\.){2,}')</code>, but cannot just remove the full stop.</p>
[ { "answer_id": 74121294, "author": "Rutger Kassies", "author_id": 1755432, "author_profile": "https://Stackoverflow.com/users/1755432", "pm_score": 3, "selected": true, "text": ".plot(" }, { "answer_id": 74121924, "author": "wl_", "author_id": 8521115, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19553729/" ]
74,120,763
<p>I have added a WebView to load HTML and the baseUrl method. But it leads to crashing the app and showing a warning</p> <blockquote> <p>This method should not be called on the main thread as it may lead to UI unresponsiveness.</p> </blockquote> <pre><code>//load HTML let htmlPath = Bundle.main.path(forResource: &quot;index&quot;, ofType: &quot;html&quot;) let folderPath = Bundle.main.bundlePath let baseUrl = URL(fileURLWithPath: folderPath, isDirectory: true) do { let htmlString = try NSString(contentsOfFile: htmlPath!, encoding: String.Encoding.utf8.rawValue) self.webView.loadHTMLString(htmlString as String, baseURL: URL(string: newBaseURL)) } catch { // catch error print(error.localizedDescription) } </code></pre> <p>I have called this piece of code in viewDidLoad(). Also it has been added in dispatch queue. Any help is much appreciated.</p>
[ { "answer_id": 74121294, "author": "Rutger Kassies", "author_id": 1755432, "author_profile": "https://Stackoverflow.com/users/1755432", "pm_score": 3, "selected": true, "text": ".plot(" }, { "answer_id": 74121924, "author": "wl_", "author_id": 8521115, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8842890/" ]
74,120,810
<p>I'm trying to join 2 entities using Spring data JPA query, but the result set seems to be repeating. I only want the fields/columns of Snippet table that is related to the id of SnippetCollection table.</p> <p>MariaDB SQL code</p> <pre><code>CREATE TABLE `user` ( `id` INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(`id`) ); CREATE TABLE `snippet_collection` ( `id` int NOT NULL AUTO_INCREMENT, `user_id` int NOT NULL, `title` VARCHAR(34) NOT NULL, `description` VARCHAR(125) NOT NULL, `programming_language` VARCHAR(64) NOT NULL, `date_created` DATE NOT NULL, `link` VARCHAR(512), CONSTRAINT `fk_sc_user` FOREIGN KEY (user_id) REFERENCES user(id), PRIMARY KEY (`id`) ); CREATE TABLE `snippet` ( `id` int NOT NULL AUTO_INCREMENT, `snippet_collection_id` int NOT NULL, `title` VARCHAR(34) NOT NULL, `is_public` BOOLEAN DEFAULT false, `programming_language` VARCHAR(64) NOT NULL, `date_created` DATE NOT NULL, `code` TEXT, CONSTRAINT `fk_s_snippet_collection` FOREIGN KEY (snippet_collection_id) REFERENCES `snippet_collection`(id), PRIMARY KEY (`id`) ); INSERT INTO `user` (`id`) VALUES (1); INSERT INTO `user` (`id`) VALUES (2); INSERT INTO `snippet_collection`(`user_id`, `title`, `description`, `programming_language`, `date_created`) VALUES(1, 'http servlet code snippets', 'Lorem ipsom dolor amet', 'java', CURDATE()); INSERT INTO `snippet_collection`(`user_id`, `title`, `description`, `programming_language`, `date_created`) VALUES(2, 'http php code ', 'Lorem ipsom asda dolor amet', 'php', CURDATE()); INSERT INTO `snippet`(`snippet_collection_id`, `title`, `is_public`, `programming_language`, `date_created`, `code`) VALUES(1, 'luv2code angular http', FALSE, 'java', CURDATE(), 'const x =&gt;{ console.log(y); }'); INSERT INTO `snippet`(`snippet_collection_id`, `title`, `is_public`, `programming_language`, `date_created`, `code`) VALUES(1, 'luv2code java http', FALSE, 'java', CURDATE(), 'let x =&gt;{ console.log(y); }'); INSERT INTO `snippet`(`snippet_collection_id`, `title`, `is_public`, `programming_language`, `date_created`, `code`) VALUES(1, 'luv2code spring boot http', FALSE, 'java', CURDATE(), 'var x =&gt;{ console.log(y); }'); INSERT INTO `snippet`(`snippet_collection_id`, `title`, `is_public`, `programming_language`, `date_created`, `code`) VALUES(2, 'asddasd', FALSE, 'javax', CURDATE(), 'var x =&gt;{ consssole.log(y); }'); </code></pre> <p>Spring Boot JPA Entities</p> <pre><code> // snippet collections entity @Entity @Table(name = &quot;snippet_collection&quot;) public class SnippetCollection { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String title; private String description; @Column(name = &quot;programming_language&quot;) private String programmingLanguage; @Temporal(TemporalType.DATE) @Column(name = &quot;date_created&quot;) private Date dateCreated; private String link; @JsonIgnore @ManyToOne @JoinColumn(name = &quot;user_id&quot;) private User user; @OneToMany(mappedBy = &quot;snippetCollection&quot;, cascade = CascadeType.ALL, orphanRemoval = true) private List&lt;Snippet&gt; snippets; public SnippetCollection() { } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getProgrammingLanguage() { return programmingLanguage; } public void setProgrammingLanguage(String programmingLanguage) { this.programmingLanguage = programmingLanguage; } public Date getDateCreated() { return dateCreated; } public void setDateCreated(Date dateCreated) { this.dateCreated = dateCreated; } public String getLink() { return link; } public void setLink(String link) { this.link = link; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public List&lt;Snippet&gt; getSnippets() { return snippets; } public void setSnippets(List&lt;Snippet&gt; snippets) { this.snippets = snippets; } } // snippet entity @Entity @Table(name = &quot;snippet&quot;) public class Snippet { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; private String title; @Column(name = &quot;is_public&quot;) private boolean isPublic; @Column(name = &quot;programming_language&quot;) private String programmingLanguage; @Temporal(TemporalType.DATE) @Column(name = &quot;date_created&quot;) private Date dateCreated; @Lob private String code; @JsonIgnore @ManyToOne @JoinColumn(name = &quot;snippet_collection_id&quot;) private SnippetCollection snippetCollection; public Snippet() { } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public boolean isPublic() { return isPublic; } public void setPublic(boolean isPublic) { this.isPublic = isPublic; } public String getProgrammingLanguage() { return programmingLanguage; } public void setProgrammingLanguage(String programmingLanguage) { this.programmingLanguage = programmingLanguage; } public Date getDateCreated() { return dateCreated; } public void setDateCreated(Date dateCreated) { this.dateCreated = dateCreated; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public SnippetCollection getSnippetCollection() { return snippetCollection; } public void setSnippetCollection(SnippetCollection snippetCollection) { this.snippetCollection = snippetCollection; } } </code></pre> <p>Here's my query in the repository</p> <pre><code>@Repository public interface SnippetCollectionRepository extends CrudRepository&lt;SnippetCollection, Integer&gt; { @Query(&quot;SELECT s FROM Snippet s JOIN s.snippetCollection r WHERE r.id = 1 &quot;) List&lt;Snippet&gt; findSnippetCollectionBySnippetId(int id); } </code></pre> <p>Result I'm getting from POSTMAN</p> <pre><code>[ { &quot;id&quot;: 1, &quot;title&quot;: &quot;luv2code angular http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;const x =&gt;{ console.log(y); }&quot;, &quot;snippetCollection&quot;: { &quot;id&quot;: 1, &quot;title&quot;: &quot;http servlet code snippets&quot;, &quot;description&quot;: &quot;Lorem ipsom dolor amet&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;link&quot;: null, &quot;snippets&quot;: [ { &quot;id&quot;: 1, &quot;title&quot;: &quot;luv2code angular http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;const x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false }, { &quot;id&quot;: 2, &quot;title&quot;: &quot;luv2code java http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;let x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false }, { &quot;id&quot;: 3, &quot;title&quot;: &quot;luv2code spring boot http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;var x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false } ] }, &quot;public&quot;: false }, { &quot;id&quot;: 2, &quot;title&quot;: &quot;luv2code java http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;let x =&gt;{ console.log(y); }&quot;, &quot;snippetCollection&quot;: { &quot;id&quot;: 1, &quot;title&quot;: &quot;http servlet code snippets&quot;, &quot;description&quot;: &quot;Lorem ipsom dolor amet&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;link&quot;: null, &quot;snippets&quot;: [ { &quot;id&quot;: 1, &quot;title&quot;: &quot;luv2code angular http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;const x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false }, { &quot;id&quot;: 2, &quot;title&quot;: &quot;luv2code java http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;let x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false }, { &quot;id&quot;: 3, &quot;title&quot;: &quot;luv2code spring boot http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;var x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false } ] }, &quot;public&quot;: false }, { &quot;id&quot;: 3, &quot;title&quot;: &quot;luv2code spring boot http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;var x =&gt;{ console.log(y); }&quot;, &quot;snippetCollection&quot;: { &quot;id&quot;: 1, &quot;title&quot;: &quot;http servlet code snippets&quot;, &quot;description&quot;: &quot;Lorem ipsom dolor amet&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;link&quot;: null, &quot;snippets&quot;: [ { &quot;id&quot;: 1, &quot;title&quot;: &quot;luv2code angular http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;const x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false }, { &quot;id&quot;: 2, &quot;title&quot;: &quot;luv2code java http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;let x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false }, { &quot;id&quot;: 3, &quot;title&quot;: &quot;luv2code spring boot http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;var x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false } ] }, &quot;public&quot;: false } ] </code></pre> <p>Is there a way to only have this result set?</p> <pre><code>&quot;snippets&quot;: [ { &quot;id&quot;: 1, &quot;title&quot;: &quot;luv2code angular http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;const x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false }, { &quot;id&quot;: 2, &quot;title&quot;: &quot;luv2code java http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;let x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false }, { &quot;id&quot;: 3, &quot;title&quot;: &quot;luv2code spring boot http&quot;, &quot;programmingLanguage&quot;: &quot;java&quot;, &quot;dateCreated&quot;: &quot;2022-10-18&quot;, &quot;code&quot;: &quot;var x =&gt;{ console.log(y); }&quot;, &quot;public&quot;: false } ] </code></pre>
[ { "answer_id": 74121294, "author": "Rutger Kassies", "author_id": 1755432, "author_profile": "https://Stackoverflow.com/users/1755432", "pm_score": 3, "selected": true, "text": ".plot(" }, { "answer_id": 74121924, "author": "wl_", "author_id": 8521115, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6243279/" ]
74,120,815
<p>have a problem with authorization in clickhouse, my os Ubuntu 18.04. I can connect with clickhouse-client.</p> <pre><code>clickhouse-client --user=dev --password=dev123 &lt;jemalloc&gt;: Number of CPUs detected is not deterministic. Per-CPU arena disabled. ClickHouse client version 22.8.5.29 (official build). Connecting to localhost:9000 as user dev. Connected to ClickHouse server version 22.8.5 revision 54460. </code></pre> <p>But if i try connect to web - i get error.</p> <pre><code>curl http://localhost:8123/?user=dev&amp;password=dev123 Code: 516. DB::Exception: dev: Authentication failed: password is incorrect or there is no user with such name. (AUTHENTICATION_FAILED) (version 22.8.5.29 (official build)) </code></pre> <p>What is the problem with authorization on port 8123? Do I need to create a specific user for access, or do I need to somehow add rights to connect?</p>
[ { "answer_id": 74121294, "author": "Rutger Kassies", "author_id": 1755432, "author_profile": "https://Stackoverflow.com/users/1755432", "pm_score": 3, "selected": true, "text": ".plot(" }, { "answer_id": 74121924, "author": "wl_", "author_id": 8521115, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16678569/" ]
74,120,817
<p>This is kind of a challenge, as I'm sure there must be a better way to do this but I'm not able to find it.</p> <p>Given a string, I want to split it into two strings by a given index. For instance:</p> <pre><code>input: - string: &quot;helloworld&quot; - index: 5 output: [&quot;hello&quot;, &quot;world&quot;] </code></pre> <p>An easy way is to make two slices, but isn't there a more direct way like splitting by a regex or something? I would like to achieve my purpose with a single instruction.</p> <p>The non-elegant way:</p> <pre class="lang-js prettyprint-override"><code>const str = &quot;helloworld&quot;; const [ str1, str2 ] = [ str.substring(0, 5), str.substring(5) ]; </code></pre>
[ { "answer_id": 74120881, "author": "boki_bo", "author_id": 3419330, "author_profile": "https://Stackoverflow.com/users/3419330", "pm_score": -1, "selected": false, "text": "const splitAt = (index, input) => [input.slice(0, index), input.slice(index)]\n" }, { "answer_id": 74120885...
2022/10/19
[ "https://Stackoverflow.com/questions/74120817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/972197/" ]
74,120,826
<p>I want to print decimal numbers from 0.1 to 0.100 In a loop, how can you print with increment?</p> <pre><code>for(decimal i=0.1;i&lt;=0.100;i++) { console.writeline(i); } </code></pre> <p>My decimal value getting change from 0.10 to 1.0.</p> <p>want to print 0.1 , 0.2, 0.3... 0.10,0.11, 0.12...0.100</p>
[ { "answer_id": 74120942, "author": "D A", "author_id": 13840530, "author_profile": "https://Stackoverflow.com/users/13840530", "pm_score": -1, "selected": false, "text": "for(int i=1;i<=100;i++)\n {\n Console.WriteLine(\"0.\"+ (i<10 ? i+\"0\": i.ToString()));\n }\n}\n" }, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74120826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19901465/" ]
74,120,839
<p>Here is my code. In the excel file, it should have 4 tables, including date = 1/3,1/7,1/14,1/21. I have run the query, it showed 4 results. However, when I wrote to the excel, the file only has one table, which was date = 1/3. I'm wondering how can I correct this, thanks!</p> <pre><code> import pyodbc import pandas as pd from datetime import datetime,timedelta cnxn = pyodbc.connect('DRIVER=xx; SERVER=xx; DATABASE=xx; UID=xx; PWD=xx') cursor = cnxn.cursor() query=&quot;&quot;&quot; declare @START_ORDATE DATETIME declare @END_ORDATE DATETIME set @START_ORDATE ='2022-01-03 00:00:00:000' set @END_ORDATE ='2022-01-24 00:00:00:000' WHILE @START_ORDATE&lt;=@END_ORDATE BEGIN select xx,xx,xx... set @START_ORDATE = @START_ORDATE + 7 END &quot;&quot;&quot; df = pd.read_sql_query(query, cnxn) writer = pd.ExcelWriter('test1.xlsx') df.to_excel(writer, sheet_name='test000') writer.save() </code></pre>
[ { "answer_id": 74120918, "author": "Phippre", "author_id": 3901046, "author_profile": "https://Stackoverflow.com/users/3901046", "pm_score": -1, "selected": false, "text": "writer = pd.ExcelWriter('test1.xlsx')\nfor x in df:\n df.to_excel(writer, sheet_name='test000')\nwriter.save()\n...
2022/10/19
[ "https://Stackoverflow.com/questions/74120839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12943251/" ]
74,120,866
<p>I have table with three input select and one button , so after I click on button I want to enable respective input to it, also change text of button and it should work individually for all rows, I have tried some methods but it doesn't very helpful.</p> <pre><code> &lt;input placeholder=&quot;&quot; onChange={console.log(&quot;something&quot;)} className=&quot;engineer-input&quot; disabled={true} /&gt; {1 ? ( &lt;button className=&quot;btnassign&quot; onClick={console.log(&quot;show assign&quot;)} &gt; Assign &lt;/button&gt; ) : ( &lt;&gt; &lt;button className=&quot;btnassign&quot;&gt;Allocated&lt;/button&gt; &lt;/&gt; )} </code></pre> <p>Here is the link to code - <a href="https://codesandbox.io/s/cranky-mendel-t94y70?file=/src/App.js:1650-2032" rel="nofollow noreferrer">https://codesandbox.io/s/cranky-mendel-t94y70?file=/src/App.js:1650-2032</a></p>
[ { "answer_id": 74121082, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 2, "selected": true, "text": "state" }, { "answer_id": 74121127, "author": "Lollergalad", "author_id": 11660414, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17723109/" ]
74,120,880
<p>I am logging the function name in my application logs using <code>%(funcName)</code>, but this only captures the function name which executes the code.</p> <p>let's say that func_C is called form func_B and func_B is being called from func_A, then i would also like this information in log. How can i fetch this info in my log message?</p>
[ { "answer_id": 74121082, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 2, "selected": true, "text": "state" }, { "answer_id": 74121127, "author": "Lollergalad", "author_id": 11660414, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5370631/" ]
74,120,882
<p><a href="https://i.stack.imgur.com/D8Q3l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D8Q3l.png" alt="Visual studio shows no update button to update the Nuget package manager, but when i try to install Microsoft.EntityFrameworkCore.SqlServer i'm getting a error saying update the nuget manager by going to particular website (https://www.nuget.org/downloads)" /></a></p> <p>Visual studio shows no update button to update the Nuget package manager, but when i try to install Microsoft.EntityFrameworkCore.SqlServer i'm getting a error saying update the nuget manager by going to particular website (<a href="https://www.nuget.org/downloads" rel="nofollow noreferrer">https://www.nuget.org/downloads</a>)</p>
[ { "answer_id": 74121082, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 2, "selected": true, "text": "state" }, { "answer_id": 74121127, "author": "Lollergalad", "author_id": 11660414, "author_profile...
2022/10/19
[ "https://Stackoverflow.com/questions/74120882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16006347/" ]
74,120,887
<p>I have a program where an <code>QJSEngine</code> object is used with several different threads. There should be no concurrent access - a thread is created, calling or evaluating something, and then this thread is deleted.</p> <p>However there are random crashes of program while using <code>QJSEngine</code>. All crashes are occured inside the private <code>QJSEngine</code> functions related to allocating or freeing memory. Example:</p> <pre><code>// QV4::PersistentValueStorage::allocate() (qv4persistent.cpp): Value *PersistentValueStorage::allocate() { Page *p = static_cast&lt;Page *&gt;(firstPage); while (p) { if (p-&gt;header.freeList != -1) break; p = p-&gt;header.next; } if (!p) p = allocatePage(this); Value *v = p-&gt;values + p-&gt;header.freeList; p-&gt;header.freeList = v-&gt;int_32(); // !!! Get SEGFAULT here // .... } </code></pre> <p>I've found a <a href="https://bugreports.qt.io/browse/QTBUG-83410" rel="nofollow noreferrer">bugreport</a> that is similar to my problem. The reporter provided the minimal code that reproduces the problem:</p> <pre><code>#include &lt;QCoreApplication&gt; #include &lt;QJSEngine&gt; #include &lt;QThread&gt; #include &lt;QTimer&gt; int main(int argc, char** argv) { QCoreApplication app(argc, argv); QJSEngine engine; engine.installExtensions(QJSEngine::ConsoleExtension); engine.evaluate(&quot;var iteration = 0;&quot;); auto function = engine.evaluate(R&quot;(( function() { if (++iteration % 100 == 0) console.log(iteration); } ))&quot;); QThread thread; thread.start(); QTimer timer; QObject::connect(&amp;timer, &amp;QTimer::timeout, &amp;engine, [&amp;]{function.call();}, Qt::DirectConnection); timer.moveToThread(&amp;thread); // Comment it if you want to test QJSEngine in the main thread QMetaObject::invokeMethod(&amp;timer, &quot;start&quot;, Q_ARG(int, 0)); return app.exec(); } </code></pre> <p>Doing the same thing in the main thread (thread where <code>QJSEngine</code> was created) does not crash the program.</p> <p>Could you please tell me how to make <code>QJSEngine</code> thread-safe for this situation? The reported provided template functions <code>safeEngineCall()</code> to wrap engine calls in blocking queue but I can't understand how to use it.</p> <p>Thanks in advance.</p> <p><strong>UPD:</strong> I had an idea to wrap <code>QJSValue::call()</code> to a thread-safe function to force it call in the <code>QJSEngine</code>'s object thread by using <code>QMetaObject::invokeMethod()</code>:</p> <p><strong>threadsafeqjsengine.h</strong></p> <pre><code>class ThreadSafeQJSEngine : public QObject { Q_OBJECT QJSEngine* m_engine; public: ThreadSafeQJSEngine(QObject *parent = Q_NULLPTR); virtual ~ThreadSafeQJSEngine(); // ... QJSValue call(QJSValue value, const QJSValueList&amp; args); // ... private slots: inline QJSValue call_imp(QJSValue value, const QJSValueList&amp; args) { return value.engine() == m_engine ? value.call(args) : QJSValue(); } // ... }; </code></pre> <p><strong>threadsafeqjsengine.cpp</strong></p> <pre><code>ThreadSafeQJSEngine::ThreadSafeQJSEngine(QObject *parent) : QObject(parent) { m_engine = new QJSEngine; } ThreadSafeQJSEngine::~ThreadSafeQJSEngine() { delete m_engine; } QJSValue ThreadSafeQJSEngine::call(QJSValue value, const QJSValueList &amp;args) { if (QThread::currentThread() != this-&gt;thread()) { QJSValue result; QMetaObject::invokeMethod(this, &quot;call_imp&quot;, Qt::BlockingQueuedConnection, Q_RETURN_ARG(QJSValue, result), Q_ARG(QJSValue, value), Q_ARG(const QJSValueList&amp;, args) ); return result; } else { return call_imp(value, args); } } // ... </code></pre> <p><strong>main.cpp</strong></p> <pre><code>int main(int argc, char** argv) { QCoreApplication app(argc, argv); ThreadSafeQJSEngine engine; // The same as before // ... QObject::connect(&amp;timer, &amp;QTimer::timeout, &amp;engine, [&amp;]{engine.call(function);}, Qt::DirectConnection); // The same as before // ... } </code></pre> <p>But the problem is not gone and it crashes as usual. What am I doing wrong?</p>
[ { "answer_id": 74231492, "author": "Nikita", "author_id": 9540586, "author_profile": "https://Stackoverflow.com/users/9540586", "pm_score": 0, "selected": false, "text": "QJSEngine" }, { "answer_id": 74489690, "author": "Maxim Paperno", "author_id": 3246449, "author_p...
2022/10/19
[ "https://Stackoverflow.com/questions/74120887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9540586/" ]
74,120,913
<p>I am observing some weired issue. I am not sure whether it is lack of my knowledge in spark or what.</p> <p>I have a dataframe as shown in below code. I create a tempview from it and I am observing that after merge operation, that tempview becomes empty. Not sure why.</p> <pre><code>val myDf = getEmployeeData() myDf.createOrReplaceTempView(&quot;myView&quot;) // Result1: Below lines display all the records myDf.show() spark.Table(&quot;myView&quot;).show() // performing merge operation val sql = s&quot;&quot;&quot;MERGE INTO employee AS a USING myView AS b ON a.Id = b.Id WHEN MATCHED THEN UPDATE SET * WHEN NOT MATCHED THEN INSERT *&quot;&quot;&quot; spark.sql(sql) // Result2: ISSUE is here. myDf &amp; mvView both are empty myDf.show() spark.Table(&quot;myView&quot;).show() </code></pre> <p><strong>Edit</strong></p> <p>getEmployeeData method performs join between two dataframes and returns the result.</p> <pre><code>df1.as(df1Alias).join(df2.as(df2Alias), expr(joinString), &quot;inner&quot;).filter(finalFilterString).select(s&quot;$df1Alias.*&quot;) </code></pre>
[ { "answer_id": 74123605, "author": "Kombajn zbożowy", "author_id": 2890093, "author_profile": "https://Stackoverflow.com/users/2890093", "pm_score": 3, "selected": true, "text": ".show" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74120913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2988458/" ]
74,120,927
<p>Using Scrapy and Scrapy shell in python to scrape the feature image from this website <a href="https://www.thrillist.com/travel/nation/all-the-ways-to-cool-off-in-austin" rel="nofollow noreferrer">https://www.thrillist.com/travel/nation/all-the-ways-to-cool-off-in-austin</a> but it returns this <code>data:image/gif;base64,R0</code> instead of src of the image, I need the help of someone if any one tell me the way to fix this to get src of the image</p> <p>Here is my Code</p> <pre><code>Feature_Image = [i.strip() for i in response.xpath('//*[@id=&quot;main-content&quot;]/article/div/div/div[2]/div[1]/picture/img/@src').getall()][0] </code></pre>
[ { "answer_id": 74121873, "author": "Alexander", "author_id": 17829451, "author_profile": "https://Stackoverflow.com/users/17829451", "pm_score": 1, "selected": false, "text": ">>> link = response.xpath(\"//div[@data-element-type='ParagraphMainImage']//img/@data-src\").get().split(\";\")[...
2022/10/19
[ "https://Stackoverflow.com/questions/74120927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20147022/" ]
74,120,959
<p>HERE'S THE TABLE I CREATED:</p> <pre><code>CREATE TABLE personal_info ( Person_name VARCHAR(30) NOT NULL, Date_of_Birth DATE, Join_date DATE, Join_year NUMBER, Person_address VARCHAR(75), Person_Post VARCHAR(15), Person_id VARCHAR(9) NOT NULL UNIQUE, Email_primary VARCHAR(30), Phone_primary NUMBER, Email_secondary VARCHAR(30), Phone_secondary NUMBER, Sal_grade CHAR(1) NOT NULL, Empl_id NUMBER NOT NULL, CONSTRAINT FK_Salary_Person FOREIGN KEY (Sal_grade) REFERENCES salary(Salary_grade) ON DELETE CASCADE, CONSTRAINT FK_Employee_Person FOREIGN KEY (Empl_id) REFERENCES employee(Employee_id) ON DELETE CASCADE, CONSTRAINT UC_Person_ID UNIQUE (Empl_id,Person_name) ); </code></pre> <p>HERE'S THE EMPLOYEE TABLE:</p> <pre><code>CREATE TABLE employee ( Employee_id NUMBER NOT NULL PRIMARY KEY, Employee_job_description VARCHAR(200), Proj_id NUMBER NOT NULL, Dep_id NUMBER NOT NULL ); ALTER TABLE employee ADD CONSTRAINT FK_project_employee FOREIGN KEY (Proj_id) REFERENCES PROJECTS(Project_id) ON DELETE CASCADE; ALTER TABLE employee ADD CONSTRAINT FK_dept_employee FOREIGN KEY (Dep_id) REFERENCES dept(Dept_id) ON DELETE CASCADE; CREATE SEQUENCE EMPID_SEQ1 MINVALUE 1 MAXVALUE 9999999 START WITH 10000 INCREMENT BY 4 CACHE 20; </code></pre> <p>I ALREADY INSERTED INTO THE EMPLOYEE TABLE, NO ISSUE.</p> <pre><code>INSERT INTO employee (Employee_id, Employee_job_description, Proj_id, Dep_id) VALUES(EMPID_SEQ1.NEXTVAL,'SENIOR VICE PRESIDENT',501,1); </code></pre> <p>BUT WHEN I TRY TO INSERT INTO THE PERSONAL_INFO TABLE:</p> <pre><code>/* Formatted on 19-Oct-22 11:58:19 AM (QP5 v5.256.13226.35538) */ INSERT INTO PERSONAL_INFO (Empl_id, Person_name, Date_of_Birth, Join_date, Join_year, Person_address, Sal_grade, Actual_salary, Person_Post, PERSON_ID, Email_primary, Phone_primary, Email_secondary, Phone_secondary) VALUES (EMPID_SEQ1.CURRVAL, 'Mr. FF', TO_DATE ('1980/05/03 21:02:44', 'yyyy/mm/dd hh24:mi:ss'), TO_DATE ('2000/05/03 21:02:44', 'yyyy/mm/dd hh24:mi:ss'), TO_CHAR (Join_DATE, 'YYYY'), 'Banani,Dhaka.', 'D', 150000, 'SVP', TO_CHAR(TO_CHAR(Join_YEAR) || TO_CHAR (EMPID_SEQ1.CURRVAL)), 'FF@bank.com', 01234567891, 'FFF@bank.com', 99998882222); </code></pre> <p>I GET THE AFORMENTIONED ERROR WHILE INSERTING THE PERSON_ID UNIQUE KEY VALUE. BASICALLY I WANTED THE PERSON_ID TO LOOK SOMETHING LIKE '200710016'. JOINING YEAR FOLLOWED BY EMPLOYEE ID.</p> <p>BUT IT'S TELLING ME THAT THE JOIN_YEAR COLUMN IS NOT ALLOWED HERE.</p>
[ { "answer_id": 74121069, "author": "Littlefoot", "author_id": 9097906, "author_profile": "https://Stackoverflow.com/users/9097906", "pm_score": 2, "selected": true, "text": "nextval" }, { "answer_id": 74123525, "author": "MT0", "author_id": 1509264, "author_profile": ...
2022/10/19
[ "https://Stackoverflow.com/questions/74120959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12616548/" ]
74,120,975
<p>Is there a way to call the constructor of a class, given the pointer-type of that class type as the template parameter?</p> <pre><code>MyClass&lt;AnotherClass*&gt; =&gt; how to call the default constructor of AnotherClass in MyClass? </code></pre> <p>This one does obviously not work (doesnt compile), because in <code>GetNew</code> the <code>new T</code> and the return type T don't fit together. What would be needed is some kind of &quot;type dereferencing&quot; to come to the class type, given the pointer type.</p> <pre><code>class AnotherClass {}; template &lt;class T&gt; class MyClass { public: // this does obviously not compile virtual T GetNew() { return new T; // how let T be AnotherClass* and to create an AnotherClass instance here? } }; int main() { // this does not compile: MyClass&lt;AnotherClass*&gt; tmp; // here, AnotherClass is **pointer** type AnotherClass* a = tmp.GetNew(); } </code></pre> <p>A workaround would be to use the class type as the template parameter and use poiter types as return types. But this changes the interface, so I would still like a solution to pointer template type.</p> <pre><code>class AnotherClass {}; template &lt;class T&gt; class MyClass2 { public: virtual T* GetNew() { return new T; } }; int main() { // this does work: MyClass2&lt;AnotherClass&gt; tmp2; // here, AnotherClass is **not** pointer type AnotherClass* b = tmp2.GetNew(); } </code></pre> <p>Another workaround could be to use a factory or similar, but I would like to use the default constructor without additional helping structures.</p>
[ { "answer_id": 74121015, "author": "songyuanyao", "author_id": 3309790, "author_profile": "https://Stackoverflow.com/users/3309790", "pm_score": 3, "selected": true, "text": "std::remove_pointer" }, { "answer_id": 74122313, "author": "Caleth", "author_id": 2610810, "a...
2022/10/19
[ "https://Stackoverflow.com/questions/74120975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2393191/" ]
74,120,993
<p>On MacOS terminal, when I run this command:</p> <pre><code>$ which clang </code></pre> <p>I got:</p> <pre><code>clang version 10.0.0 Target: x86_64-apple-darwin21.6.0 Thread model: posix InstalledDir: /Users/myusername/anaconda3/bin </code></pre> <p>But,I have another clang version on my Mac, the directory is:</p> <pre><code>/Library/Developer/CommandLineTools/usr/bin/clang </code></pre> <p>So, how to change my current clang directory (/Users/myusername/anaconda3/bin) to a new clang directory (/Library/Developer/CommandLineTools/usr/bin/clang)?</p> <p>and I am wondering that why my clang is defaulted to install in Anaconda?</p>
[ { "answer_id": 74121015, "author": "songyuanyao", "author_id": 3309790, "author_profile": "https://Stackoverflow.com/users/3309790", "pm_score": 3, "selected": true, "text": "std::remove_pointer" }, { "answer_id": 74122313, "author": "Caleth", "author_id": 2610810, "a...
2022/10/19
[ "https://Stackoverflow.com/questions/74120993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279656/" ]
74,121,008
<p>I made a simple data as follow:</p> <pre><code>data&lt;-data.frame(id=c(1,1,1,2,2,2,3,3,4,4), a=c(0,0,1,0,0,0,1,1,1,1), b=c(1,0,0,0,0,0,0,1,1,0)) </code></pre> <p><code>id</code> stands for specific id number of a person. What I want to do now is delete the whole <code>id</code> if <code>a</code>equals 1. Aso, I want to delete the whole <code>id</code> if <code>b</code> equals 1. In this example, the desired output should be like this:</p> <pre><code>data&lt;-data.frame(id=c(2,2,2), a=c(0,0,0), b=c(0,0,0)) </code></pre> <p>In my actual data, there are hundreds of <code>id</code>,so I want to know method to do this.</p>
[ { "answer_id": 74121088, "author": "maydin", "author_id": 7224354, "author_profile": "https://Stackoverflow.com/users/7224354", "pm_score": 3, "selected": true, "text": "Base R" }, { "answer_id": 74121914, "author": "Maël", "author_id": 13460602, "author_profile": "ht...
2022/10/19
[ "https://Stackoverflow.com/questions/74121008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17930715/" ]
74,121,075
<p>This is the code of my controller :</p> <pre><code>private readonly ILMS_Service lms_client; private UrlHelper urlHelper; public PackagesController(ILMS_Service client, UrlHelper _urlHelper) { lms_client = client; urlHelper = _urlHelper; } public PackagesController() { lms_client = new LMS_ServiceClient(); urlHelper = new UrlHelper(Request.RequestContext); } [HttpPost] public ActionResult EditPackageDetails( int packageID, string package_name, int unit_type, int product_id, int unit_count, string description ) { lms_client.EditPackageDetails( packageID, package_name, unit_type, product_id, unit_count, description); var url = urlHelper.Action(&quot;PackagesList&quot;, &quot;Packages&quot;); return Json(new { statusCode = (int)HttpStatusCode.OK, redirectURL = url }); } </code></pre> <p>The <code>urlBuilder.Action(&quot;PackagesList&quot;, &quot;Packages&quot;);</code> returns null during the test run. I am trying to fake the <code>UrlHelper</code> class with a fake return value by assigning it to the controller but it doesn't seem to work. Here is the current implementation of my test:</p> <pre><code>private readonly PackagesController _controller_Packages; private readonly ILMS_Service _lms_service; private readonly HttpContextBase httpContext; private readonly HttpResponseBase httpResponse; private readonly HttpSessionStateBase httpSession; private readonly UrlHelper urlBuilder; public Packages_UnitTest() { // Mock WCF _lms_service = A.Fake&lt;ILMS_Service&gt;(); // Fake session httpContext = A.Fake&lt;HttpContextBase&gt;(); httpResponse = A.Fake&lt;HttpResponseBase&gt;(); httpSession = A.Fake&lt;HttpSessionStateBase&gt;(); urlBuilder = A.Fake&lt;UrlHelper&gt;(); //SUTs _controller_Packages = new PackagesController(_lms_service, urlHelper); A.CallTo(() =&gt; httpContext.Response).Returns(httpResponse); A.CallTo(() =&gt; httpContext.Session).Returns(httpSession); } [TestMethod] public void should_EditPackageDetails() { // Arrange int packageID = 1; string package_name = &quot;Test package&quot;; int unit_type = 1; int product_id = 1; int unit_count = 10; string description = &quot;Sample test description&quot;; int expected_statusCode = (int)HttpStatusCode.OK; string expected_page_destination = &quot;/Packages/PackagesList&quot;; var context = new ControllerContext(new RequestContext(httpContext, new RouteData()), _controller_Packages); _controller_Packages.ControllerContext = context; A.CallTo(() =&gt; urlBuilder.Action(&quot;PackagesList&quot;, &quot;Packages&quot;)) .Returns(&quot;/Packages/PackagesList&quot;); // Act _ = A.CallTo(() =&gt; _lms_service.EditPackageDetails( A&lt;int&gt;.Ignored, A&lt;string&gt;.Ignored, A&lt;int&gt;.Ignored, A&lt;int&gt;.Ignored, A&lt;int&gt;.Ignored, A&lt;string&gt;.Ignored )); var _editPackage = _controller_Packages.EditPackageDetails( packageID, package_name, unit_type, product_id, unit_count, description ) as JsonResult; dynamic result = _editPackage.Data; // Assert Assert.AreEqual(expected_statusCode, result.statusCode); Assert.AreEqual(expected_page_destination, result.redirectURL); } </code></pre> <p>With this test, it is still returning null, not <code>&quot;/Packages/PackagesList&quot;</code>. How can I fake <code>UrlHelper</code> with it returning <code>&quot;/Packages/PackagesList&quot;</code> as the value with FakeitEasy? Any help would be appreciated. I have an ASP.NET MVC 4, MSTest, and FakeitEasy mocking framework. Thanks!</p>
[ { "answer_id": 74121088, "author": "maydin", "author_id": 7224354, "author_profile": "https://Stackoverflow.com/users/7224354", "pm_score": 3, "selected": true, "text": "Base R" }, { "answer_id": 74121914, "author": "Maël", "author_id": 13460602, "author_profile": "ht...
2022/10/19
[ "https://Stackoverflow.com/questions/74121075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8331324/" ]
74,121,080
<p>I'm new in world of dart and I have problem with this:</p> <pre class="lang-dart prettyprint-override"><code>import 'dart:io'; void main() { print('Please your name:'); String name = stdin.readLineSync(); print('$name'); } </code></pre> <pre><code>I/flutter ( 7962): Please your name: I/flutter ( 7962): null </code></pre> <p>Every time the value is null.</p> <p><img src="https://i.stack.imgur.com/ZA8D4.png" alt="" /></p>
[ { "answer_id": 74121088, "author": "maydin", "author_id": 7224354, "author_profile": "https://Stackoverflow.com/users/7224354", "pm_score": 3, "selected": true, "text": "Base R" }, { "answer_id": 74121914, "author": "Maël", "author_id": 13460602, "author_profile": "ht...
2022/10/19
[ "https://Stackoverflow.com/questions/74121080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279739/" ]
74,121,094
<p>I am trying to integrate <strong>Jitsi Android SDK</strong> for video Conferences on my app but it crashes as soon as I join/create a meeting. I am using Android Version -</p> <pre><code>Android Studio Dolphin | 2021.3.1 Patch 1 Build #AI-213.7172.25.2113.9123335, built on September 30, 2022 Runtime version: 11.0.13+0-b1751.21-8125866 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 11 10.0 </code></pre> <p>Here's the java code below for my DashboardActivity.</p> <pre><code>package com.skymeet.videoConference; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import androidx.appcompat.app.AppCompatActivity; import org.jitsi.meet.sdk.JitsiMeet; import org.jitsi.meet.sdk.JitsiMeetActivity; import org.jitsi.meet.sdk.JitsiMeetConferenceOptions; import java.net.MalformedURLException; import java.net.URL; public class DashboardActivity extends AppCompatActivity { EditText codeBox; Button joinBtn, shareBtn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dashboard); codeBox = findViewById(R.id.codeBox); joinBtn = findViewById(R.id.joinBtn); shareBtn = findViewById(R.id.shareBtn); // not implemented yet URL serverURL = null; try { serverURL = new URL(&quot;https://meet.jit.si&quot;); } catch (MalformedURLException e) { e.printStackTrace(); } JitsiMeetConferenceOptions defaultOptions = new JitsiMeetConferenceOptions.Builder() .setServerURL(serverURL) .setFeatureFlag(&quot;welcomepage.enabled&quot;, false) .build(); JitsiMeet.setDefaultConferenceOptions(defaultOptions); joinBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { JitsiMeetConferenceOptions options = new JitsiMeetConferenceOptions.Builder() .setRoom(codeBox.getText().toString()).setFeatureFlag(&quot;welcomepage.enabled&quot;, false) .build(); JitsiMeetActivity.launch(DashboardActivity.this, options); } }); } } </code></pre> <p>I have implemented this code with help from <a href="https://jitsi.github.io/handbook/docs/dev-guide/dev-guide-android-sdk/" rel="nofollow noreferrer">https://jitsi.github.io/handbook/docs/dev-guide/dev-guide-android-sdk/</a></p> <p>On the Jitsi Android docs they have mentioned this way <strong>but this does not imports Jitsi Android SDK to our project.</strong></p> <p><em>The repository typically goes into the <code>build.gradle</code> file in the root of your project: build.gradle</em></p> <pre><code>allprojects { repositories { maven { url &quot;https://github.com/jitsi/jitsi-maven-repository/raw/master/releases&quot; } google() mavenCentral() maven { url 'https://www.jitpack.io' } } } </code></pre> <p><em>Dependency definitions belong in the individual module <code>build.gradle</code> files:</em></p> <pre><code>dependencies { // (other dependencies) implementation ('org.jitsi.react:jitsi-meet-sdk:+') { transitive = true } } </code></pre> <p>Instead, we used to get a warning like this below while syncing the Gradle files. <code>Failed to resolve: org.jitsi.react:jitsi-meet-sdk:6.1.0</code> ~~<br /> <a href="https://i.stack.imgur.com/G7ihW.jpg" rel="nofollow noreferrer">Check Gradle Warning Screenshot</a></p> <p>This can be fixed by placing the repository on <code>settings.gradle</code> as below</p> <pre><code>dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url &quot;https://github.com/jitsi/jitsi-maven-repository/raw/master/releases&quot; } maven { url &quot;https://maven.google.com&quot; } } } </code></pre> <p>After everything is successfully built &amp; installed on devices, my app crashes as soon as I create or join the meeting. Not able to figure out what is causing my application to crash.</p> <p>After crashing the error comes this way on my mobile phone. <a href="https://i.stack.imgur.com/5RGGn.jpg" rel="nofollow noreferrer">Check Error Screenshot on mobile</a></p> <pre><code>java.lang.RuntimeException: Unable to start service org.jitsi.meet.sdk Jits MeetOngoingConferenceService@dc6a12a with Intent(cmp=com.skymeet.videoConference/org.jits i.meet.sdk.JitsiMeetOngoingConferenceService (has extras)}: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(chann el-JitsiOngoingConferenceChannel shortcut=null contentView=null vibrate-null sound=null defaults=0x0 flags=0xa color=0x00000000 category=call actions=2 vis=PUBLIC) at android.app.ActivityThread.handleServiceArgs(Activit yThread.java:4802) at android.app.ActivityThread.access$2100(ActivityThr ead.java:276) at android.app.ActivityThread$H.handleMessage(Activi tyThread.java:2156) at android.os.Handler.dispatchMessage(Handler.java:1 06) at android.os.Looper.loopOnce (Looper.java:210) at android.os.Looper.loop(Looper.java:299) at android.app.ActivityThread.main(ActivityThread.java: 8213) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArg sCaller.run(RuntimeInit.java:556) at com.android.internal.os.ZygoteInit.main(ZygoteInit.ja va:1045) Caused by: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel-JitsiOngoingConfere nceChannel shortcut-null contentView=null vibrate-null sound-null defaults=0x0 flags=0xa color=0x00000000 category=call actions=2 vis PUBLIC) at android.app.NotificationManager.fixNotification(Noti ficationManager.java:699) at android.app.NotificationManager.notifyAsUser(Notifi cationManager.java:678) at android.app.NotificationManager.notify(Notification Manager.java:627) at android.app.NotificationManager.notify(Notification Manager.java:603) at org.jitsi.meet.sdk.JitsiMeetOngoingConferenceServi ce.onStartCommand(JitsiMeetOngoingConferenceS ervice.java:135) at android.app.ActivityThread.handleServiceArgs(Activit yThread.java:4784) ... 9 more </code></pre> <p>Check video for further error references - <a href="https://drive.google.com/file/d/1tXZOtMYQ_Oi1w4UtJ5olyupR13E2HrpV/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1tXZOtMYQ_Oi1w4UtJ5olyupR13E2HrpV/view?usp=sharing</a></p> <p>Can someone please help me with this? I will be grateful enough. Thank you!</p>
[ { "answer_id": 74121088, "author": "maydin", "author_id": 7224354, "author_profile": "https://Stackoverflow.com/users/7224354", "pm_score": 3, "selected": true, "text": "Base R" }, { "answer_id": 74121914, "author": "Maël", "author_id": 13460602, "author_profile": "ht...
2022/10/19
[ "https://Stackoverflow.com/questions/74121094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15081383/" ]
74,121,134
<p>while I am running <code>python manage.py collectstatic --no-input</code> I am getting a DB connection issue. i want to collect statics without a DB connection to dockerize my Django app. with DB connection it's working fine.</p> <p>traceback</p> <pre><code>Traceback (most recent call last): File &quot;C:\projects\test-env\lib\site-packages\django\db\backends\utils.py&quot;, line 84, in _execute return self.cursor.execute(sql, params) File &quot;C:\projects\test-env\lib\site-packages\django\db\backends\sqlite3\base.py&quot;, line 423, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such table: information_schema.tables The above exception was the direct cause of the following exception: Traceback (most recent call last): File &quot;C:\projects\test-app\test\manage.py&quot;, line 22, in &lt;module&gt; main() File &quot;C:\projects\test-app\test\manage.py&quot;, line 18, in main execute_from_command_line(sys.argv) File &quot;C:\projects\test-env\lib\site-packages\django\core\management\__init__.py&quot;, line 419, in execute_from_command_line utility.execute() File &quot;C:\projects\test-env\lib\site-packages\django\core\management\__init__.py&quot;, line 395, in execute django.setup() File &quot;C:\projects\test-env\lib\site-packages\django\__init__.py&quot;, line 24, in setup apps.populate(settings.INSTALLED_APPS) File &quot;C:\projects\test-env\lib\site-packages\django\apps\registry.py&quot;, line 122, in populate app_config.ready() File &quot;C:\projects\test-env\lib\site-packages\django_tenants\apps.py&quot;, line 46, in ready validate_extra_extensions() File &quot;C:\projects\test-env\lib\site-packages\django_tenants\utils.py&quot;, line 272, in validate_extra_extensions cursor.execute( File &quot;C:\projects\test-env\lib\site-packages\django\db\backends\utils.py&quot;, line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File &quot;C:\projects\test-env\lib\site-packages\django\db\backends\utils.py&quot;, line 75, in _execute_with_wrappers return executor(sql, params, many, context) File &quot;C:\projects\test-env\lib\site-packages\django\db\backends\utils.py&quot;, line 84, in _execute return self.cursor.execute(sql, params) File &quot;C:\projects\test-env\lib\site-packages\django\db\utils.py&quot;, line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File &quot;C:\projects\test-env\lib\site-packages\django\db\backends\utils.py&quot;, line 84, in _execute return self.cursor.execute(sql, params) File &quot;C:\projects\test-env\lib\site-packages\django\db\backends\sqlite3\base.py&quot;, line 423, in execute return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: no such table: information_schema.tables </code></pre>
[ { "answer_id": 74121088, "author": "maydin", "author_id": 7224354, "author_profile": "https://Stackoverflow.com/users/7224354", "pm_score": 3, "selected": true, "text": "Base R" }, { "answer_id": 74121914, "author": "Maël", "author_id": 13460602, "author_profile": "ht...
2022/10/19
[ "https://Stackoverflow.com/questions/74121134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197109/" ]
74,121,142
<p>I have an array of numbers with some 0 values. I want to fill 0 with the linear difference between two valid values.</p> <p>let arr = [10,0,0,16,17,0,23] I am using the below code to calculate the linear difference between the two data points if they have zero between them like 10 and 16 have two indexes with 0, if need any further info regarding this data feel free to comment below any answers are accepted that can help.</p> <pre><code><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>let arr = [10,0,0,16,17,0,23] //required result [10,12,14,16,17,20,23] // here is my code const getValueIf = (item, index, array) =&gt; { const lastindex = array.length - 1; const zeroWithFirst = index !== 0 &amp;&amp; item === 0; const zeroWithLast = index !== lastindex &amp;&amp; item === 0; const firstZero = index === 0 &amp;&amp; item === 0; if (firstZero) { return array[index] = ifZeroToNumber(array, index) ; } if (zeroWithFirst || zeroWithLast) { if (zeroWithFirst &amp;&amp; !zeroWithLast) { return array[index - 1]; } if (!zeroWithFirst &amp;&amp; zeroWithLast) { return array[index + 1] === 0 ? array[index + 2] : array[index + 1]; } array[index] = (ifZeroToNumber(array, index) - array[index - 1]) / 2 + array[index - 1]; return ( (ifZeroToNumber(array, index) - array[index - 1]) / 2 + array[index - 1] ); } else { return item; } }; const ifZeroToNumber = (array, index) =&gt; { let num = 0; for (let i = 1; i &lt;= array.length; i++) { if (num === 0 &amp;&amp; array[index + i]) { num = array[index + i]; } } if (!num) { num = array[index - 1]; } return num; }; let removeZero = arr.map((value, index) =&gt; getValueIf(value, index, arr) ); console.log(removeZero)</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"&gt;&lt;/script&gt; &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </code></pre>
[ { "answer_id": 74121328, "author": "gog", "author_id": 3494774, "author_profile": "https://Stackoverflow.com/users/3494774", "pm_score": 3, "selected": true, "text": "function fill(a) {\n\n let start = -1\n let zero = false\n\n for (let i = 0; i < a.length; i++) {\n if (a...
2022/10/19
[ "https://Stackoverflow.com/questions/74121142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20157569/" ]
74,121,154
<p>Lets say i have two component parent and child and I'm trying to access the DOM element of Child component from parent component. But i'm facing issue of undefined native element.</p> <pre><code>export class ChildComponent implements OnInit,AfterViewInit{ @ViewChild('pdfData', { read: ElementRef }) domData: ElementRef; constructor() ngOnInit(): void { some code.. } ngAfterViewInit(): void { this.domData.nativeElement; } } </code></pre> <p>Child component DOM element</p> <pre><code>&lt;div #pdfData class=&quot;pdfData&quot;&gt; &lt;table *ngFor=&quot;let hubxReport of hubxReportList; let i=index&quot;&gt; &lt;tr&gt; &lt;th&gt;{{hubxReport.categoryName}} + &quot;Test&quot;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;{{column}}&lt;/th&gt; &lt;/tr&gt; &lt;tr *ngFor=&quot;let item of hubxReport.hubxDataItems&quot;&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;{{item.itemTitle}}&lt;/td&gt; &lt;td&gt;{{item.itemValue}}&lt;/td&gt; &lt;td&gt;{{item.itemUnit}}&lt;/td&gt; &lt;td&gt;{{item.normalRange}}&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>And below code is Parent component and I'm trying to access Child component DOM element and the issue comes here.</p> <pre><code>export class ParentComponent implements OnInit,AfterViewInit{ @ViewChild('pdfData',{ read: ElementRef }) pdf: ChildComponent ; constructor() ngOnit(): void{ some code... } ngAfterViewInit() { this.pdf.domData.nativeElement; console.log(this.pdf.domData.nativeElement) //undefine here } downloadPDF(isSubmit:any) { debugger let doc = new jsPDF(); let rows: Array&lt;any&gt; = []; let header: Array&lt;any&gt; = []; let medicineInfo: any; let physicianInfo: any; //this.isShow = true; //this.changeRef.detectChanges(); let content= this.pdf.domData.nativeElement; //undefine here let _elementHandlers = { '#editor':function(element,renderer){ return true; } }; doc.html(content.innerHTML,{ callback: function (doc) { doc.save(); }, x: 10, y: 80, // 'x': 15, // 'y': 15, width:190, 'elementHandlers':_elementHandlers }); } </code></pre> <p>And here is my Stackblitz <a href="https://stackblitz.com/edit/angular-ivy-jzatra?file=src%2Fapp%2FchildComponent%2Fchild.component.ts,src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html" rel="nofollow noreferrer">Link</a></p>
[ { "answer_id": 74121328, "author": "gog", "author_id": 3494774, "author_profile": "https://Stackoverflow.com/users/3494774", "pm_score": 3, "selected": true, "text": "function fill(a) {\n\n let start = -1\n let zero = false\n\n for (let i = 0; i < a.length; i++) {\n if (a...
2022/10/19
[ "https://Stackoverflow.com/questions/74121154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19669077/" ]
74,121,168
<p>I have used the below code to get the local alignment score between two strings using Smith-Waterman Algorithm. However, I'm getting the required output, I'm finding it difficult to save the result into some variable for further analysis.</p> <pre class="lang-py prettyprint-override"><code>import swalign def Local_Alignment(string1, string2): match_score = 100 mismatch_score = -100 matrix = swalign.NucleotideScoringMatrix(match_score, mismatch_score) lalignment_object = swalign.LocalAlignment(matrix) alignment_object = lalignment_object.align(string1, string2) return alignment_object.dump() string1 = &quot;ABCDEFGHIJKLMNOP&quot; string2 = &quot;CDGIKNOP&quot; temp = Local_Alignment(string1, string2) </code></pre> <p>Whenever I try to save the result into some variable, it simply stores a <code>None</code> value. Even though I tried storing the result in a text file, that also didn't work.</p>
[ { "answer_id": 74121328, "author": "gog", "author_id": 3494774, "author_profile": "https://Stackoverflow.com/users/3494774", "pm_score": 3, "selected": true, "text": "function fill(a) {\n\n let start = -1\n let zero = false\n\n for (let i = 0; i < a.length; i++) {\n if (a...
2022/10/19
[ "https://Stackoverflow.com/questions/74121168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20228490/" ]
74,121,186
<p>For some reason Finder on Mac doesn't come with create new file functionality. The fastest way I've found to create a new file is to drag the finder path into Terminal and create a file there... which is super annoying</p> <p>I wrote an apple script to automatically create a new file and bound it to a shortcut. It works perfectly, except that I can't figure out how to <em>open</em> the new file from within the applescript. I'm pretty sure the error stems from POSIX / UNIX paths but couldn't find a way to get this to work even when I put POSIX next to file, currentDir etc.</p> <p>Here's my script:</p> <pre><code>set file_name to display dialog &quot;File Name&quot; default answer &quot;untitled&quot; with icon note buttons {&quot;Cancel&quot;, &quot;Continue&quot;} default button &quot;Continue&quot; set file_name to (text returned of file_name) tell application &quot;Finder&quot; set theWin to window 1 set currentDir to POSIX path of (target of theWin as alias) make new file at (the target of the front window) as alias with properties {name:file_name} set currentPath to (currentDir &amp; file_name) as string open file currentPath end tell </code></pre> <p>The script creates the file, then errors out saying it can't find the file to open it.</p>
[ { "answer_id": 74126622, "author": "Mockman", "author_id": 7410243, "author_profile": "https://Stackoverflow.com/users/7410243", "pm_score": 0, "selected": false, "text": "set file_name to display dialog \"File Name\" default answer \"untitled\" with icon note buttons {\"Cancel\", \"Cont...
2022/10/19
[ "https://Stackoverflow.com/questions/74121186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7583953/" ]
74,121,216
<p>I have 7 Textboxes, and Data i have to fetch from Single col and 7 rows and assign to the 7 textboxes,</p> <p>E.g</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th><strong>DefectStatus</strong></th> </tr> </thead> <tbody> <tr> <td>None</td> </tr> <tr> <td>None</td> </tr> <tr> <td>None</td> </tr> </tbody> </table> </div> <pre><code>} OldbCommand = new OleDbCommand(&quot;SELECT DefectStatus FROM TblProductionData WHERE SerialNumber='&quot; + TxtSerialNo.Text.Trim() + &quot;'&quot;, ClsGlobals.con); OldbReader = OldbCommand.ExecuteReader(); } while ( OldbReader.Read()) { TxtCell1Status.Text = OldbReader.GetValue(0).ToString(); TxtCell2Status.Text = I dont know how to get value from second row } </code></pre>
[ { "answer_id": 74126622, "author": "Mockman", "author_id": 7410243, "author_profile": "https://Stackoverflow.com/users/7410243", "pm_score": 0, "selected": false, "text": "set file_name to display dialog \"File Name\" default answer \"untitled\" with icon note buttons {\"Cancel\", \"Cont...
2022/10/19
[ "https://Stackoverflow.com/questions/74121216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20155144/" ]
74,121,235
<p>I am new to Django and my current task is to upload a xml file with 16 fields and more than 60000 rows to a database in PostgreSQL. I used Django to connect to the Database and was able to create a table in the database. I also used XML Etree to parse the xml file. I am having trouble storing the data in the table that I created in the sql database.</p> <p>This is the code that I used to parse:</p> <pre><code>import xml.etree.ElementTree as ET def saveXML2db(): my_file = &quot;C:/Users/Adithyas/myproject/scripts/supplier_lookup.xml&quot; tree = ET.parse(my_file) root = tree.getroot() cols = [&quot;organization&quot;, &quot;code&quot;, &quot;name&quot;] rows = [] for i in root: organization = i.find(&quot;organization&quot;).text code = i.find(&quot;code&quot;).text name = i.find(&quot;name&quot;).text x = rows.append([organization, code, name]) data = &quot;&quot;&quot;INSERT INTO records(organization,code,name) VALUES(%s,%s,%s)&quot;&quot;&quot; x.save() saveXML2db() </code></pre> <p>the code runs without any error, but I am unable to store the data into the table in the SQL database.</p>
[ { "answer_id": 74121616, "author": "treuss", "author_id": 19838568, "author_profile": "https://Stackoverflow.com/users/19838568", "pm_score": 0, "selected": false, "text": "import psycopg2\n\ndef storeXmlToPostgres(xmldata):\n with psycopg2.connect(host=\"dbhost\", database=\"dbname\"...
2022/10/19
[ "https://Stackoverflow.com/questions/74121235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279779/" ]
74,121,238
<p>I have a collection as</p> <pre><code>[ { firstName: &quot;John&quot;, middleName: &quot;F&quot;, lastName: &quot;Kennedy&quot; }, { firstName: &quot;Barack&quot;, lastName: &quot;Obama&quot; } ] </code></pre> <p>I am trying to create a function that searches the collection by name. I need to concat the names before trying to find a match. I tried the following</p> <pre class="lang-js prettyprint-override"><code>User.aggregate([ { &quot;$project&quot;: { fullName: { &quot;$concat&quot;: [ &quot;$firstName&quot;, &quot; &quot;, &quot;$lastName&quot; ] } } }, { $match: { &quot;fullName&quot;: { $regex: /[a-z\\s]*oba[a-z\\s]*/i } } } ]) </code></pre> <p>It works for names without middle names. But I need this to work for names with middle names too. When I try to concat <code>middleName</code>, I get an error because the path <code>middleName</code> does not exist on all documents. I could not implement <code>$cond</code> and <code>$exists</code> operators properly make this work. Any kind of help is highly appreciated. Thanks!</p>
[ { "answer_id": 74121298, "author": "nimrod serok", "author_id": 18482310, "author_profile": "https://Stackoverflow.com/users/18482310", "pm_score": 2, "selected": true, "text": "$ifNull" }, { "answer_id": 74128634, "author": "user20042973", "author_id": 20042973, "aut...
2022/10/19
[ "https://Stackoverflow.com/questions/74121238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227171/" ]
74,121,246
<p>I'm working with Laravel 5.8 and I have this syntax:</p> <pre><code>@php($counter_foreach = 0) @foreach($memnames as $mem=&gt;$memname) @php @endphp @endforeach </code></pre> <p>Now when I run this, I get <strong>syntax error, unexpected 'endforeach' (T_ENDFOREACH)</strong> error:</p> <p><a href="https://i.stack.imgur.com/ZdBvD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZdBvD.png" alt="enter image description here" /></a></p> <p>But when I remove <code>@php @endphp</code>, and replace it with <code>html</code>, the error will be gone!</p> <p>So what's going wrong here?</p> <p>Is there anything wrong about using <code>@php</code> after <code>@foreach</code> in Laravel Blades?</p>
[ { "answer_id": 74121298, "author": "nimrod serok", "author_id": 18482310, "author_profile": "https://Stackoverflow.com/users/18482310", "pm_score": 2, "selected": true, "text": "$ifNull" }, { "answer_id": 74128634, "author": "user20042973", "author_id": 20042973, "aut...
2022/10/19
[ "https://Stackoverflow.com/questions/74121246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17119202/" ]
74,121,264
<p>We have the following dummy data frame that collects counts of warnings (based on a reason) for a given date:</p> <pre><code>temp = pd.DataFrame(np.array([['2022-10-13','one',123],['2022-10-13','two',77123], ['2022-10-13','three',451], ['2022-10-13','three',77]]), columns = ['date','reason','count']) </code></pre> <p>The problem is in the count column</p> <pre><code> date reason count 0 2022-10-13 one 123 1 2022-10-13 two 77123 2 2022-10-13 three 451 3 2022-10-13 three 77 </code></pre> <p>The data for reasons <strong>one</strong> and <strong>three</strong> needs to be scaled by 100 as it is stored in a minimized way on the database.</p> <p>Is there a way to traverse the cells and add '00' to the counts or multiply by 100 where reason is not equal to two? And end up with something like this:</p> <pre><code> date reason count 0 2022-10-13 one 12300 1 2022-10-13 two 77123 2 2022-10-13 three 45100 3 2022-10-13 three 7700 </code></pre> <p>How would this be achieved?</p>
[ { "answer_id": 74121321, "author": "T C Molenaar", "author_id": 8814131, "author_profile": "https://Stackoverflow.com/users/8814131", "pm_score": 3, "selected": true, "text": "count" }, { "answer_id": 74121331, "author": "TiTo", "author_id": 12934163, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74121264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8972207/" ]
74,121,269
<p>I have a c# console application where I need to take some command line arguments.</p> <p>For this reason I need a main method, instead of the non-main method that is currently there, and since I can't find any material on how to do it without.</p> <p>So, I tried just pasting some code into my newly created visual studio dotnet 6 c# application:</p> <pre><code>static void Main(string[] args) { Console.WriteLine(&quot;hi there&quot;); } </code></pre> <p>Which does'nt work. The code is not executed. How do I add a main method, so I can take some cmd arguments?</p>
[ { "answer_id": 74121515, "author": "Heinzi", "author_id": 87698, "author_profile": "https://Stackoverflow.com/users/87698", "pm_score": 2, "selected": false, "text": "args" } ]
2022/10/19
[ "https://Stackoverflow.com/questions/74121269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20158259/" ]
74,121,290
<p>I have the following scenario:</p> <ul> <li>An organization has an internal application, X, which is registered under the 'main' tenant, allowing employees to utilize it.</li> <li>App X has an API exposed for other applications (which are also registered under the main organization tenant) to used, and thus, this is all setup in AD.</li> <li>A new B2C tenant has been created, where another public facing application, Y, will be registered.</li> </ul> <p>How do I allow my App Registration for Y in my B2C tenant to use the exposed API of X?</p> <p>Any feedback would be appreciated.</p> <p><strong>Edit 1:</strong></p> <p>I'm assuming I'd need to setup a <a href="https://learn.microsoft.com/en-us/azure/active-directory/develop/authentication-flows-app-scenarios#daemon-app-that-calls-a-web-api-in-the-daemons-name" rel="nofollow noreferrer">Daemon auth flow</a>, as the backend of Y will be authenticating with X as the app itself, and not as or on behalf of the user logged into Y.</p> <p><strong>Edit 2:</strong></p> <p>After some looking into this today, I'm considering creating an AD App Registration for Y in the main organization of X, allowing me to set up any connections that need to be made there, and I'd update the backend of Y to make a call as a Daemon to X, passing all the relevant information and client secret.</p> <p>Seems a bit unusual, so will look for alternatives, but would also appreciate some feedback from someone who has more experience :)</p> <p><strong>Edit 3:</strong></p> <p>To clarify, I am looking to facilitate the communication between <em>backend</em> applications between two tenants, where one is a B2C tenant, and the other is an internal organization tenant.</p>
[ { "answer_id": 74163296, "author": "Kartik Bhiwapurkar", "author_id": 16526895, "author_profile": "https://Stackoverflow.com/users/16526895", "pm_score": 0, "selected": false, "text": "You might be having a front end and a back end to your application registered for authentication purpos...
2022/10/19
[ "https://Stackoverflow.com/questions/74121290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3951987/" ]
74,121,308
<p>I am delivering data from PLC Siemens S7 through node-red installed on IoT edge device to the cloud storage.</p> <p>In the node-red I receive data as a JSON object with several properties every second from PLC node. The JSON object (or data) has the same properties every second.</p> <p>Some properties change every second, some change in five minute, some remain constant for several hours.</p> <p>To handle data to the cloud the JSON object is handled to the IoT hub node in the node-red.</p> <p>I would like to process this JSON object before handling to the IoT hub node in a way that the JSON object has only the properties which changed from previous state (a second ago). It means that I want to compare an input object at the moment <code>t</code> with the object at <code>t-1</code> and generate a new object with properties of the object at <code>t</code> which differ from those of the object at <code>t-1</code>.</p> <p>The new object will be handled further. The object processing is expected to be done in the function node in the node-red. From PLC node the JSON object is received as the <code>msg.payload</code>.</p> <p>Could you please help me to script in (javascript) the process I have described?</p> <p>msg.payload to the function node is json object:</p> <pre><code>{&quot;Zone0&quot;: 200, &quot;Wire_tension&quot;: 2.5} </code></pre> <p>UPD: Since it was not clear what I have tried, here is the code. Sorry for not providing it, I thought it was clear.</p> <pre><code>var state = {}; // this state will be messaged further var prev_state = { &quot;Zone0&quot;: 0, &quot;Wire_tension&quot;: 0 }; // initially zeros are assigned var current_state = msg.payload; // has these two properties and updated every second // comparison of properties if (current_state.Zone0 != prev_state.Zone0) { state[&quot;Zone0&quot;] = current_state.Zone0; prev_state[&quot;Zone0&quot;] = current_state.Zone0; } if (current_state.Wire_tension != prev_state.Wire_tension) { state[&quot;Wire_tension&quot;] = current_state.Wire_tension; prev_state[&quot;Wire_tension&quot;] = current_state.Wire_tension; } msg.payload = state; return msg; </code></pre> <p>It looks like when the flow in the node-red starts the function node runs the code every time. Therefore prev_state is assigned every time. I understand that I need to somehow handle initial state which is updated further.</p> <p>UPD2: I also tried using the following code (also with <em>context</em> feature). The example is with my real data:</p> <pre><code>var state = {}; // this state will be messaged further flow.set([&quot;Zone0&quot;, &quot;Wire_tension&quot;],[0,0]); // initially zeros are assigned var current_state = msg.payload; // has these two properties and updated every second // comparison of properties if (current_state.Zone0 != flow.get(&quot;Zone0&quot;)) { state[&quot;Zone0&quot;] = current_state.Zone0; flow.set(&quot;Zone0&quot;, current_state.Zone0); } if (current_state.Wire_tension != flow.get(&quot;Wire_tension&quot;)) { state[&quot;Wire_tension&quot;] = current_state.Wire_tension; flow.set(&quot;Wire_tension&quot;, current_state.Wire_tension); } msg.payload = state; return msg; </code></pre>
[ { "answer_id": 74163296, "author": "Kartik Bhiwapurkar", "author_id": 16526895, "author_profile": "https://Stackoverflow.com/users/16526895", "pm_score": 0, "selected": false, "text": "You might be having a front end and a back end to your application registered for authentication purpos...
2022/10/19
[ "https://Stackoverflow.com/questions/74121308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14571343/" ]
74,121,322
<p>I am using antd DatePicker for date range purposes.</p> <p>How can I style the days that are sundays using css. Help will be appreciated</p> <p>edit:</p> <p>I am getting this blue background between start , range and the end. I want that to be continous. Also there is gap between selected rows, I want it to be purple itself. But here I see white color between selected rows</p> <p><a href="https://i.stack.imgur.com/1vAi4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1vAi4.png" alt="enter image description here" /></a></p> <pre><code>import React from &quot;react&quot;; import &quot;./styles.css&quot;; import { DatePicker } from &quot;antd&quot;; import &quot;antd/dist/antd.css&quot;; import { ConfigProvider } from &quot;antd&quot;; import en_GB from &quot;antd/lib/locale-provider/en_GB&quot;; import moment from &quot;moment&quot;; import &quot;moment/locale/en-gb&quot;; moment.locale(&quot;en-gb&quot;); const { RangePicker } = DatePicker; export default function App() { return ( &lt;div className=&quot;App&quot;&gt; &lt;br /&gt; &lt;ConfigProvider locale={en_GB}&gt; &lt;RangePicker /&gt; &lt;/ConfigProvider&gt; &lt;/div&gt; ); } </code></pre> <p>Sandbox: <a href="https://codesandbox.io/s/black-breeze-6gmz85?file=/src/App.js:0-511" rel="nofollow noreferrer">https://codesandbox.io/s/black-breeze-6gmz85?file=/src/App.js:0-511</a></p>
[ { "answer_id": 74121426, "author": "DreamTeK", "author_id": 2120261, "author_profile": "https://Stackoverflow.com/users/2120261", "pm_score": 3, "selected": true, "text": ".ant-picker-content tr td:nth-child(7) {\n background: #eee;\n}\n" }, { "answer_id": 74121508, "author"...
2022/10/19
[ "https://Stackoverflow.com/questions/74121322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16860065/" ]
74,121,325
<p>When I set background-color, there are no white spaces as expected. My browser is chrome and it was a brand-new code, no other styles where applied in the CSS. Same thing happens with or without more components present in the HTML file. Added a div to try it out and same result.</p> <pre><code>body { background-color: aquamarine; } </code></pre>
[ { "answer_id": 74121397, "author": "Fran", "author_id": 12021064, "author_profile": "https://Stackoverflow.com/users/12021064", "pm_score": -1, "selected": false, "text": "html {\n height: 100%;\n}\n\nbody {\n height: 100%;\n}\n\n.example {\n background-color: aquamarine;\n height: 1...
2022/10/19
[ "https://Stackoverflow.com/questions/74121325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19844932/" ]
74,121,329
<p>I'm trying to test a job but I can't get to the bottom of it, basically my step consists of a single reader and a composite Processor and a Composite writer, all this because I have to read from a single .CSV and write on MongoDB and Mysql, here is my Job Configuration class:</p> <pre><code> @Configuration @EnableBatchProcessing public class BatchConfiguration { @Autowired public JobBuilderFactory jobBuilderFactory; @Autowired public StepBuilderFactory stepBuilderFactory; @Autowired public MarketDataMySqlRepository marketDataMySqlRepository; @Value(&quot;${file.input}&quot;) private String fileInput; @Bean public TaskExecutor taskExecutor(){ SimpleAsyncTaskExecutor taskExecutor=new SimpleAsyncTaskExecutor(&quot;customerInfoThreads-&quot;); return taskExecutor; } @Bean public FlatFileItemReader&lt;MarketDataDto&gt; reader() { return new FlatFileItemReaderBuilder&lt;MarketDataDto&gt;().name(&quot;ItemReader&quot;) .resource(new PathResource(fileInput)).delimited() .names(&quot;time&quot;,&quot;id&quot;, &quot;price&quot;, &quot;quantity&quot;, &quot;isbuyermaker&quot;) .fieldSetMapper(new BeanWrapperFieldSetMapper&lt;MarketDataDto&gt;() { { setTargetType(MarketDataDto.class); } }).build(); } @Bean public MongoItemWriter&lt;MarketDataMongo&gt; writer(MongoTemplate mongoTemplate) { return new MongoItemWriterBuilder&lt;MarketDataMongo&gt;().template(mongoTemplate).collection(&quot;marketdata&quot;) .build(); } @Bean public RepositoryItemWriter&lt;MarketDataMySql&gt; writer1() { RepositoryItemWriter&lt;MarketDataMySql&gt; writer = new RepositoryItemWriter&lt;&gt;(); writer.setRepository(marketDataMySqlRepository); writer.setMethodName(&quot;save&quot;); return writer; } @Bean public CompositeItemWriter CompositeItemWriter(MongoTemplate mongoTemplate){ CompositeItemWriter writer = new CompositeItemWriter(); writer.setDelegates(Arrays.asList(writer(mongoTemplate),writer1())); return writer; } @Bean public UserItemProcessorMongo MongoProcessor() { return new UserItemProcessorMongo(); } @Bean public UserItemProcessorMySql MySqlProcessor() {return new UserItemProcessorMySql();} @Bean public CompositeItemProcessor compositeProcessor() throws Exception { List&lt;ItemProcessor&lt;MarketDataDto,MarketDataMongo&gt;&gt; itemProcessors = new ArrayList&lt;&gt;(1); List&lt;ItemProcessor&lt;MarketDataDto,MarketDataMySql&gt;&gt; itemProcessors1 = new ArrayList&lt;&gt;(1); itemProcessors1.add(MySqlProcessor()); itemProcessors.add(MongoProcessor()); CompositeItemProcessor processor = new CompositeItemProcessor(); processor.setDelegates(itemProcessors); processor.setDelegates(itemProcessors1); //processor.afterPropertiesSet(); return processor; } @Bean public Step step1(FlatFileItemReader&lt;MarketDataDto&gt; itemReader, MongoItemWriter&lt;MarketDataMongo&gt; itemWriter, MongoTemplate mongoTemplate) throws Exception { return this.stepBuilderFactory.get(&quot;step1&quot;).chunk(200000).reader(itemReader) .processor(compositeProcessor()).writer(CompositeItemWriter(mongoTemplate)).build(); } @Bean public Job updateUserJob(JobCompletionNotificationListener listener, Step step1) throws Exception { return this.jobBuilderFactory.get(&quot;updateMarketJob&quot;).incrementer(new RunIdIncrementer()) .listener(listener).start(step1).build(); } } </code></pre> <p>And this is my TestClass :</p> <pre><code>@RunWith(SpringRunner.class) @SpringBatchTest @ContextConfiguration(classes= {BatchConfiguration.class, BatchAutoConfiguration.class}) public class BatchConfigurationTest { @Autowired private JobLauncherTestUtils jobLauncherTestUtils; @Autowired private JobRepositoryTestUtils jobRepositoryTestUtils; @Autowired private MarketDataMySqlRepository marketDataMySqlRepository; @Test public void readerTest() throws Exception { JobParameters jobParameters = this.jobLauncherTestUtils.getUniqueJobParameters(); JobExecution jobExecution = this.jobLauncherTestUtils.launchJob(jobParameters); Assert.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); } } </code></pre> <p>When i try to launch my test i riceive this Exception :</p> <pre><code> java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:98) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jobRepositoryTestUtils': Unsatisfied dependency expressed through method 'setDataSource' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:767) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:719) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:132) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:141) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90) ... 27 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:759) ... 46 more </code></pre>
[ { "answer_id": 74121397, "author": "Fran", "author_id": 12021064, "author_profile": "https://Stackoverflow.com/users/12021064", "pm_score": -1, "selected": false, "text": "html {\n height: 100%;\n}\n\nbody {\n height: 100%;\n}\n\n.example {\n background-color: aquamarine;\n height: 1...
2022/10/19
[ "https://Stackoverflow.com/questions/74121329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20272914/" ]
74,121,337
<p>I'm trying to do a simple validation for vehicle registration number.</p> <ul> <li><p>It must include &quot;<strong>-</strong>&quot; Dash/Hyphen symbol. Example: BIR - 5698</p> </li> <li><p>It allows Numbers/Letters and Hyphen symbol only.</p> </li> <li><p>All the other symbols are invalid. ( `~!@#$%^&amp;*()_+=./;,&lt;&gt;&quot;:|[]{} )</p> <p>My code -</p> <pre><code> public static void main(String[] args) { Scanner in = new Scanner(System.in); if (in.hasNext(&quot;[A-Za]&quot;)) { System.out.println(&quot;Vehicles :&quot; + vehicles ); }else { System.out.println(&quot;Enter a Valid Value&quot;); </code></pre> </li> </ul> <p>Thank you. Your kind help highly appreciated.</p>
[ { "answer_id": 74121397, "author": "Fran", "author_id": 12021064, "author_profile": "https://Stackoverflow.com/users/12021064", "pm_score": -1, "selected": false, "text": "html {\n height: 100%;\n}\n\nbody {\n height: 100%;\n}\n\n.example {\n background-color: aquamarine;\n height: 1...
2022/10/19
[ "https://Stackoverflow.com/questions/74121337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16832138/" ]
74,121,344
<p>I have sell out data and want to remove rows/transactions when customers returned something (mat). In these cases there is a row with a positive value and a row with a negative value in column sales. The row with the negative value has a higher date. cust and mat are the same. Both should be removed.</p> <pre><code>cust &lt;- c(1, 1, 1, 1, 1,1,1,1,2,2,3,3,4,4,4) mat &lt;- c(123,123,123,123,123,124,123,123,124,123,125,125,130,124,124) sales &lt;- c(100.58,100.58,-100.58,-100.58,100.58,10,100,-100,10,100,50,-50,-1,20,20) date &lt;- c(&quot;2021-01-11&quot;, &quot;2018-12-04&quot;, &quot;2018-12-20&quot;, &quot;2018-12-20&quot;, &quot;2018-12-13&quot;, &quot;2018-12-13&quot;, &quot;2019-01-01&quot;,&quot;2019-01-02&quot;,&quot;2020-12-24&quot;,&quot;2021-01-20&quot;,&quot;2021-12-01&quot;, &quot;2021-12-05&quot;,&quot;2013-01-01&quot;,&quot;2014-02-02&quot;,&quot;2015-03-02&quot;) data&lt;-data.frame(cust,mat,sales,date) data cust mat sales date 1 1 123 100.58 2021-01-11 2 1 123 100.58 2018-12-04 3 1 123 -100.58 2018-12-20 4 1 123 -100.58 2018-12-20 5 1 123 100.58 2018-12-13 6 1 124 10.00 2018-12-13 7 1 123 100.00 2019-01-01 8 1 123 -100.00 2019-01-02 9 2 124 10.00 2020-12-24 10 2 123 100.00 2021-01-20 11 3 125 50.00 2021-12-01 12 3 125 -50.00 2021-12-05 13 4 130 -1.00 2013-01-01 14 4 124 20.00 2014-02-02 15 4 124 20.00 2015-03-02 </code></pre> <p>This should be the result:</p> <pre><code> cust mat sales date 1 123 100.58 2021-01-11 1 124 10.00 2018-12-13 2 124 10.00 2020-12-24 2 123 100.00 2021-01-20 4 130 -1.00 2013-01-01 4 124 20.00 2014-02-02 4 124 20.00 2015-03-02 </code></pre> <p>In the end I want the dataframe &quot;data&quot; having only the rows when customers keep their material.</p>
[ { "answer_id": 74121783, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "cust" }, { "answer_id": 74125590, "author": "jblood94", "author_id": 9463489, "author_profile": "h...
2022/10/19
[ "https://Stackoverflow.com/questions/74121344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6220458/" ]
74,121,345
<p>What im trying to do is for example if router came from login to verification screen do something but when prev location from sign up and not login dont do something.</p> <p>So i want to get the prev location to do some logic to it, im aware that i can pass params to pages then do the logic from it for example passing a bool and do the logic if true or false but i want a better or right way, if you know want i mean. Thank you.</p> <p>And i encounter this method from go router, what it does? is it for logging purpose only, im trying to add route name or location in the parameter but it throws an error. What param do i need to input in here, i dont know where to find Route thank you.</p> <pre><code>context.didPush(Route&lt;dynamic&gt; route, Route&lt;dynamic&gt;? previousRoute); </code></pre>
[ { "answer_id": 74121783, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "cust" }, { "answer_id": 74125590, "author": "jblood94", "author_id": 9463489, "author_profile": "h...
2022/10/19
[ "https://Stackoverflow.com/questions/74121345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8161429/" ]
74,121,360
<p>I have a column of store opening hours in STRING format where one column*row entry looks like this:</p> <pre><code>Monday: 10:00 - 20:00, Tuesday: 10:00 - 20:00, Wednesday: 10:00 - 20:00, Thursday: 10:00 - 20:00, Friday: 10:00 - 20:00, Saturday: 10:00 - 20:00, Sunday: 11:00 - 18:00 </code></pre> <p>. I would like to transform this entry into several column*row entries such like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Weekday</th> <th>Opening</th> <th>Closing</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>00:10:00</td> <td>00:20:00</td> </tr> <tr> <td>1</td> <td>00:10:00</td> <td>00:20:00</td> </tr> </tbody> </table> </div> <p>The timestamp format I need in order to obtain foottraffic for stores at certain hours of the day.</p>
[ { "answer_id": 74121783, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "cust" }, { "answer_id": 74125590, "author": "jblood94", "author_id": 9463489, "author_profile": "h...
2022/10/19
[ "https://Stackoverflow.com/questions/74121360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15863534/" ]
74,121,361
<p>In my react application I'm calling api call some times I'm not receiving data from api specifically in 1st time call. In this case while I do a second api call I'm receiving result always. How to resolve the issue.</p> <pre><code>useEffect(() =&gt; { post(`get-${props.url}`, {searchParams: {UserId: props.userId}}) .then(response =&gt; { if (Object.keys(response.data).length === 0) { recursiveCall() } console.log(response, 'response') }) .catch(error =&gt; { console.log(error, 'error') }) }, [ ]) </code></pre>
[ { "answer_id": 74121783, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "cust" }, { "answer_id": 74125590, "author": "jblood94", "author_id": 9463489, "author_profile": "h...
2022/10/19
[ "https://Stackoverflow.com/questions/74121361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4652706/" ]
74,121,374
<p>Is it possible to use CSS grid to auto-fit the columns in a row to always take up the whole width?</p> <p>I know this would be possible if you knew the number of columns, but is it possible with a dynamic number of columns?</p> <p>Image for reference of what I'd like to achieve. <a href="https://i.stack.imgur.com/GmbX1.png" rel="nofollow noreferrer">column example image</a></p> <p>This is what I have so far, but you can see that the lower row item doesn't take up all the row width.</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>.wrapper { display: grid; grid-template-columns: 200px 200px; column-gap: 20px; } .grid { border: solid #FF8181 1px; display: grid; grid-template-rows: 40px repeat(8, minmax(0, 1fr)); width: 200px; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); } .row-item { background: #FFC555; border: 1px solid #835600; width: 100%; height: 40px; } .item-1, .item-1 { grid-row: 2 / span 1; } .item-2 { grid-row: 6 / span 1; font-size: 12px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class='wrapper'&gt; &lt;div class='grid'&gt; &lt;div class='row-item item-1'&gt;&lt;/div&gt; &lt;div class='row-item item-1'&gt;&lt;/div&gt; &lt;div class='row-item item-2'&gt;I'm too short&lt;/div&gt; &lt;/div&gt; &lt;div class='grid'&gt; &lt;div class='row-item item-1'&gt;&lt;/div&gt; &lt;div class='row-item item-1'&gt;&lt;/div&gt; &lt;div class='row-item item-1'&gt;&lt;/div&gt; &lt;div class='row-item item-2'&gt;Should be the whole width&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74121783, "author": "Maël", "author_id": 13460602, "author_profile": "https://Stackoverflow.com/users/13460602", "pm_score": 2, "selected": true, "text": "cust" }, { "answer_id": 74125590, "author": "jblood94", "author_id": 9463489, "author_profile": "h...
2022/10/19
[ "https://Stackoverflow.com/questions/74121374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13187021/" ]
74,121,406
<p>I have the following three lists of which I'd like to combine each list element by index creating a new list.</p> <p>Before:</p> <pre><code>list_numbers = [55900, 44560, 49510, 49509, 49519, 49556, 49586] list_names = ['Richard White', 'Susan Pierce', 'Kim Note', 'John Lee', 'Jennifer Six', 'Maria Cruz', 'Martin Lewis'] list_grades = ['100', '46', '76', '74', '50', '67', '79'] </code></pre> <p>What I'd like to receive as a result:</p> <pre><code>list_final = ['55900 Richard White 100', '44560 Susan Pierce 46', '49510 Kim Note 76', '49509 John Lee 74', '49519 Jennifer Six 50', '49556 Maria Cruz 67', '49586 Martin Lewis 79'] </code></pre> <p>Once the list is created it is supposed to be sorted by the first 4 numbers in the character list elements.</p> <p>Thanks, everyone!</p>
[ { "answer_id": 74121470, "author": "R. Baraiya", "author_id": 13888486, "author_profile": "https://Stackoverflow.com/users/13888486", "pm_score": 1, "selected": false, "text": "[f'{list_numbers[l]} {list_names[l]} {list_grades[l]}' for l in range(len(list_grades))]\n" }, { "answe...
2022/10/19
[ "https://Stackoverflow.com/questions/74121406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279856/" ]
74,121,425
<p>I want to add some headers but can't find it on the docs</p> <pre class="lang-php prettyprint-override"><code>$httpRequest = Http::baseUrl(config('api_base_url')) -&gt;withHeaders([ 'Authorization' =&gt; 'Bearer ' . $accessToken, ]); // can i do something like this? if ($var === 'me') { $httpRequest-&gt;pushToExistingHeaders([ &quot;Content-Type&quot; =&gt; 'multipart/form-data' ]); } </code></pre>
[ { "answer_id": 74121831, "author": "nice_dev", "author_id": 4964822, "author_profile": "https://Stackoverflow.com/users/4964822", "pm_score": 2, "selected": true, "text": "withHeaders" }, { "answer_id": 74134335, "author": "Hafid Maulana", "author_id": 9786205, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74121425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11054401/" ]
74,121,448
<p>my data structure is</p> <pre class="lang-java prettyprint-override"><code>@Data @AllArgsConstructor class A { private B b; } @Data @AllArgsConstructor class B { private List&lt;C&gt; cs; } @Data @AllArgsConstructor class C { private List&lt;D&gt; ds; } @Data @AllArgsConstructor class D { private String value; } </code></pre> <p>and all member is nullable. so I want to extract all values(in class D) in this data structure with optional for nullsafe.</p> <p>I imagine</p> <pre class="lang-java prettyprint-override"><code>A a = new A( new B(List.of( new C(List.of( new D(&quot;a&quot;), new D(&quot;b&quot;), new D(&quot;c&quot;) )) , new C(List.of( new D(&quot;d&quot;), new D(&quot;e&quot;), new D(&quot;f&quot;) )) )) ); // it will be List.of(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;) var result = Optional.ofNullable(a) .map(A::getB) .flatMap(.......) // &lt;-- i don't know this point how to do to flat elements .orElse(List.of(&quot;empty&quot;)) // or 'orThrow` </code></pre>
[ { "answer_id": 74121831, "author": "nice_dev", "author_id": 4964822, "author_profile": "https://Stackoverflow.com/users/4964822", "pm_score": 2, "selected": true, "text": "withHeaders" }, { "answer_id": 74134335, "author": "Hafid Maulana", "author_id": 9786205, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74121448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6563164/" ]
74,121,450
<p>I want to organize my urls for the testing project, so I tried to create a separate class or dictionary to store urls, but whenever I tried to call a &quot;driver.get(pages.url)&quot; method I get an error. Although if you pass the url from a variable or a string directly, everything works. I can't understand where is the problem. Could someone help? The code:</p> <pre><code>from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.support.ui import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.options import Options class Pages: basic_url:str = 'google.com' translate:str = 'translate.' + basic_url maps:str = 'www.' + basic_url + '/maps' pages = Pages() print(pages.translate) print(type(pages.translate)) chrome_options = Options() chrome_options.add_experimental_option(&quot;detach&quot;, True) driver = webdriver.Chrome(service=Service(executable_path=ChromeDriverManager().install()),options=chrome_options) wait = WebDriverWait(driver, 60) driver.maximize_window() driver.get(pages.translate) </code></pre> <p>The error:</p> <pre><code>'Traceback (most recent call last): File &quot;E:\Projects\Python\portal_UI_testing_automation\ptn.py&quot;, line 23, in &lt;module&gt; driver.get(pages.translate) File &quot;E:\portal_UI_testing_automation\lib\site-packages\selenium\webdriver\remote\webdriver.py&quot;, line 440, in get self.execute(Command.GET, {'url': url}) File &quot;E:\portal_UI_testing_automation\lib\site-packages\selenium\webdriver\remote\webdriver.py&quot;, line 428, in execute self.error_handler.check_response(response) File &quot;E:\portal_UI_testing_automation\lib\site-packages\selenium\webdriver\remote\errorhandler.py&quot;, line 243, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidArgumentException: Message: invalid argument (Session info: chrome=106.0.5249.119)' </code></pre>
[ { "answer_id": 74121831, "author": "nice_dev", "author_id": 4964822, "author_profile": "https://Stackoverflow.com/users/4964822", "pm_score": 2, "selected": true, "text": "withHeaders" }, { "answer_id": 74134335, "author": "Hafid Maulana", "author_id": 9786205, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74121450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19688436/" ]
74,121,458
<p>Given a column named <strong>fullname</strong>, how can I filter on firstname/lastname with no order ?</p> <p>In the example below in javascript, the query is not valid when searching by lastname</p> <pre class="lang-js prettyprint-override"><code>function getQuery(searchWord){ return `SELECT * FROM user WHERE fullname like '%${searchWord}%' ` } // trying to search fullname &quot;Elon Musk&quot; getQuery(&quot;Elon M&quot;) // okay getQuery(&quot;Musk E&quot;) // no result </code></pre> <p>What is the query that allow me to find &quot;Elon Musk&quot; by searching by keyword &quot;Musk Elon&quot; ?</p> <p><strong>NB:</strong> columns firstname and lastname exists as well</p>
[ { "answer_id": 74121831, "author": "nice_dev", "author_id": 4964822, "author_profile": "https://Stackoverflow.com/users/4964822", "pm_score": 2, "selected": true, "text": "withHeaders" }, { "answer_id": 74134335, "author": "Hafid Maulana", "author_id": 9786205, "autho...
2022/10/19
[ "https://Stackoverflow.com/questions/74121458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12538581/" ]
74,121,466
<p>For typing practice purpose, I'm trying to apply the following typing to get the first element of an array :</p> <pre><code>type First&lt;T extends unknown[]&gt; = T extends [infer P, ...unknown[]] ? P : never </code></pre> <p>I have the following implementation :</p> <pre><code>const getFirstOrThrow = &lt;T extends unknown[]&gt;(arr: T): First&lt;T&gt; =&gt; { if(arr.length === 0) { throw new Error(&quot;Empty array&quot;) } return arr[0]; // Type 'unknown' is not assignable to type 'First&lt;T&gt;'.(2322) } </code></pre> <p>For some reason typescript is not able to understand that the array should have at least 1 element.</p> <p>I tried with the following type too :</p> <pre><code>type First&lt;T extends unknown[]&gt; = T[&quot;length&quot;] extends 0 ? never : T[0]; type A = First&lt;[]&gt; // never type B = First&lt;[1]&gt; // 1 type C = First&lt;[1,2]&gt; // 1 </code></pre> <p>Is something like this possible with typescript ?</p> <p>This typing seems ok to me :</p> <pre><code>declare function getFirst &lt;T extends unknown[]&gt;(arr: T): First&lt;T&gt;; const A = getFirst([]) // never const B = getFirst([1]) // number const C = getFirst([1, 2]) //number </code></pre>
[ { "answer_id": 74121533, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "T extends any" }, { "answer_id": 74121755, "author": "T.J. Crowder", "author_id": 157247, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74121466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19309765/" ]
74,121,481
<p>I have text file and I want to convert it to JSON:</p> <pre><code>red|2022-09-29|03:15:00|info 1 blue|2022-09-29|10:50:00| yellow|2022-09-29|07:15:00|info 2 </code></pre> <p>so i type a script to convert this file into JSON:</p> <pre><code>import json filename = 'input_file.txt' dict1 = {} fields =['name', 'date', 'time', 'info'] with open(filename) as fh: l = 1 for line in fh: description = list( line.strip().split(&quot;|&quot;, 4)) print(description) sno ='name'+str(l) i = 0 dict2 = {} while i&lt;len(fields): dict2[fields[i]]= description[i] i = i + 1 dict1[sno]= dict2 l = l + 1 out_file = open(&quot;json_file.json&quot;, &quot;w&quot;) json.dump(dict1, out_file, indent = 4) out_file.close() </code></pre> <p>and output looks like this:</p> <pre><code>{ &quot;name1&quot;: { &quot;name&quot;: &quot;red&quot;, &quot;date&quot;: &quot;2022-09-29&quot;, &quot;time&quot;: &quot;03:15:00&quot;, &quot;info&quot;: &quot;info 1&quot; }, &quot;name2&quot;: { &quot;name&quot;: &quot;blue&quot;, &quot;date&quot;: &quot;2022-09-29&quot;, &quot;time&quot;: &quot;10:50:00&quot;, &quot;info&quot;: &quot;&quot; }, &quot;name3&quot;: { &quot;name&quot;: &quot;yellow&quot;, &quot;date&quot;: &quot;2022-09-29&quot;, &quot;time&quot;: &quot;07:15:00&quot;, &quot;info&quot;: &quot;info 2&quot; } } </code></pre> <p>As you can see I do so, but now I want to change looks of this JSON file. How can I change it to make my output looks like this: to look like this:</p> <pre><code>[ {&quot;name&quot;:&quot;red&quot;, &quot;date&quot;: &quot;2022-09-29&quot;, &quot;time&quot;: &quot;03:15:00&quot;, &quot;info&quot;:&quot;info 1&quot;}, {&quot;name&quot;:&quot;blue&quot;, &quot;date&quot;: &quot;2022-09-29&quot;, &quot;time&quot;: &quot;10:50:00&quot;, &quot;info&quot;:&quot;&quot;}, {&quot;name&quot;:&quot;yellow&quot;, &quot;date&quot;: &quot;2022-09-29&quot;, &quot;time&quot;: &quot;07:15:00&quot;, &quot;info&quot;:&quot;info 2&quot;} ] </code></pre>
[ { "answer_id": 74121533, "author": "Matthieu Riegler", "author_id": 884123, "author_profile": "https://Stackoverflow.com/users/884123", "pm_score": 1, "selected": false, "text": "T extends any" }, { "answer_id": 74121755, "author": "T.J. Crowder", "author_id": 157247, ...
2022/10/19
[ "https://Stackoverflow.com/questions/74121481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15949610/" ]
74,121,490
<p>I have the following two lists</p> <pre><code>list_1 = [3, 5, 7, 2] list_2 = [ '1-CHA', '2-NOF', '3-INC', '4-CHA', '5-NOF', '6-NOF', '7-INC', '8-INC', '9-INC', '10-INC', '11-CHA', '12-NOF', '13-CHA', '14-CHA', '15-INC', '16-INC', '17-INC' ] </code></pre> <p>I want to combine the two lists in the following way:</p> <pre><code>final_list = [ '1-CHA|2-NOF|3-INC', '4-CHA|5-NOF|6-NOF|7-INC|8-INC', '9-INC|10-INC|11-CHA|12-NOF|13-CHA|14-CHA|15-INC', '16-INC|17-INC' ] </code></pre> <p><strong>final_list</strong> - should have the same length as <strong>list_1</strong></p>
[ { "answer_id": 74121587, "author": "blhsing", "author_id": 6890912, "author_profile": "https://Stackoverflow.com/users/6890912", "pm_score": 4, "selected": true, "text": "list_2" }, { "answer_id": 74121610, "author": "mousetail", "author_id": 6333444, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74121490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19602042/" ]
74,121,528
<p>I have a problem which is similar to this.</p> <p>Here I am trying to append 0 after every 5 in the list.</p> <p>The below code does not update the length of the list and the output I get is <code>[1,4,5,0,2,7,5,0,5]</code> while desired output is <code>[1,4,5,0,2,7,5,0,5,0]</code></p> <pre><code>mylist1 = [1,4,5,2,7,5,5] for i in range(len(mylist1)): if mylist1[i] == 5: mylist1.insert(i+1,0) print(f'output: {mylist1}') </code></pre> <p>I have to update in the same list mylist1.</p>
[ { "answer_id": 74121587, "author": "blhsing", "author_id": 6890912, "author_profile": "https://Stackoverflow.com/users/6890912", "pm_score": 4, "selected": true, "text": "list_2" }, { "answer_id": 74121610, "author": "mousetail", "author_id": 6333444, "author_profile"...
2022/10/19
[ "https://Stackoverflow.com/questions/74121528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19559382/" ]
74,121,529
<p>Hey I have the following &quot;problem&quot;. I am currently writing a python script that checks certificates for CRL. You give this script the certificate in the command line and it checks it. This script should now be started several times in the Linux terminal at the same time. Does this work with a normal script without multithreading or _threads or do I need something like this? If yes, which library do you recommend?</p>
[ { "answer_id": 74121575, "author": "Avishay Cohen", "author_id": 18771432, "author_profile": "https://Stackoverflow.com/users/18771432", "pm_score": 3, "selected": true, "text": "cmd arg1 & cmd arg2 & cmd arg3\n" }, { "answer_id": 74121714, "author": "rafathasan", "author...
2022/10/19
[ "https://Stackoverflow.com/questions/74121529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18722343/" ]
74,121,536
<p>I am trying to use <a href="https://gnome.pages.gitlab.gnome.org/libxml2/examples/xpath1.c" rel="nofollow noreferrer"><code>xpath1</code></a>, on the following SOAP XML file:</p> <ul> <li><a href="https://raw.githubusercontent.com/mrjeffstevenson3/mmimproc/master/data/testdata/examcard/SR_ADULT_007.ExamCard" rel="nofollow noreferrer">https://raw.githubusercontent.com/mrjeffstevenson3/mmimproc/master/data/testdata/examcard/SR_ADULT_007.ExamCard</a></li> </ul> <p>I tried a simple one:</p> <pre><code>% ./xpath1 SR_ADULT_007.ExamCard &quot;//SOAP-ENC:Array[@id='ref-297']&quot; XPath error : Undefined namespace prefix Error: unable to evaluate xpath expression &quot;//SOAP-ENC:Array[@id='ref-297']&quot; Usage: ./xpath1 &lt;xml-file&gt; &lt;xpath-expr&gt; [&lt;known-ns-list&gt;] where &lt;known-ns-list&gt; is a list of known namespaces in &quot;&lt;prefix1&gt;=&lt;href1&gt; &lt;prefix2&gt;=href2&gt; ...&quot; format </code></pre> <p>However my XPath perl command seems to contradict the above:</p> <pre><code>% xpath -e &quot;//SOAP-ENC:Array[@id='ref-297']&quot; SR_ADULT_007.ExamCard &gt; /dev/null Found 1 nodes in SR_ADULT_007.ExamCard: -- NODE -- </code></pre> <p>What did I misunderstood from libxml2/xpath/namespace convention ?</p>
[ { "answer_id": 74121787, "author": "malat", "author_id": 136285, "author_profile": "https://Stackoverflow.com/users/136285", "pm_score": 1, "selected": true, "text": "% ./xpath1 SR_ADULT_007.ExamCard \"//SOAP-ENC:Array[@id='ref-297']\" SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/\n...
2022/10/19
[ "https://Stackoverflow.com/questions/74121536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/136285/" ]
74,121,537
<p>I have a strange json, which:</p> <ul> <li>I can not change it, it is from a third party</li> <li>It can have up to 75 properties</li> </ul> <p>A simple example of the json:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;bookingcode&quot;:[&quot;ABC&quot;,&quot;DEF&quot;, &quot;GHJ&quot;, &quot;TEST&quot;], &quot;referencenumber&quot;:[123, 456] &quot;bookingdate&quot;:[&quot;22-07-2022T14:00:30&quot;, &quot;23-11-2022T17:00:25&quot;] } </code></pre> <p>I am only interested in the last value of the array and want to deserialize into a class called Booking, so in this case <code>bookingcode=&quot;TEST&quot;</code> and <code>bookingdate=&quot;23-11-2022T17:00:25&quot;</code>.</p> <p>A solution would be define a model:</p> <pre><code>public class Booking { public string BookingCode { get; set; } public int ReferenceNumber { get; set; } public DateTime BookingDate { get; set;} } public class BookingInput { public List&lt;string&gt; BookingCode { get; set;} public List&lt;int&gt; ReferenceNumber { get; set; } public List&lt;DateTime&gt; BookingDate { get; set; } } var bookinginput = JsonSerializer.Deserialize&lt;BookingInput&gt;(jsonString); var booking = new Booking { BookingCode = bookinginput.BookingCode.Last(), ReferenceNumber = bookinginput.ReferenceNumber.Last(), ... } </code></pre> <p>I think it is very tedious to write out all 75 properties in code like this. Is there a better solution in Json.net or System.Text.Json for this?</p>
[ { "answer_id": 74123025, "author": "MarTim", "author_id": 12225751, "author_profile": "https://Stackoverflow.com/users/12225751", "pm_score": 1, "selected": false, "text": "JsonConverter" }, { "answer_id": 74124260, "author": "Peter Csala", "author_id": 13268855, "aut...
2022/10/19
[ "https://Stackoverflow.com/questions/74121537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20279859/" ]
74,121,579
<p>I have a project and this project contains a text, and this text is in the form: patientId xxxxxx, which is in the form patient1075 0944713415. And I want to separate the text from the number, I tried to use several methods, but I could not separate the text from the number.</p> <p>i need to pass 1075 to backend api, that is mean i need the number.</p> <p>How can I do that?</p> <pre><code> const d = decrypt(t); console.log('after decrypt: ', d); //patient1075 let numb: any = d.replace(/\D/g,''); console.log('ccxcxccxcc: ', numb); </code></pre>
[ { "answer_id": 74121674, "author": "SpookyJelly", "author_id": 16747864, "author_profile": "https://Stackoverflow.com/users/16747864", "pm_score": 0, "selected": false, "text": "const d = 'patient1075' // your example\n\n/** replace text to '' with regex, \nbelow regex means replace str...
2022/10/19
[ "https://Stackoverflow.com/questions/74121579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16377085/" ]
74,121,614
<p>I have a text box, wherein 1 line of comma separated data is getting inserted successfully, but when clicked Enter to insert another similar line. It does nothing. It does not allow to add a new line of input data.</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-html lang-html prettyprint-override"><code>&lt;div class="formFields qP"&gt; &lt;div&gt; &lt;textarea id="qPA" name="qP" placeholder="Hello, help me pls"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74121674, "author": "SpookyJelly", "author_id": 16747864, "author_profile": "https://Stackoverflow.com/users/16747864", "pm_score": 0, "selected": false, "text": "const d = 'patient1075' // your example\n\n/** replace text to '' with regex, \nbelow regex means replace str...
2022/10/19
[ "https://Stackoverflow.com/questions/74121614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20280076/" ]
74,121,621
<p><a href="https://i.stack.imgur.com/XFA76.png" rel="nofollow noreferrer">ScreenShot of Navigation bar</a></p> <blockquote> <p>want to replace from <strong>&lt; back</strong> to <strong>right arrow(&lt;--) All</strong> in swiftui.</p> <p>And when we will click on the <strong>&lt;--</strong> icon and then return to the source View</p> </blockquote>
[ { "answer_id": 74121982, "author": "Taimoor Arif", "author_id": 16964922, "author_profile": "https://Stackoverflow.com/users/16964922", "pm_score": 1, "selected": false, "text": ".navigationTitle(\"\")\n.navigationBarHidden(true)\n.navigationBarBackButtonHidden(true)\n" }, { "ans...
2022/10/19
[ "https://Stackoverflow.com/questions/74121621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,121,636
<p>I need to convert a CSV document to another one in XML format. This is what I have in my CSV file:</p> <p>level;1;2;49;50;51; Position;8455;8930;9405;9880;10355;11015;11490;11965;12440;12915;13575;14050;14525;15000</p> <p>So, for each level, I should have the same positions described in the field Position The output format should be like that:</p> <p><a href="https://i.stack.imgur.com/KxRgA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KxRgA.png" alt="Code description" /></a></p> <p>And so on..until I fill all values from the Position table How can this be achived? Any example? Thanks.</p>
[ { "answer_id": 74123014, "author": "jdweng", "author_id": 5015238, "author_profile": "https://Stackoverflow.com/users/5015238", "pm_score": 2, "selected": false, "text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Xml;\nusing Sy...
2022/10/19
[ "https://Stackoverflow.com/questions/74121636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5309651/" ]
74,121,651
<p>I have a pandas dataset like this:</p> <pre><code>import pandas as pd data = {'id': ['001', '002', '003','004'], 'address': [&quot;William J. Clare\\n290 Valley Dr.\\nCasper, WY 82604\\nUSA&quot;, &quot;1180 Shelard Tower\\nMinneapolis, MN 55426\\nUSA&quot;, &quot;William N. Barnard\\n145 S. Durbin\\nCasper, WY 82601\\nUSA&quot;, &quot;215 S 11th ST&quot;], 'locality': [None, None, None,'Laramie'], 'region': [None, None, None, 'WY'], 'Zipcode': [None, None, None, '87656'], 'Country': [None, None, None, 'US'] } df = pd.DataFrame(data) </code></pre> <p>I tried to split the address column by new line but however since it has two \ followed by n. I am not able to do . Please help me in splitting the \n from address and exptrapolate into locality region zipcode and country.</p> <p>sample output:</p> <pre><code>id address locality region Zipcode Country 1 290 Valley Dr. Casper WY 82604 USA 2 1180 Shelard Tower Minneapolis MN 55426 USA 3 145 S. Durbin Casper WY 82601 USA 4 215 S 11th ST Laramie WY 87656 US </code></pre> <p>I tried different methods to split \n using split command but it gives me extra \. And I am trying to keep it in pandas dataframe so that I can carry further analysis.</p>
[ { "answer_id": 74121863, "author": "bitflip", "author_id": 20027803, "author_profile": "https://Stackoverflow.com/users/20027803", "pm_score": 0, "selected": false, "text": "data = {'id': ['001', '002', '003','004'],\n 'address': [\"William J. Clare\\\\n290 Valley Dr.\\\\nCasper,...
2022/10/19
[ "https://Stackoverflow.com/questions/74121651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20271577/" ]
74,121,671
<p>For my master thesis i downloaded a ton of finance related files. my objective is to find a specific set of words (&quot;chapter 11&quot;) to flag all companies that have gone through the debt restructuring process. The problem is that i have more than 1.2 milion little files that makes the search really inefficient. For now i wrote very basic code and i reached a velocity of 1000 documents every 40-50 seconds. i was wondering if there are some specific libraries or methods (or even programming languages) to search even faster. this is the function i'm using so far</p> <pre><code>def get_items(m): word = &quot;chapter 11&quot; f = open(m, encoding='utf8') document = f.read() f.close() return (word in document.lower()) # apply the function to the list of names: l_v1 = list(map(get_items,filenames)) </code></pre> <p>the size of the files varies between 5 and 4000 KB</p>
[ { "answer_id": 74121749, "author": "user650654", "author_id": 650654, "author_profile": "https://Stackoverflow.com/users/650654", "pm_score": 3, "selected": false, "text": "grep" }, { "answer_id": 74121773, "author": "AsafH", "author_id": 12287000, "author_profile": "...
2022/10/19
[ "https://Stackoverflow.com/questions/74121671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13735934/" ]
74,121,675
<p>I want to navigate through my ListView only with two buttons, not with the fingers and scroll so: <code> physics: const NeverScrollableScrollPhysics(),</code>. here is a picture, the problem is below:</p> <p><a href="https://i.stack.imgur.com/Dl2sV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dl2sV.png" alt="enter image description here" /></a></p> <p>when I open the keyboard, it looks like this: <a href="https://i.stack.imgur.com/Ozqls.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ozqls.png" alt="enter image description here" /></a></p> <p>So my Input Fields are obscured behind the keyboard. With an active scroll physics, this wouldn't happen because it resizes the screen so that it fit. Is there a way to move the End of my scaffold to the end of the keyboard, e.g.? Or a workaround like to activate the scrolls physics only when the keyboard appears? I also have a</p> <pre><code> ScrollConfiguration( behavior: MyBehavior(), class MyBehavior extends ScrollBehavior { @override Widget buildOverscrollIndicator( BuildContext context, Widget child, ScrollableDetails details) { return child; } } </code></pre> <p>but I think this is not important for my problem</p>
[ { "answer_id": 74121913, "author": "Shimaa Yasser", "author_id": 10868923, "author_profile": "https://Stackoverflow.com/users/10868923", "pm_score": 2, "selected": true, "text": "//use flutter_keyboard_visibility plugin for detection\nimport 'package:flutter_keyboard_visibility/flutter_k...
2022/10/19
[ "https://Stackoverflow.com/questions/74121675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19913052/" ]
74,121,684
<p>Please can anyone help me how I can use swiper or any other slider in astro.build?</p> <p>Like we use in react.</p>
[ { "answer_id": 74132467, "author": "Andrés López", "author_id": 20286708, "author_profile": "https://Stackoverflow.com/users/20286708", "pm_score": 1, "selected": false, "text": "<MySlider client:load />" }, { "answer_id": 74134244, "author": "mythosil", "author_id": 3808...
2022/10/19
[ "https://Stackoverflow.com/questions/74121684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17117701/" ]
74,121,693
<p>I have a dataset of NYC taxi data that I am trying to filter through. The dataset has the schema like this:</p> <pre class="lang-none prettyprint-override"><code>root |-- medallion: string (nullable = true) |-- hack_license: string (nullable = true) |-- vendor_id: string (nullable = true) |-- rate_code: integer (nullable = true) |-- store_and_fwd_flag: string (nullable = true) |-- pickup_datetime: timestamp (nullable = true) |-- dropoff_datetime: timestamp (nullable = true) |-- passenger_count: integer (nullable = true) |-- trip_time_in_secs: integer (nullable = true) |-- trip_distance: double (nullable = true) |-- pickup_longitude: double (nullable = true) |-- pickup_latitude: double (nullable = true) |-- dropoff_longitude: double (nullable = true) |-- dropoff_latitude: double (nullable = true) </code></pre> <p>I want to filter the dataset so that any entries which have pickup and dropoff times not between the hours of 9am to 5pm are excluded. But I am having trouble writing a helper method to use within a <code>withColumn</code> function. Here is what I have for the <code>withColumn</code> calls:</p> <pre class="lang-py prettyprint-override"><code>from pyspark.sql.window import Window from pyspark.sql import functions as fun taxi_raw.withColumn(&quot;pickup_datetime&quot;, remove_pickup_times(fun.col(&quot;pickup_datetime&quot;)) taxi_raw.withColumn(&quot;dropoff_datetime&quot;, remove_dropoff_times(fun.col(&quot;dropoff_datetime&quot;)) </code></pre> <p>And here is what I have for the helper methods so far:</p> <pre class="lang-py prettyprint-override"><code>import datetime def remove_pickup_times(pickup_datetime): time_start = datetime.time(9,0,0) time_end = datetime.time(17,0,0) if(pickup_datetime.time() &gt;= time_start and pickup_datetime.time() &lt;= time_end): //insert code to remove entry from dataset def remove_dropoff_times(dropoff_datetime): time_start = datetime.time(9,0,0) time_end = datetime.time(17,0,0) if(dropoff_datetime.time() &gt;= time_start and dropoff_datetime.time() &lt;= time_end): //insert code to remove entry from dataset </code></pre>
[ { "answer_id": 74128125, "author": "ZygD", "author_id": 2753501, "author_profile": "https://Stackoverflow.com/users/2753501", "pm_score": 1, "selected": false, "text": "date_format" }, { "answer_id": 74131001, "author": "stack0114106", "author_id": 6867048, "author_pr...
2022/10/19
[ "https://Stackoverflow.com/questions/74121693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12131423/" ]
74,121,696
<p>I have a project in C# language. which should take the name of a folder and a file. If the file does not exist in the folder, <code>the file not exist</code> will be printed. If there is a file, based on the file creation date, determine how many files have a creation date smaller than this file. My code is as follows:</p> <ol> <li><p>First, it is checked if the file does not exist in the folder, <code>the file not exist</code> is printed</p> <pre><code>DirectoryInfo dir = new DirectoryInfo(@&quot;c:\mydirectory&quot;); string fileName = &quot;myfile.png&quot;; FileInfo[] files = dir.GetFiles(&quot;*.*&quot;); Boolean fileFound = false; for(int i=0; i&lt;files.Length; i++) { if(files[i].Name == fileName) { fileFound = true; break; } } if(fileFound==false) { Console.WriteLine(&quot;the file not exist&quot;); return; } </code></pre> </li> </ol> <ol start="2"> <li><p>The files are then sorted by creation date:</p> <pre><code> for (int i = 0; i &lt; files.Length; i++) { for (int n = i; n &lt; files.Length; n++) { if (files[n].CreationTime &lt; files[i].CreationTime) { var temp = files[i]; files[i] = files[n]; files[n] = temp; } } } </code></pre> </li> </ol> <p>3.Finally, I find the index of the file in the list and it is printed:</p> <pre><code> for (int i = 0; i &lt; files.Length; i++) { if (files[i].Name == fileName) { Console.WriteLine(&quot;index of this file is: &quot; +i); break; } } </code></pre> <p>My project works fine, but I think there must be an easier way with fewer lines. Can anyone guide me?</p>
[ { "answer_id": 74121762, "author": "hossein sabziani", "author_id": 4301195, "author_profile": "https://Stackoverflow.com/users/4301195", "pm_score": 4, "selected": true, "text": " //1. if the file does not exist in the folder, `the file not exist` is printed\n\n if (!files.Any(f => f.Na...
2022/10/19
[ "https://Stackoverflow.com/questions/74121696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,121,748
<p>I have some struggles with assigning a type to filter function with TypeScript. So, when I'm building the app, it says like:</p> <blockquote> <p>Parameter 'item' implicitly has an 'any' type.</p> </blockquote> <p>And function looks like:</p> <pre><code>allowedProductPaymentMethods?.filter(item =&gt; item.id !== paymentItem.id &amp;&amp; item.balance &gt; 0) </code></pre> <p>So I tried adding like <code>(item: any)</code>, but it's not recognizing the typing. Any ideas how to fix it?</p>
[ { "answer_id": 74122666, "author": "Boussadjra Brahim", "author_id": 8172857, "author_profile": "https://Stackoverflow.com/users/8172857", "pm_score": 1, "selected": false, "text": "allowedProductPaymentMethods" }, { "answer_id": 74125504, "author": "Kalkal", "author_id":...
2022/10/19
[ "https://Stackoverflow.com/questions/74121748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17728702/" ]