qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,162,061
<p><em>This is a simplified version I made of the problem I'm having</em></p> <p>I have my <strong>Game()</strong> function that calls the other <strong>UpdateScore()</strong> and <strong>Score()</strong> functions, <strong>UpdateScore()</strong> adds 1 to <strong>computerScore</strong>, and <strong>Score()</strong> prints that updated value. But that value either doesn't get updated, what am I doing wrong?</p> <pre><code>import time def Game(): condition = True computerScore = 0 while (condition): time.sleep(2) UpdateScore(computerScore) Score(computerScore) def UpdateScore(computerScore): computerScore = computerScore+1 return def Score(computerScore): computerScore = UpdateScore(computerScore) print(computerScore) Game() </code></pre>
[ { "answer_id": 74162093, "author": "Shubham Periwal", "author_id": 7608589, "author_profile": "https://Stackoverflow.com/users/7608589", "pm_score": 0, "selected": false, "text": "import time \n\ndef Game():\n condition = True\n computerScore = 0\n while (computerScore < 2): #Ch...
2022/10/22
[ "https://Stackoverflow.com/questions/74162061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15821540/" ]
74,162,068
<p>I am trying to figure out what is the relationship about monitor and the operation system mutex lock, the java implement the synchronization keywords by monitor, does the monitor invoke the operation system mutex api? or the monitor implement the mutex by himself? I have read the source code <code>src/hotspot/share/runtime/objectMonitor.cpp</code> but still could not figure out.</p>
[ { "answer_id": 74162093, "author": "Shubham Periwal", "author_id": 7608589, "author_profile": "https://Stackoverflow.com/users/7608589", "pm_score": 0, "selected": false, "text": "import time \n\ndef Game():\n condition = True\n computerScore = 0\n while (computerScore < 2): #Ch...
2022/10/22
[ "https://Stackoverflow.com/questions/74162068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2628868/" ]
74,162,070
<p>So ive got a list of restaurant names (say fetched from an api). When I click on a restaurant name, I want it to link to a profile page for that specific restaurant, and this would set the text as &quot;selected&quot;. And when I click &quot;Go back&quot; on that profile page to return to the home page, I want the that restaurant name to say &quot;not selected&quot;.</p> <p>So, if I click on the restaurant name, then in the profile page go back to the home page, the restaurant will show &quot;unselected&quot; since it was selected in the home page, then unselected in the profile page. However, if I click on the restaurant name, then instead of going back to the home page by clicking the &quot;go back&quot;, I type in the url of the home page, it will show &quot;selected&quot;.</p> <p>I'm struggling with making it so when I click &quot;Go back&quot;, the home page shows the restaurant name as having &quot;unselected&quot;.</p> <p><a href="https://codesandbox.io/s/serene-williams-2snv1c?file=/src/App.js" rel="nofollow noreferrer">https://codesandbox.io/s/serene-williams-2snv1c?file=/src/App.js</a></p> <p>(I would also appreciate if I could get the name of this sort of concept so I can look it up myself)</p>
[ { "answer_id": 74162093, "author": "Shubham Periwal", "author_id": 7608589, "author_profile": "https://Stackoverflow.com/users/7608589", "pm_score": 0, "selected": false, "text": "import time \n\ndef Game():\n condition = True\n computerScore = 0\n while (computerScore < 2): #Ch...
2022/10/22
[ "https://Stackoverflow.com/questions/74162070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10613037/" ]
74,162,074
<p>I'm trying to make a code (for school) that compresses and counts the number of adjacent characters that are the same. in this example it would be 4(1) 4(0) 2(1) 2(0). it is supposed to output: 4 4 2 2 but for some reason, it leaves out the last 2.</p> <p>does anyone know how to fix this or make my code more optimised?</p> <p>my code:</p> <pre><code>val = &quot;111100001100&quot; #the value count1 = 0 #counts how many repeated values there are count0 = 0 num = 0 char = val[num] char_count = 0 length = len(val) l1 = length - 1 for char in range(l1): if val[char + 1] == val[char]: count1 += 1 char_count + 1 elif val[char + 1] != val[char]: x = str(count1 + 1) print(x) count1 = 0 char_count + 1* </code></pre> <p>the output: 4 4 2</p>
[ { "answer_id": 74162253, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 3, "selected": true, "text": "itertools.groupby" }, { "answer_id": 74162641, "author": "Jannes", "author_id": 19234686, "aut...
2022/10/22
[ "https://Stackoverflow.com/questions/74162074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307080/" ]
74,162,076
<p>I want to add the function which can upload multiple Photo image via ImagePicker In this code, I can just upload single photo, not mutiple. This app operating by flutter, dart and firebase server.</p> <p>[Code]</p> <pre><code>void dispose() { textEditingController.dispose(); super.dispose(); } File _image; Future _getImage() async { var image = await ImagePicker.pickImage( source: ImageSource.gallery, maxWidth: 1000, maxHeight: 1000, ); setState(() { _image = image; }); } Future _uploadFile(BuildContext context) async { if (_image != null) { final firebaseStorageRef = FirebaseStorage.instance .ref() .child('post') .child('${DateTime.now().millisecondsSinceEpoch}.png'); final task = firebaseStorageRef.putFile( _image, StorageMetadata(contentType: 'image/png'), ); final storageTaskSnapshot = await task.onComplete; final downloadUrl = await storageTaskSnapshot.ref.getDownloadURL(); await Firestore.instance.collection('post').add( { 'contents': textEditingController.text, 'displayName': widget.user.displayName, 'email': widget.user.email, 'photoUrl': downloadUrl, 'userPhotoUrl': widget.user.photoUrl, }); } </code></pre>
[ { "answer_id": 74162253, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 3, "selected": true, "text": "itertools.groupby" }, { "answer_id": 74162641, "author": "Jannes", "author_id": 19234686, "aut...
2022/10/22
[ "https://Stackoverflow.com/questions/74162076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19711930/" ]
74,162,086
<blockquote> <p>Blockquote Hello, I'm trying to make a responsive img grid with the following : 2 imgs at the top, sharing 50% of the space, and 4 imgs underneath with the same aspect ratio.</p> </blockquote> <p>The grid works just fine, until I've decided to add a small caption. What am I doing wrong ?</p> <p>Thank you, have a nice one,</p> <p>Kieran.</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> body { padding: 0px; font-family: sans-serif; background: #f2f2f2; height: 100%; } .first-row { border: 3px solid green; float:left; width: 100%; } .grid-container1 h3 { font-size: 1rem; padding: 5px; float: bottom; } .grid-container1 { border: 1px solid red; } .grid-container1 img { display:inline-block; vertical-align:middle; width: 50%; padding: 5px; } .grid-container2 img { vertical-align: top; width: 25%; float: left; padding: 5px; } .grid-container3 img { vertical-align: top; width: 33.33%; float: left; padding: 5px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="grid-container1"&gt; &lt;a href="#"&gt; &lt;img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/san-fransisco-768x432.jpg" alt="san francisco"&gt; &lt;/a&gt; &lt;h3&gt;lorem ipsum&lt;/h3&gt; &lt;/div&gt; &lt;div class="grid-container1"&gt; &lt;a href="#"&gt; &lt;img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/san-fransisco-768x432.jpg" alt="san francisco"&gt; &lt;/a&gt; &lt;h3&gt;lorem ipsum&lt;/h3&gt; &lt;/div&gt; &lt;div class="grid-container2"&gt; &lt;a href="#"&gt; &lt;img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/san-fransisco-768x432.jpg" alt="san francisco"&gt; &lt;/a&gt; &lt;h3&gt;lorem ipsum&lt;/h3&gt; &lt;/div&gt; &lt;div class="grid-container2"&gt; &lt;a href="#"&gt; &lt;img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/san-fransisco-768x432.jpg" alt="san francisco"&gt; &lt;/a&gt; &lt;h3&gt;lorem ipsum&lt;/h3&gt; &lt;/div&gt; &lt;div class="grid-container2"&gt; &lt;a href="#"&gt; &lt;img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/san-fransisco-768x432.jpg" alt="san francisco"&gt; &lt;/a&gt; &lt;h3&gt;lorem ipsum&lt;/h3&gt; &lt;/div&gt; &lt;div class="grid-container2"&gt; &lt;a href="#"&gt; &lt;img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/san-fransisco-768x432.jpg" alt="san francisco"&gt; &lt;/a&gt; &lt;h3&gt;lorem ipsum&lt;/h3&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74162253, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 3, "selected": true, "text": "itertools.groupby" }, { "answer_id": 74162641, "author": "Jannes", "author_id": 19234686, "aut...
2022/10/22
[ "https://Stackoverflow.com/questions/74162086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11717615/" ]
74,162,115
<p>As a follow up to my question from yesterday (<a href="https://stackoverflow.com/questions/74157639/allocating-data-structures-while-making-the-borrow-checker-happy">allocating data structures while making the borrow checker happy</a>), here is a simplified case. I would like to create a data structure and return both it and a reference to it. The following code does not compile:</p> <pre><code>fn create() -&gt; (String, &amp;str) { let s = String::new(); let r = &amp;s; return (s,r); } fn f() { let (s,r) = create(); do_something(r); } </code></pre> <p>If I restructure my code as follows, everything works fine:</p> <pre><code>fn create&lt;'a&gt;(s : &amp;'a String) -&gt; &amp;'a str { let r = &amp;s; return r; } fn f() { let s = String::new(); let r = create(&amp;s); do_something(r); } </code></pre> <p>Unfortunately, in some cases structuring the code as in the first example is much preferable. Is there some way to make rust accept the first version?</p> <p>Since both versions of the code do exactly the same thing, there shouldn't be any problems with safety. The question is just whether rust's type system is powerful enough to express it.</p>
[ { "answer_id": 74162246, "author": "virchau13", "author_id": 9684433, "author_profile": "https://Stackoverflow.com/users/9684433", "pm_score": 1, "selected": false, "text": "(String, &str)" }, { "answer_id": 74162747, "author": "Achim", "author_id": 20303561, "author_...
2022/10/22
[ "https://Stackoverflow.com/questions/74162115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20303561/" ]
74,162,136
<p>I have a float number x and a list range list_ = [[a, b], [c,d], [e,f]]</p> <p>How can check if the number x is in the list. It means the function will return True in case of</p> <pre><code>a&lt;=x &lt;=b or c&lt;=x &lt;=d or e&lt;=x &lt;=f </code></pre> <p>Otherwise, the function will return False. Could you help me to write a Python code for the function</p> <pre><code>function (x, list_)--&gt; True/False </code></pre>
[ { "answer_id": 74162165, "author": "Ilya", "author_id": 1139541, "author_profile": "https://Stackoverflow.com/users/1139541", "pm_score": 1, "selected": false, "text": "def function(x, list_):\n return any([l[0] < x < l[1] for l in list_])\n" }, { "answer_id": 74162193, "a...
2022/10/22
[ "https://Stackoverflow.com/questions/74162136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5084566/" ]
74,162,146
<p>I have some images on my computer, I want them to use in JSON files Now I need the image URL. How can I get it?</p>
[ { "answer_id": 74162165, "author": "Ilya", "author_id": 1139541, "author_profile": "https://Stackoverflow.com/users/1139541", "pm_score": 1, "selected": false, "text": "def function(x, list_):\n return any([l[0] < x < l[1] for l in list_])\n" }, { "answer_id": 74162193, "a...
2022/10/22
[ "https://Stackoverflow.com/questions/74162146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17166698/" ]
74,162,150
<p>Suppose I have a sum type (or several, in fact), that I know by design all have a common field:</p> <pre><code>data T1 a = C1 String a | C2 Int a | C3 Bool a </code></pre> <pre><code>data T2 a = C4 Int Int a | C5 [String] a </code></pre> <p>Is there a way to access the <code>a</code> field without having to pattern match on all variants across all types?</p> <p>(I ask in the context of defining ASTs &amp; having a neat way of accessing node-specific information)</p>
[ { "answer_id": 74162986, "author": "Carl", "author_id": 383200, "author_profile": "https://Stackoverflow.com/users/383200", "pm_score": 4, "selected": true, "text": "t1ToA :: T1 a -> a\nt1ToA (C1 _ x) = x\nt1ToA (C2 _ x) = x\nt1ToA (C3 _ x) = x\n\nt2ToA :: T2 a -> a\nt2ToA (C4 _ _ x) = x...
2022/10/22
[ "https://Stackoverflow.com/questions/74162150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6827151/" ]
74,162,153
<p>Similar question for vanilla JS <a href="https://stackoverflow.com/questions/42964102/syntax-for-an-async-arrow-function">here</a>. I however want to use async await with typescript function as below.</p> <p>Javascript</p> <pre><code>const foo = async () =&gt; { // do something } </code></pre> <p>Initial attempt</p> <pre><code>export const fetchAirports = async (): Airport[] =&gt; { //More code return airports; }; </code></pre> <p>but i get an error <strong>ts(1055) Type 'Airport[]' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value.</strong> which to me sounds like a lot of jargon. Please remember <strong>I have to specify a return type in the function declaration</strong> otherwise it nullifies the need for typescript in the first place.</p>
[ { "answer_id": 74162986, "author": "Carl", "author_id": 383200, "author_profile": "https://Stackoverflow.com/users/383200", "pm_score": 4, "selected": true, "text": "t1ToA :: T1 a -> a\nt1ToA (C1 _ x) = x\nt1ToA (C2 _ x) = x\nt1ToA (C3 _ x) = x\n\nt2ToA :: T2 a -> a\nt2ToA (C4 _ _ x) = x...
2022/10/22
[ "https://Stackoverflow.com/questions/74162153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19124826/" ]
74,162,159
<p>I have been working on a typescript project. I have created a middleware to check users' subscription and do not want to let users access PUT and POST routes. But I still want them to be able to access GET and DELETE requests. I know that the following line applies the <code>checkSubscription</code> middleware to all the requests on the route.</p> <pre class="lang-js prettyprint-override"><code>router.use(checkSubscription) </code></pre> <p>I only want the middleware to run if the request type is PUT or POST. I could do the following, of course</p> <pre class="lang-js prettyprint-override"><code>router.get(&quot;/endpoint1&quot;, controller1); router.put(&quot;/endpoint2&quot;, checkSubscription, controller2); router.post(&quot;/endpoint3&quot;, checkSubscription, controller3); router.delete(&quot;/endpoint4&quot;, controller4); </code></pre> <p>Notice that the above PUT and POST requests run the <code>checkSubscription</code> middleware. But if I could declare on the top of the route file to run the middleware on all POST and PUT requests, that would save a lot of work and time.</p> <p>Any kind of help would be highly appreciated. Thanks!</p>
[ { "answer_id": 74162190, "author": "robertklep", "author_id": 893780, "author_profile": "https://Stackoverflow.com/users/893780", "pm_score": 0, "selected": false, "text": "router.get(...);\nrouter.delete(...);\n\nrouter.use(checkSubscription);\n\nrouter.post(...);\nrouter.put(...);\n" ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227171/" ]
74,162,172
<p>How do I convert a number to its correlating day of the week?</p> <p>For example:</p> <pre><code>def string(hour_of_day, day_of_week, date) : print(f'{day_of_week} {date} at hour {hour_of_day}') </code></pre> <p>how can I re-write the 'day_of_week' part in <code>print</code> so that when I use the function:</p> <pre><code>string(12, 1, '2020/02/18') </code></pre> <p>How can I get <code>Tuesday 2020/02/18 at hour 12</code> instead of <code>1 2020/02/18 at hour 12</code>?</p>
[ { "answer_id": 74162238, "author": "user19077881", "author_id": 19077881, "author_profile": "https://Stackoverflow.com/users/19077881", "pm_score": 2, "selected": false, "text": "daysdict = { 1: 'Monday', 2: 'Tuesday'}" }, { "answer_id": 74162262, "author": "Gwang-Jin Kim", ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20058055/" ]
74,162,214
<p>I have a dataframe with a single column which contains the names of people as shown below.</p> <pre><code>name -------------- john doe john david doe doe henry john john henry </code></pre> <p>I want to count the number of time each two words appear together in a name regardless of the order. In this example, the words <code>john</code> and <code>doe</code> appear in the same same three times names <code>john doe</code>, <code>john henry doe</code> and <code>doe john</code>.</p> <p><strong>Expected output</strong></p> <pre><code>name1 | name2 | count ---------------------- david | doe | 1 doe | henry | 1 doe | john | 3 henry | john | 2 </code></pre> <p>Notice that <code>name1</code> is the word that comes first in alphabetical order. Currently I have a brute force solution.</p> <ol> <li>Create a list of all unique words in the dataframe</li> <li>For each unique word <code>W</code> in this list, filter the records in the original data frame which contain this <code>W</code></li> <li>From the filtered records, count frequency of other words. This gives the number of time <code>W</code> appears with various other words</li> </ol> <p><strong>Question</strong>: This works fine for small number of records but is not efficient if we have a large number of records as it runs in quadratic complexity. How can it generate the output in a faster way? Is there any function or package that can give these counts?</p> <p><strong>Note</strong>: I tried using n-gram extraction from NLP packages but this over estimates the counts because it internally appends all the names to form a long string due to which the last word on a name and the first word of the next name shows up as a a sequence of words in the appended string which adds up to the count.</p>
[ { "answer_id": 74162548, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 2, "selected": false, "text": "n" }, { "answer_id": 74162756, "author": "Quentin Bracq", "author_id": 10484302, "author_profile": ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10726504/" ]
74,162,239
<p>Does anyone knows how to fix the error when creating a topic in Kafka?</p> <pre class="lang-none prettyprint-override"><code>C:\kafka\bin\windows&gt;kafka-topics.bat --create --bootstrap-server localhost:2181 --replication-factor 1 --partition 1 --topic test Exception in thread &quot;main&quot; joptsimple.UnrecognizedOptionException: partition is not a recognized option at joptsimple.OptionException.unrecognizedOption(OptionException.java:108) at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510) at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56) at joptsimple.OptionParser.parse(OptionParser.java:396) at kafka.admin.TopicCommand$TopicCommandOptions.&lt;init&gt;(TopicCommand.scala:567) at kafka.admin.TopicCommand$.main(TopicCommand.scala:47) at kafka.admin.TopicCommand.main(TopicCommand.scala) </code></pre>
[ { "answer_id": 74162548, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 2, "selected": false, "text": "n" }, { "answer_id": 74162756, "author": "Quentin Bracq", "author_id": 10484302, "author_profile": ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18480886/" ]
74,162,243
<p><a href="https://i.stack.imgur.com/agfpg.png" rel="nofollow noreferrer">The code from my project</a></p> <p>The output: How long is the lasagna in the oven: 10 30 How many layers do you want to make: 20 40 None</p> <p>My question is why is the Ergebniss1 a &quot;none&quot; and not the number from the function?</p>
[ { "answer_id": 74162548, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 2, "selected": false, "text": "n" }, { "answer_id": 74162756, "author": "Quentin Bracq", "author_id": 10484302, "author_profile": ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307214/" ]
74,162,292
<p>Below is code for a password generator which I've written using Python3 and tkinter. I'm having difficulty with the last line of code <code>and any(c in spec for c in password)</code>. The while loop does not terminate when I add this last line to the if statement in the while loop. I've looked at all the other answers online for &quot;check string for special characters&quot; and can't find a solution to make my while loop work. The last line of my code should check if there is any special characters in the password, if not, then generate password again.</p> <pre><code>import string import secrets alphabet = string.ascii_letters + string.digits + string.punctuation spec = string.punctuation while True: password = ''.join(secrets.choice(alphabet) for i in range(12)) if (any(c.islower() for c in password) and any(c.isupper() for c in password) and any(c.isdigit() for c in password) and any(c in spec for c in password)): break </code></pre>
[ { "answer_id": 74162505, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 0, "selected": false, "text": "secrets" }, { "answer_id": 74162560, "author": "codeblock", "author_id": 20307116, "author_prof...
2022/10/22
[ "https://Stackoverflow.com/questions/74162292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307116/" ]
74,162,299
<p>Project: vue3+vite+ts, created by npm init vue@latest Software: phpstorm Problems and errors: The style has taken effect, but the ide does not have any intellisense and reports an error Error notification:Tailwind CSS: Cannot read properties of undefined (reading 'modifier')</p>
[ { "answer_id": 74166448, "author": "The Oc1s", "author_id": 18770686, "author_profile": "https://Stackoverflow.com/users/18770686", "pm_score": 0, "selected": false, "text": "0.9.0" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74162299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15391755/" ]
74,162,300
<p>I am using a gridview.builder and it is wrapped with an Expanded widget. i want to return a container from this gridview and this container has a child Column.</p> <p>Column will render some of text widget and after that it will contain some row widget with icon and text (space between)</p> <p>problem 1: when i place column inside container it shows a fixed height of this container and i can't able to place extra widget in column. it shows :</p> <blockquote> <p>A RenderFlex overflowed by 134 pixels on the bottom.</p> </blockquote> <p>how can i create a widget like this? <a href="https://i.stack.imgur.com/WUd30.png" rel="nofollow noreferrer">enter image description here</a></p> <p>here's my code:</p> <pre><code> body: Column( children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 48.0), child: TextFormField( decoration: InputDecoration( suffixIcon: Icon(Icons.search), // labelText: 'Team Name', hintText: 'Search Employee', ), ), ), SizedBox( height: 30, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ GestureDetector( onTap: () { // setState(() { print('tapped 1'); // }); Center( child: Text('HEllo'), ); }, child: IconRoundCircle( hasIcon: false, title: 'Member', border: Utils.colorPrimary, // color: , ), ), IconRoundCircle( hasIcon: false, title: 'Maneger', border: Utils.colorBlue, color: Colors.white, ), IconRoundCircle( hasIcon: false, border: Utils.colorYollow, color: Utils.colorYollowSecondary, title: 'Admin', ), ], ), Expanded( child: GridView.builder( shrinkWrap: true, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, ), itemCount: 2, itemBuilder: (BuildContext context, int index) { return Padding( padding: EdgeInsets.all(18.0), child: Container( decoration: BoxDecoration( border: Border.all(color: Colors.grey, width: 2), borderRadius: BorderRadius.circular(5), ), child: Expanded( child: Column( children: [ Icon( Icons.person, size: 50, color: Colors.black, ), Text('Name'), Text('Designation'), Icon( Icons.person, size: 50, color: Colors.black, ), Text('data'), Text('data'), Text('data'), Text('data'), Text('data'), Text('data'), Text('data'), Text('data'), ], ), ), ), ); }, ), ), ], ), </code></pre> <p>here's how ui error look like:</p> <p><a href="https://i.stack.imgur.com/IMU1j.png" rel="nofollow noreferrer">enter image description here</a></p> <p>related error :</p> <blockquote> <p>Tried to build dirty widget in the wrong build scope. Incorrect use of ParentDataWidget.</p> </blockquote>
[ { "answer_id": 74166448, "author": "The Oc1s", "author_id": 18770686, "author_profile": "https://Stackoverflow.com/users/18770686", "pm_score": 0, "selected": false, "text": "0.9.0" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74162300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10808222/" ]
74,162,376
<p>I've got a case where I have a text that begins with characters like <code>&amp;nbsp;</code> that I do not want to escape, but then the rest of the string I do want to escape.</p> <p>In Vue, given <code>text = &quot;&amp;nbsp;&amp;nbsp;&lt;strong&gt;something&lt;/strong&gt;&quot;</code>, if I do:</p> <pre class="lang-html prettyprint-override"><code>&lt;p&gt;{{ text }}&lt;/p&gt; </code></pre> <p>It escapes all text, including the <code>&amp;nbsp;</code>, printing out:</p> <p>&amp;nbsp;&amp;nbsp;&lt;strong&gt;something&lt;/strong&gt;</p> <p>If I do this:</p> <pre class="lang-html prettyprint-override"><code>&lt;p v-html=&quot;text&quot;&gt;&lt;/p&gt; </code></pre> <p>Then I get:</p> <p>  <strong>something</strong></p> <p>What I want to achieve is not escaping the <code>&amp;nbsp;</code> but escaping all the rest of the html. My thought was doing something like this:</p> <pre class="lang-html prettyprint-override"><code>&lt;p v-html=&quot;formatText()&quot;&gt;&lt;/p&gt; &lt;script&gt; methods: { formatText() { return '&amp;nbsp;&amp;nbsp;' + e('&lt;strong&gt;something&lt;/strong&gt;'); } } &lt;/script&gt; </code></pre> <p>where <code>e</code> would be some function that escapes the undesired html.</p> <p>Does Vue have a method like that? Or is that something I'd have to write up? I'm not sure how Vue does its escaping under the hood.</p>
[ { "answer_id": 74166448, "author": "The Oc1s", "author_id": 18770686, "author_profile": "https://Stackoverflow.com/users/18770686", "pm_score": 0, "selected": false, "text": "0.9.0" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74162376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1193304/" ]
74,162,389
<p>I try to scrap some informations on a website. There is my code</p> <pre><code>from lib2to3.pgen2 import driver from selenium import webdriver import time from selenium.webdriver.common.by import By import pyvirtualdisplay class Informations: def __init__(self): self.list_site_by_siren = [&quot;418 096 392&quot;, &quot;334 992 798&quot;] self.website = &quot;https://www.pappers.fr/&quot; def main(): informations = Informations() print(informations.list_site_by_siren) driver = webdriver.Chrome() driver.set_window_size(1920,1500) driver.get(informations.website) driver.find_element(By.XPATH, &quot;//input[@placeholder='Entreprise, N° SIREN, Dirigeant, Mot-clé...']&quot;).send_keys(informations.list_site_by_siren[0]) driver.find_element(By.XPATH, '//button[text()=&quot;Rechercher&quot;]').click() time.sleep(1) driver.find_element(By.XPATH, '//button[contains(text(),&quot;Voir les comptes&quot;)]').click() #driver.find_element(By.CLASS_NAME, &quot;button mt2&quot;).click() same but doesnt work too </code></pre> <p>my driver.find_element(By.CLASS_NAME, &quot;button mt2&quot;).click() doesn't work.</p> <p><a href="https://i.stack.imgur.com/i5GjF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i5GjF.png" alt="enter image description here" /></a></p> <p>i would like to click on &quot;Voir les comptes&quot; and start the force the download of the file but i don't know how to do that.</p> <p>this is the html code</p> <pre><code>&lt;a href=&quot;micromania-418096392/comptes/MICROMANIA - Comptes sociaux 2022 19-07-2022.pdf&quot; title=&quot;Voir les comptes 2022-01-31 de MICROMANIA&quot; target=&quot;_blank&quot; class=&quot;button mt2&quot;&gt;VOIR LES COMPTES &lt;span class=&quot;fas fa-download&quot; style=&quot;margin-left: 4px;&quot;&gt;&lt;/span&gt;&lt;/a&gt; </code></pre> <p>So at first i have to locate micromania-418096392/comptes/MICROMANIA - Comptes sociaux 2022 19-07-2022.pdf and the second part is to download it but i dont find how i can do that and actually it doesn't detect the button.</p> <p>Thanks for yours answers!</p>
[ { "answer_id": 74162461, "author": "Dmitriy Neledva", "author_id": 16786350, "author_profile": "https://Stackoverflow.com/users/16786350", "pm_score": 1, "selected": false, "text": "driver.find_element(By.CLASS_NAME, \"button mt2\").click() " }, { "answer_id": 74162992, "auth...
2022/10/22
[ "https://Stackoverflow.com/questions/74162389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13934941/" ]
74,162,417
<p>I'm learning code so I have a problem that I want to show date from datagridview to textbox but I don't know how to show it without time. Thank you guys. <a href="https://i.stack.imgur.com/WSnND.png" rel="nofollow noreferrer">enter image description here</a></p> <p>Code I write <code>txtDate.Text = dataGrid.Cells[2].Value.ToString();</code></p> <p>I tried <code>txtDate.Text = dataGrid.Cells[2].Value.ToString(&quot;DD/MM/YYYY&quot;);</code> It has erro &quot; No overload for method 'ToString' &quot;.</p> <p>Thank you.</p>
[ { "answer_id": 74162527, "author": "Mehdi Kacim", "author_id": 17838896, "author_profile": "https://Stackoverflow.com/users/17838896", "pm_score": 0, "selected": false, "text": "if(!string.IsNullOrWhiteSpace(dataGrid.Cells[2].Value.ToString()) && DateTime.TryParse(dataGrid.Cells[2].Value...
2022/10/22
[ "https://Stackoverflow.com/questions/74162417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14498072/" ]
74,162,421
<p>This is the most frequent problem I come across, in this file was trying to access the innerHTML of the textarea using the same property.</p> <p>But the error says that the input.innerHTML is null.</p> <p>You can understand better by code,</p> <pre><code>import React, { Component, useEffect, useState } from 'react' import './Body.css'; import axios from &quot;axios&quot;; import './Body.css' export default function Navbar() { let noteArray; let input = document.getElementById('.input_area') ; const AddNote = () =&gt;{ console.log(&quot;here&quot; ,input.innerHTML) ; } return ( &lt;&gt; &lt;div&gt; &lt;div className=&quot;input_info&quot;&gt; &lt;textarea id='input_area' name=&quot;&quot; cols=&quot;50&quot; rows=&quot;5&quot;&gt;op&lt;/textarea&gt; &lt;br /&gt; &lt;button onClick={AddNote} className='add'&gt;Add Note&lt;/button&gt; &lt;/div&gt; &lt;br /&gt; &lt;div id='display_info' &gt; &lt;/div&gt; &lt;/div&gt; &lt;/&gt; ) } </code></pre> <p>I tried from class, id, and querySelector but none of them is working.</p> <p>Can anyone suggest me some edits?</p> <p>EDIT--</p> <p><a href="https://i.stack.imgur.com/YldXW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YldXW.png" alt="THIS IS THE CONSOLE" /></a></p>
[ { "answer_id": 74162479, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 2, "selected": true, "text": "DOM" }, { "answer_id": 74163895, "author": "Ozan Mudul", "author_id": 12260088, "author_profile": ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19757319/" ]
74,162,451
<p>im pretty new to coding so maybe the answer is simple.</p> <p>Im creating a tower defense game and right now im trying to code a tower, which adds a serializable amount of money after each wave is defeated.</p> <p>My idea is that the script which controls the WaveSpawning should call all MoneyPumps to perform the function &quot;GiveMoney()&quot;, that sits on their script MoneyPump. But there is a problem with static stuff, which I cant find a solution to.</p> <p>Please help, thanks.</p> <p>The Segment for WaveSpawning:</p> <pre><code> void Update() { if(spawningWave){return;} if(GameManager.gameOver){enabled = false; return;} maxWavePlayTime -= Time.deltaTime; if(enemiesAlive &gt; 0 &amp;&amp; maxWavePlayTime &gt;= 0f) { return; } if(waveIndex == waves.Length &amp;&amp; !spawningWave) { gameManager.LevelWon(); this.enabled = false; return; } //THE IDEA IS TO CALL HERE THE MONEY PUMPS 1 TIME if(Countdown &lt;= 0f ) { Stats.WavesSurvived++; waveToDisplay = waveIndex + 1; WaveIndexDisplay.text = &quot;Wave &quot; + waveToDisplay.ToString(); spawningWave = true; StartCoroutine(SpawnWave()); Countdown = WaveCounter; maxWavePlayTime = StartmaxWavePlayTime; return; } </code></pre> <p>The short script for MoneyPumps:</p> <pre><code>using System.Collections; using System.Collections.Generic; using UnityEngine; public class MoneyPump : MonoBehaviour { public int moneyEveryRound = 25; public static bool giveMoney = false; public void GiveMoney() { Stats.Money += moneyEveryRound; } } </code></pre> <p>The stuff to spawn a turret: 1.</p> <pre><code>[System.Serializable] public class TurretBluePrint { public GameObject prefab; public int cost; public GameObject upgradedPrefab; public int upgradeCost; public int SellDivider; } </code></pre> <ol start="2"> <li>If we click on a designated Button the SelectMoneyPump() function gets called</li> </ol> <pre><code>public class Shop : MonoBehaviour { public TurretBluePrint LaserBeamer; public void SelectMoneyPump() { Debug.Log(&quot;Money Pump Purchased&quot;); BuildManager.SelectTurretToBuild(MoneyPump); } } </code></pre> <ol start="3"> <li></li> </ol> <pre><code> public void SelectTurretToBuild (TurretBluePrint turret) { turretToBuild = turret; DeselectNode(); } </code></pre> <ol start="4"> <li>If we now click on a node (basically a just a tile on a grid):</li> </ol> <pre><code>public class Node : MonoBehaviour { ... void OnMouseDown() ... BuildTurret(buildmanager.GetTurretToBuild()); ... } public class BuildManager : MonoBehaviour { ... public TurretBluePrint GetTurretToBuild() { return turretToBuild; } ... } </code></pre> <ol start="5"> <li>Turret building</li> </ol> <pre><code>void BuildTurret(TurretBluePrint blueprint) { ... turretBlueprint = blueprint; GameObject _turret = (GameObject)Instantiate(blueprint.prefab, GetBuildPosition(), Quaternion.identity); ... } </code></pre>
[ { "answer_id": 74163025, "author": "GeorgeKarlinzer", "author_id": 19109755, "author_profile": "https://Stackoverflow.com/users/19109755", "pm_score": 1, "selected": false, "text": "GiveMoney" }, { "answer_id": 74166410, "author": "Lexus", "author_id": 20307382, "auth...
2022/10/22
[ "https://Stackoverflow.com/questions/74162451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307382/" ]
74,162,456
<p>I am new to python 3 and trying to work with a list but struggling. I have read things but some are quite confusing, so I have been playing with code but getting nowhere fast.</p> <p>I want to store 3 elements (Count,Angle,Speed) for every second of the day which is 86400 entries.</p> <p>To make things easier for this example lets have a list of 2 entries of 3 elements I created a list and initially want to set every element to 0</p> <pre><code>a = [[0, 0, 0], [0, 0, 0]] print(a[0]) print(a[0][0]) print(a[0][1]) print(a[0][2]) print(a[1]) print(a[1][0]) print(a[1][1]) print(a[1][2]) print(&quot;** Change a[0][2] to 7 from 0&quot;) a[0][2] = 7 print(a[0]) print(a[0][0]) print(a[0][1]) print(a[0][2]) print(&quot;-----------&quot;) print(a[1]) print(a[1][0]) print(a[1][1]) print(a[1][2]) print(&quot;-----------&quot;) </code></pre> <p>This works great and for example I am able to access and change a[0][2]</p> <h2>[0, 0, 0] 0 0 0 [0, 0, 0] 0 0 0 ** Change a[0][2] to 7 from 0 [0, 0, 7] 0 0 7</h2> <h2>[0, 0, 0] 0 0 0</h2> <p>However I want to be able to pre-fill the list with 0 as it will be tedious to do it for 86400 entries but again for this example lets go with 2</p> <p>So I read up and seen how to do it using... a = [[0,0,0]] * 2</p> <pre><code>a = [[0,0,0]] * 2 print(a[0]) print(a[0][0]) print(a[0][1]) print(a[0][2]) print(a[1]) print(a[1][0]) print(a[1][1]) print(a[1][2]) print(&quot;** Change a[0][2] to 7 from 0&quot;) a[0][2] = 7 print(a[0]) print(a[0][0]) print(a[0][1]) print(a[0][2]) print(&quot;-----------&quot;) print(a[1]) print(a[1][0]) print(a[1][1]) print(a[1][2]) print(&quot;-----------&quot;) </code></pre> <p>However why does a[1][2] also change to 7</p> <h2>[0, 0, 0] 0 0 0 [0, 0, 0] 0 0 0 ** Change a[0][2] to 7 from 0 [0, 0, 7] 0 0 7</h2> <h2>[0, 0, 7] 0 0 7</h2> <p>I have obviously done something wrong with pre-filling the list or even defining the list, so if anybody can help I would be grateful.</p> <p>Thanks</p>
[ { "answer_id": 74163025, "author": "GeorgeKarlinzer", "author_id": 19109755, "author_profile": "https://Stackoverflow.com/users/19109755", "pm_score": 1, "selected": false, "text": "GiveMoney" }, { "answer_id": 74166410, "author": "Lexus", "author_id": 20307382, "auth...
2022/10/22
[ "https://Stackoverflow.com/questions/74162456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4279233/" ]
74,162,467
<p>I have a question on how to map correctly my list.</p> <p>I have the following code:</p> <pre><code>class Bar(): def __init__(self, i, j): self.i = i-1 self.j = j-1 </code></pre> <p>For the following list:</p> <pre><code>bars = [Bar(1,2), Bar(2,3), Bar(3,4), Bar(4,5), Bar(5,1),Bar(1,4), Bar(2,4), Bar(4,6), Bar(6,5)] </code></pre> <p>But for my problem, I have an array like this:</p> <pre><code>elementsmat=[[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 1], [6, 1, 4], [7, 2, 4], [8, 4, 6], [9, 6, 5]] </code></pre> <p>I used the following code to obtain an array where I removed the first element of each list of the list and then transformed it into a list.</p> <pre><code>s= np.delete(elementsmat, 0, 1) r = s.tolist() Output: [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 4], [2, 4], [4, 6], [6, 5]] </code></pre> <p>So, how can I apply the Bar function to all the elements of my new array correctly? I did this but I got the following error.</p> <pre><code>bars = map(Bar,r) __init__() missing 1 required positional argument: 'j' </code></pre> <p>I thought it could be because in the first one the list has () and in my list I have [], but I am not sure.</p>
[ { "answer_id": 74163025, "author": "GeorgeKarlinzer", "author_id": 19109755, "author_profile": "https://Stackoverflow.com/users/19109755", "pm_score": 1, "selected": false, "text": "GiveMoney" }, { "answer_id": 74166410, "author": "Lexus", "author_id": 20307382, "auth...
2022/10/22
[ "https://Stackoverflow.com/questions/74162467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20276952/" ]
74,162,469
<p>So recently I started coding my first FPS game. I experienced a problem with my pause menu. The problem is when I have my game paused my mouse is still controling the camera and when I want to press some buttons in menu camera keeps following my mouse. I searched for solution to this problem on web, but I haven't found the solution (even my code is similar to some I've found).</p> <pre><code>using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class PauseMenu : MonoBehaviour { public static bool gameIsPaused; public GameObject pauseMenuUI; void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Pause(); } } public void Resume() { Cursor.lockState = CursorLockMode.Locked; pauseMenuUI.SetActive(false); Time.timeScale = 1f; gameIsPaused = false; } void Pause() { Cursor.lockState = CursorLockMode.None; pauseMenuUI.SetActive(true); gameIsPaused=true; Time.timeScale = 0f; } public void LoadMenu() { Time.timeScale = 1f; SceneManager.LoadScene(&quot;Menu&quot;); } public void QuitGame() { Debug.Log(&quot;Quitting game...&quot;); Application.Quit(); } } </code></pre>
[ { "answer_id": 74162611, "author": "rustyBucketBay", "author_id": 11826132, "author_profile": "https://Stackoverflow.com/users/11826132", "pm_score": 1, "selected": false, "text": "public class CameraRotation : MonoBehaviour\n{\n public isGamePaused; // changed from outside when you p...
2022/10/22
[ "https://Stackoverflow.com/questions/74162469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307399/" ]
74,162,482
<p>I have the following snippet:</p> <pre><code>set grid set xlabel &quot;Entropy&quot; set ylabel &quot;Amortized work&quot; set xrange [-0.05:1.05] set style line 1 linecolor rgb '#516db0' linetype 2 linewidth 5 f(x) = -1.3973 * x ** 2 + 1.3947 * x + 0.5796 F = '$-1.3973 x^2 + 1.3947 x + 0.5796$' set terminal cairolatex pdf input size 700,700 color colortext set key opaque box lc &quot;black&quot; linewidth 3 plot 'RatioVerboseData.dat', f(x) set output </code></pre> <p>The data file <code>RatioVerboseData.dat</code> looks like this:</p> <pre><code>0.93070 0.290710 0.94060 0.281450 0.95050 0.254771 0.96040 0.241656 </code></pre> <p>When I run the script with the gnuplot, it outputs:</p> <pre><code>plot 'RatioVerboseData.dat', f(x) ^ cairolatex terminal cannot write to standard output &quot;EntropyVerboseData.plt&quot;, line 15: util.c: No error </code></pre> <p>I use gnuplot 4.6.7 and MiKTeX-pdfTeX 4.10 (MiKTeX 22.7)</p>
[ { "answer_id": 74162611, "author": "rustyBucketBay", "author_id": 11826132, "author_profile": "https://Stackoverflow.com/users/11826132", "pm_score": 1, "selected": false, "text": "public class CameraRotation : MonoBehaviour\n{\n public isGamePaused; // changed from outside when you p...
2022/10/22
[ "https://Stackoverflow.com/questions/74162482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1049393/" ]
74,162,491
<p>I'm trying to make it so that an image can be clicked 3 times before it disappears, and I would like that function to repeat itself. At this point it only works the first time the image pops up, after that it disappears after 1 click. Sorry for the confusing code.(It works now)</p> <pre><code> let clickMonster3=0; const monsterCounter3=()=&gt;clickMonster3++; function monster003(){ if(clickMonster3==3){ this.style.display='none' }else{ monsterCounter3() } wolfmonster3.onclick=monster003; setInterval(monster003,6000); </code></pre>
[ { "answer_id": 74162611, "author": "rustyBucketBay", "author_id": 11826132, "author_profile": "https://Stackoverflow.com/users/11826132", "pm_score": 1, "selected": false, "text": "public class CameraRotation : MonoBehaviour\n{\n public isGamePaused; // changed from outside when you p...
2022/10/22
[ "https://Stackoverflow.com/questions/74162491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20252132/" ]
74,162,500
<p>I was trying to implement a moving system but there is an error that I don’t know what it means:</p> <blockquote> <p>Assets\moving_BEAN.cs(14,52): error CS1526: A new expression requires (), [], or {} after type</p> </blockquote> <p>This is my code:</p> <pre class="lang-cs prettyprint-override"><code>using System.Collections; using System.Collections.Generic; using UnityEngine; public class moving_BEAN : MonoBehaviour { public float speed; void Update() { float h = Input.GetAxisRaw(&quot;Horizontal&quot;); float v = Input.getAxisRaw(&quot;Vertical&quot;); gameObject.transform.position = new vector2; transform.position.x + (h*speed); transform.position.y +(v * speed); } } </code></pre>
[ { "answer_id": 74162571, "author": "maxkcy", "author_id": 16131911, "author_profile": "https://Stackoverflow.com/users/16131911", "pm_score": -1, "selected": false, "text": "gameObject.transform.position = new Vector2();\n" }, { "answer_id": 74162867, "author": "Attila Gál", ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19683150/" ]
74,162,515
<p>I am trying to create a function which receives an ordered array of values and associated frequencies as input and produces the median of the observations as output. My idea was to recreate the original data set by repeatedly adding each value, in order, to a new variable according to its frequency of occurrence. After that, I would just call a function I've already created for calculating the median of a set of raw observations.</p> <p>So, for example. So we have:</p> <pre><code>severities = np.arange(7) with_helmet = np.array([248, 58, 11, 3, 2, 8, 1]) </code></pre> <p>Then I want my function to add zero 248 times, one 58 times, and so on. I'm new to numpy, and I'm embarrassed to say I'm not sure how to do this. A helpful function I found was</p> <pre><code>np.repeat(array, repeats) </code></pre> <p>but that duplicates each element a set number of times, whereas I want to duplicate each element in values the number of times it occurs (i.e. according to the corresponding frequency value).</p> <p>Can anyone provide in suggestions (in base python and numpy only)?</p>
[ { "answer_id": 74163161, "author": "Joao_PS", "author_id": 20262902, "author_profile": "https://Stackoverflow.com/users/20262902", "pm_score": 2, "selected": true, "text": "import numpy as np\nimport collections\n\nseverities = np.arange(7)\nwith_helmet = np.array([248, 58, 11, 3, 2, 8, ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17934180/" ]
74,162,526
<p>Microsoft says:</p> <blockquote> <p>A structure type (or struct type) is a value type that can encapsulate data and related functionality.</p> <p>Record struct is value type that encapsulates data.</p> </blockquote> <p>Also says:</p> <blockquote> <p>For struct,two objects are equal if they're of the same type and store same value</p> </blockquote> <blockquote> <p>For record struct,two objects are equal if they're of the same type and store same value</p> </blockquote> <p>For me both struct and record struct have same definition. Also compared compiler generated code for struct and record struct but still confused about when struct or struct record should be used. Do you have any real world example?</p>
[ { "answer_id": 74162751, "author": "shingo", "author_id": 6196568, "author_profile": "https://Stackoverflow.com/users/6196568", "pm_score": 2, "selected": false, "text": "public record struct C(string name);\n" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74162526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5705803/" ]
74,162,552
<p>I have a Future Builder in my flutter app and it displays --</p> <ol> <li>Error : if there's an error in json parsing</li> <li>Data : if everything goes smooth</li> <li>Loader : if its taking time</li> </ol> <p>Everything works. the Future is calling a 'future' function thats doing a get request of some student data and the 'builder' is displaying it. I have an edit dialog box on the same page. I can edit the student information through the put request. The problem is that when I click on the form fields in the edit dialog box, I notice that get request is automatically happening approx 10 times. When I save the edits, a confirmation dialog box appears that data is updated. While this happens again get requests happens upto 10 times. And then it pops. So there are round about 20 useless requests happening on the server. I think it happens because when I click the form fields the keyboard appears and the underlying displaying widget rebuilds, calling the api. When data is edited keyboards goes back into its place again widget rebuilds, calling the api. How can I resolve this issue ?</p> <p>this is the code if it helps :</p> <pre><code> child: FutureBuilder( future: APIs().getStudentDetails(), builder: (context, data) { if (data.hasError) { return Padding( padding: const EdgeInsets.all(8), child: Center(child: Text(&quot;${data.error}&quot;))); } else if (data.hasData) { var studentData = data.data as List&lt;StudentDetails&gt;; return Padding( padding: const EdgeInsets.fromLTRB(0, 15, 0, 0), child: SingleChildScrollView( child: SizedBox( height: MediaQuery.of(context).size.height * 0.9, child: ListView.builder( itemCount: studentData.length, itemBuilder: ((context, index) { final student = studentData[index]; final id = student.studentId; final father = student.fatherName; final mother = student.motherName; final cg = student.cg; final cityName = student.city; final studentName = student.studentName; return SizedBox( child: Padding( padding: const EdgeInsets.all(30.0), child: SingleChildScrollView( child: GestureDetector( onDoubleTap: () { edit(context, id!, studentName!, father, mother, cg, cityName!); }, child: Column(children: [ CustomReadOnlyField( hintText: id.toString()), CustomReadOnlyField(hintText: studentName), CustomReadOnlyField(hintText: father), CustomReadOnlyField(hintText: mother), CustomReadOnlyField( hintText: cg.toString()), CustomReadOnlyField(hintText: cityName), ]), ), ), ), ); }), scrollDirection: Axis.vertical, ), ), ), ); } else { return const Center(child: CircularProgressIndicator()); } }, ), </code></pre>
[ { "answer_id": 74162620, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 0, "selected": false, "text": "future" }, { "answer_id": 74162626, "author": "rasityilmaz", "author_id": 15812214, "aut...
2022/10/22
[ "https://Stackoverflow.com/questions/74162552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17879169/" ]
74,162,586
<p>I am trying to traverse the fp in <code>babashka</code>, and have found that running <code>(shell &quot;cd ..&quot;)</code> in my script <code>bb-test</code> causes an error:</p> <pre><code>----- Error -------------------------------------------------------------------- Type: java.io.IOException Message: Cannot run program &quot;cd&quot;: error=2, No such file or directory Location: /home/jack/Documents/clojure/leingit/./bb-test:120:1 </code></pre> <p>Any ideas?</p>
[ { "answer_id": 74162620, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 0, "selected": false, "text": "future" }, { "answer_id": 74162626, "author": "rasityilmaz", "author_id": 15812214, "aut...
2022/10/22
[ "https://Stackoverflow.com/questions/74162586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19582765/" ]
74,162,596
<p>I am new to react and im trying to understand how to use the hook &quot;useState()&quot;. So here is my problem, i have a useState() list of object with two string, a char and a color. I set the string color in the className of my element.</p> <p>Then my purpose is to change the color of the char depending of what i type into my input. But i understand there is a delay for useState(), it's returning the changed value one value late... Then i need &quot;useEffect()&quot; so here is my code maybe it's more clear to you:</p> <pre><code>const [inputValue, setInputValue] = useState(''); const [words, setWords] = useState([{str: 'A', color: 'color-one'}, {str: &quot;B&quot;, color:&quot;color-one&quot;}, {str: &quot;C&quot;, color: &quot;color-one&quot;}]); const inputHandler =(event) =&gt;{ const string = event.target.value; setInputValue(string); } useEffect(()=&gt;{ const charWords = words.map(word =&gt; word.str); const charInput = inputValue.charAt(inputValue.length-1); if(charInput === charWords[inputValue.length-1]){ const goodAnswer = words.map((elem,i)=&gt;{ if(i === inputValue.length-1){ return {...elem, color: &quot;color-two&quot;,} }else{ return elem; } }) setWords(goodAnswer); }else{ if(charInput ===&quot;&quot;){ }else{ const wrongAnswer = words.map((elem,i)=&gt;{ if(i === inputValue.length-1){ return {...elem, color: &quot;wrong-answer&quot;,} }else{ return elem; } }) setWords(wrongAnswer); } } }, [inputValue]) return( &lt;div&gt; {words.map((elem)=&gt;( &lt;label className={elem.color}&gt;{elem.str}&lt;/label&gt; ))} &lt;input value={inputValue} onChange={inputHandler}/&gt; &lt;/div&gt; ) } export default TestComponent; </code></pre> <p>So the code is working fine. The problem is the console say:</p> <pre><code>&quot;Line 39:8: React Hook useEffect has a missing dependency: 'words'. Either include it or remove the dependency array react-hooks/exhaustive-deps&quot; </code></pre> <p>But the problem, if i put my state &quot;words&quot; in my dependency array, i have infinite loop.</p> <p>So here is my question, how to solve this &quot;problem&quot;, maybe i do something wrong, or maybe i can let the warning in the compiler..</p> <p>Thank you for the answers.</p> <p><strong>Edit:</strong> I tried something new i create a new useSate like a copy of my array object. And in my useEfect, i set this state and now i can add &quot;words&quot; into my array dependencies. But the problème now, when i change the value i add too the previous objects of the non-modified useState.</p> <pre><code> if(charInput === charWords[inputValue.length-1]){ const goodAnswer = words.map((elem,i)=&gt;{ if(i === inputValue.length-1){ return{...elem, color: &quot;color-two&quot;,}; }else{ //here it return the &quot;normal-color&quot; because my useState named &quot;words&quot; has not change... return elem; } }) setUpdatedWords(goodAnswer); </code></pre> <p>So how can i fix this now ? :((</p>
[ { "answer_id": 74162620, "author": "Yeasin Sheikh", "author_id": 10157127, "author_profile": "https://Stackoverflow.com/users/10157127", "pm_score": 0, "selected": false, "text": "future" }, { "answer_id": 74162626, "author": "rasityilmaz", "author_id": 15812214, "aut...
2022/10/22
[ "https://Stackoverflow.com/questions/74162596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19788387/" ]
74,162,604
<p>I want to escape curly braces in my regular expression. Unfortunately the <code>\\</code> does not work. The problem is that the regular expression does not work on IOS mobile devices.</p> <p>The regular expression is used in Angular forms:</p> <pre><code>Validators.pattern('(?&lt;!\w)(\(?(\+|00)?48\)?)?[ -]?\d{3}[ -]?\d{3}[ -]?\d{3}(?!\w)'); </code></pre> <p>Whenever I enter the site that does use this expression on IOS mobile device, then I can see in chrome errors related to regular expression. If I delete this pattern, then the site works without any problems.</p>
[ { "answer_id": 74163072, "author": "Hareen Udayanath", "author_id": 13915885, "author_profile": "https://Stackoverflow.com/users/13915885", "pm_score": 1, "selected": false, "text": "Validators.pattern(new RegExp(/^(?<!\\w)(\\(?(\\+|00)?48\\)?)?[ -]?\\d{3}[ -]?\\d{3}[ -]?\\d{3}(?!\\w)$/,...
2022/10/22
[ "https://Stackoverflow.com/questions/74162604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10728774/" ]
74,162,607
<p>How do i print an input using the print function? (it should allow the user to type)</p> <pre><code> if ChooseGame==&quot;1&quot;: part1story = input(&quot;Do you want to skip the story[y] or [n]&quot;) if part1story==&quot;y&quot;: robotwarpart1() </code></pre> <p>As you can see, the robotwarpart1 function will only be called if we give input to part1story. Yes i know, my code should just work fine, but i get this error: (I'm using replit python)</p> <p>NameError: Name part1story is not defined.</p>
[ { "answer_id": 74162644, "author": "esskayesss", "author_id": 20063482, "author_profile": "https://Stackoverflow.com/users/20063482", "pm_score": 1, "selected": false, "text": "part1story = 'n'\nif ChooseGame == '1':\n part1story = input(\"Do you want to skip the story[y] or [n]\")\n\ni...
2022/10/22
[ "https://Stackoverflow.com/questions/74162607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20302323/" ]
74,162,616
<p>I have log files generated from Python's logging module that truncates with ellipses in the middle of lines, at around 159 characters or 160 if you count newline.</p> <p>At first, I thought it was VSCode doing the truncating. The file was loaded into Notepad and the lines were the same width. It's likely the lines were truncated with Python's logging module.</p> <p>Settings for logging module:</p> <pre><code>import logging as log from logging.handlers import RotatingFileHandler log.basicConfig( handlers=[RotatingFileHandler('./logs/kucoin_bot.log', maxBytes=100000, backupCount=100, encoding='utf-8')], level=log.DEBUG, format=&quot;[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s&quot;, datefmt='%Y-%m-%dT%H:%M:%S') </code></pre> <p>Prettier extension is installed in VSCode. What are the options to expand this line to its full width to show all the details of the log?</p> <pre><code>[2022-10-22T01:47:04] DEBUG [websockets.client.read_frame:1152] &lt; TEXT '{&quot;type&quot;:&quot;message&quot;,&quot;topic&quot;:&quot;/spotMarket/level2De...estamp&quot;:1666428417709}}' [394 bytes] </code></pre> <p>The following setting in VSCode didn't make a difference:</p> <p>&quot;editor.stopRenderingLineAfter&quot; : -1</p> <p>Update:</p> <p>I wanted to find out if Python's logging was reformating the string. The function in Python's websockets that generated the truncated line was located:</p> <pre><code>def write_frame_sync(self, fin: bool, opcode: int, data: bytes) -&gt; None: frame = Frame(fin, Opcode(opcode), data) if self.debug: self.logger.debug(&quot;&gt; %s&quot;, frame) print(frame) # &lt;&lt;&lt; frame.write( self.transport.write, mask=self.is_client, extensions=self.extensions, ) </code></pre> <p>A print() statement was used to print out the 'frame' (notated by &lt;&lt;&lt;).</p> <pre><code>TEXT '{&quot;type&quot;: &quot;subscribe&quot;, &quot;topic&quot;: &quot;/spotMarket/lev...privateChannel&quot;: false}' [1063 bytes] </code></pre> <p>The result looked similarly truncated!</p>
[ { "answer_id": 74162644, "author": "esskayesss", "author_id": 20063482, "author_profile": "https://Stackoverflow.com/users/20063482", "pm_score": 1, "selected": false, "text": "part1story = 'n'\nif ChooseGame == '1':\n part1story = input(\"Do you want to skip the story[y] or [n]\")\n\ni...
2022/10/22
[ "https://Stackoverflow.com/questions/74162616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7087618/" ]
74,162,631
<p>I know that is very simple, but why is the line break not working here and the numbers keep printing in a single line? I want to print 100 random numbers on a line and then again 100 random numbers, but on a new line.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function generateNumber() { const arr = Array(100) for (i = 0; i &lt; arr.length; i++) { setInterval(() =&gt; { let randomNumber = (Math.floor(Math.random() * 10) + 1); document.write(randomNumber + "\n") }, 3000); } } function test() { generateNumber(); } test();</code></pre> </div> </div> </p>
[ { "answer_id": 74162664, "author": "ORGPEV", "author_id": 20085325, "author_profile": "https://Stackoverflow.com/users/20085325", "pm_score": 2, "selected": false, "text": "<br>" }, { "answer_id": 74162767, "author": "Carsten Massmann", "author_id": 2610061, "author_p...
2022/10/22
[ "https://Stackoverflow.com/questions/74162631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20204288/" ]
74,162,668
<p>Is there any way to reduce the time complexity of the factorial function below O(n), and what is the time complexity of its implementation in the math library in python?</p> <p>Also, is any memorization done for some set of inputs (in Python 3), to further reduce its runtime?</p>
[ { "answer_id": 74166723, "author": "Peter de Rivaz", "author_id": 1139393, "author_profile": "https://Stackoverflow.com/users/1139393", "pm_score": 2, "selected": false, "text": "math.lgamma(n+1)" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74162668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13286705/" ]
74,162,694
<p>i have a simple html form, which is working fine in desktop devices but not visible in mobile devices. my code is like below:</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>@import url('https://fonts.googleapis.com/css?family=Muli&amp;display=swap'); @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,500&amp;display=swap'); * { box-sizing: border-box; } body { background-color: #9b59b6; font-family: 'Open Sans', sans-serif; display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; } .container { background-color: #fff; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); overflow: hidden; width: 400px; max-width: 100%; } .header { border-bottom: 1px solid #f0f0f0; background-color: #f7f7f7; padding: 20px 40px; } .header h2 { margin: 0; } .form { padding: 30px 40px; } .form-control { margin-bottom: 10px; padding-bottom: 20px; position: relative; } .form-control label { display: inline-block; margin-bottom: 5px; } .form-control input { border: 2px solid #f0f0f0; border-radius: 4px; display: block; font-family: inherit; font-size: 14px; padding: 10px; width: 100%; } .form-control input:focus { outline: 0; border-color: #777; } .form-control.success input { border-color: #2ecc71; } .form-control.error input { border-color: #e74c3c; } .form-control i { visibility: hidden; position: absolute; top: 40px; right: 10px; } .form-control.success i.fa-check-circle { color: #2ecc71; visibility: visible; } .form-control.error i.fa-exclamation-circle { color: #e74c3c; visibility: visible; } .form-control small { color: #e74c3c; position: absolute; bottom: 0; left: 0; visibility: hidden; } .form-control.error small { visibility: visible; } .form button { background-color: #8e44ad; border: 2px solid #8e44ad; border-radius: 4px; color: #fff; display: block; font-family: inherit; font-size: 16px; padding: 10px; margin-top: 20px; width: 100%; } /* SOCIAL PANEL CSS */ .social-panel-container { position: fixed; right: 0; bottom: 80px; transform: translateX(100%); transition: transform 0.4s ease-in-out; } .social-panel-container.visible { transform: translateX(-10px); } .social-panel { background-color: #fff; border-radius: 16px; box-shadow: 0 16px 31px -17px rgba(0, 31, 97, 0.6); border: 5px solid #001F61; display: flex; flex-direction: column; justify-content: center; align-items: center; font-family: 'Muli'; position: relative; height: 169px; width: 370px; max-width: calc(100% - 10px); } .social-panel button.close-btn { border: 0; color: #97A5CE; cursor: pointer; font-size: 20px; position: absolute; top: 5px; right: 5px; } .social-panel button.close-btn:focus { outline: none; } .social-panel p { background-color: #001F61; border-radius: 0 0 10px 10px; color: #fff; font-size: 14px; line-height: 18px; padding: 2px 17px 6px; position: absolute; top: 0; left: 50%; margin: 0; transform: translateX(-50%); text-align: center; width: 235px; } .social-panel p i { margin: 0 5px; } .social-panel p a { color: #FF7500; text-decoration: none; } .social-panel h4 { margin: 20px 0; color: #97A5CE; font-family: 'Muli'; font-size: 14px; line-height: 18px; text-transform: uppercase; } .social-panel ul { display: flex; list-style-type: none; padding: 0; margin: 0; } .social-panel ul li { margin: 0 10px; } .social-panel ul li a { border: 1px solid #DCE1F2; border-radius: 50%; color: #001F61; font-size: 20px; display: flex; justify-content: center; align-items: center; height: 50px; width: 50px; text-decoration: none; } .social-panel ul li a:hover { border-color: #FF6A00; box-shadow: 0 9px 12px -9px #FF6A00; } .floating-btn { border-radius: 26.5px; background-color: #001F61; border: 1px solid #001F61; box-shadow: 0 16px 22px -17px #03153B; color: #fff; cursor: pointer; font-size: 16px; line-height: 20px; padding: 12px 20px; position: fixed; bottom: 20px; right: 20px; z-index: 999; } .floating-btn:hover { background-color: #ffffff; color: #001F61; } .floating-btn:focus { outline: none; } .floating-text { background-color: #001F61; border-radius: 10px 10px 0 0; color: #fff; font-family: 'Muli'; padding: 7px 15px; position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); text-align: center; z-index: 998; } .floating-text a { color: #FF7500; text-decoration: none; } @media screen and (max-width: 480px) { .social-panel-container.visible { transform: translateX(0px); } .floating-btn { right: 10px; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;div class="header"&gt; &lt;/div&gt; &lt;form id="form" class="form" method="post" action=""&gt; &lt;div class="form-control"&gt; &lt;label for="username"&gt;Full Name&lt;/label&gt; &lt;input type="text" placeholder="Full Name" name="name" id="username" /&gt; &lt;i class="fas fa-check-circle"&gt;&lt;/i&gt; &lt;i class="fas fa-exclamation-circle"&gt;&lt;/i&gt; &lt;small&gt;Error message&lt;/small&gt; &lt;/div&gt; &lt;div class="form-control"&gt; &lt;label for="username"&gt;Email&lt;/label&gt; &lt;input type="email" placeholder="Email" id="email" name="email" /&gt; &lt;i class="fas fa-check-circle"&gt;&lt;/i&gt; &lt;i class="fas fa-exclamation-circle"&gt;&lt;/i&gt; &lt;small&gt;Error message&lt;/small&gt; &lt;/div&gt; &lt;div class="form-control"&gt; &lt;label for="username"&gt;Roll Number&lt;/label&gt; &lt;input type="text" maxlength="10" placeholder="Roll Number" name="rollnumber" id="password" /&gt; &lt;i class="fas fa-check-circle"&gt;&lt;/i&gt; &lt;i class="fas fa-exclamation-circle"&gt;&lt;/i&gt; &lt;small&gt;Error message&lt;/small&gt; &lt;/div&gt; &lt;button type="submit"&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>this is my live url: <a href="https://badrukaonline.com/feepayment/" rel="nofollow noreferrer">enter link description here</a> when i view this in mobile, the form is too small, i have to zoom to see it properly, can anyone please tell me how to make this form fit to screen in all devices, thanks in advance</p>
[ { "answer_id": 74166723, "author": "Peter de Rivaz", "author_id": 1139393, "author_profile": "https://Stackoverflow.com/users/1139393", "pm_score": 2, "selected": false, "text": "math.lgamma(n+1)" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74162694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19215426/" ]
74,162,703
<p>Provide a recursive function that takes a pointer to the middle of an infinite doubly linked list along with an integer key and searches the list for the given key. The list grows infinitely in both directions. Your algorithm should be able to find the key if it is present in the list, otherwise it should continue the search infinitely. This is The question i'm provided with and i can't understand how To recursivly search on both sides. either i'll have to write 2 functions i.e one for searching left other for right side. but can it e searched in one function? this is my code:</p> <pre><code> void searchmiddle(Node&lt;T&gt;* middle, int key,int index) { if (middle == NULL) { return ; } if (head == NULL) { return ; } /* if (middle-&gt;next == head) { return false ; }*/ if (middle-&gt;data == key) { cout &lt;&lt; &quot;key found at index &quot;&lt;&lt;index &lt;&lt; endl; key = 0; return ; } searchmiddle(middle-&gt;prev, key, index - 1); searchmiddle(middle-&gt;next, key, index + 1); } </code></pre> <p>code works for key next to middle pointer..</p>
[ { "answer_id": 74163044, "author": "trincot", "author_id": 5459839, "author_profile": "https://Stackoverflow.com/users/5459839", "pm_score": 0, "selected": false, "text": "prev" }, { "answer_id": 74163051, "author": "Ted Lyngmo", "author_id": 7582247, "author_profile"...
2022/10/22
[ "https://Stackoverflow.com/questions/74162703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307618/" ]
74,162,714
<p>I have the following sequence:</p> <pre><code>s0 &lt;- &quot;KDRH?THLA???RT?HLAK&quot; </code></pre> <p>The wild card character there is indicated by <code>?</code>. What I want to do is to replace that character by sampled character from this vector:</p> <pre><code>AADict &lt;- c(&quot;A&quot;, &quot;R&quot;, &quot;N&quot;, &quot;D&quot;, &quot;C&quot;, &quot;E&quot;, &quot;Q&quot;, &quot;G&quot;, &quot;H&quot;, &quot;I&quot;, &quot;L&quot;, &quot;K&quot;, &quot;M&quot;, &quot;F&quot;, &quot;P&quot;, &quot;S&quot;, &quot;T&quot;, &quot;W&quot;, &quot;Y&quot;, &quot;V&quot;) </code></pre> <p>Since <code>s0</code> has 5 wild cards <code>?</code>, I would sample from AADict:</p> <pre><code>set.seed(1) nof_wildcard &lt;- 5 tolower(sample(AADict, nof_wildcard, TRUE)) </code></pre> <p>Which gives <code>[1] &quot;d&quot; &quot;q&quot; &quot;a&quot; &quot;r&quot; &quot;l&quot;</code></p> <p>Hence the expected result is:</p> <pre><code> KDRH?THLA???RT?HLAK KDRHdTHLAqarRTlHLAK </code></pre> <p>So the placement of the sampled character must be exactly in the same position as <code>?</code>, but the order of the character is not important. e.g. this answer is also acceptable: <code>KDRHqTHLAdlaRTrHLAK</code>.</p> <p>How can I achieve that with R?</p> <p>The other example are:</p> <pre><code>s1 &lt;- &quot;FKDHKHIDVKDRHRTHLAK????RTRHLAK&quot; s2 &lt;- &quot;FKHIDVKDRHRTRHLAK??????????&quot; </code></pre>
[ { "answer_id": 74162784, "author": "jared_mamrot", "author_id": 12957340, "author_profile": "https://Stackoverflow.com/users/12957340", "pm_score": 2, "selected": false, "text": "s0 <- \"KDRH?THLA???RT?HLAK\"\nAADict <- c(\"A\", \"R\", \"N\", \"D\", \"C\", \"E\", \"Q\", \"G\", \"H\", \n ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8391698/" ]
74,162,716
<p>I have an object defined like this. I want to access the role object and push a value into it. I couldn't do it with a map anyway. Any help?</p> <p>Example: That exactly what i want. I want to map and find role and push some items. I filter the object if there is the same element i just change its value</p> <pre><code>interface IInitial { init: string; lang: string; } interface IInitialValues { role: IInitial[]; addPrivs: string; } const [initialValues, setInitialValues] = useState&lt;IInitialValues[]&gt;([]); </code></pre> <pre><code>initialValues.map((item) =&gt; item.role) .push({ init: &quot;test&quot;, lang: &quot;TR&quot;, }) </code></pre> <p>OR</p> <pre><code>initialValues .map((item: any) =&gt; item === name) .filter((item: any) =&gt; { if (item.lang === activeLang) { item.init = value; } }); </code></pre>
[ { "answer_id": 74162885, "author": "Svetoslav Petkov", "author_id": 11612861, "author_profile": "https://Stackoverflow.com/users/11612861", "pm_score": 3, "selected": true, "text": "///Update the state\n\nsetInitialValues(prevValues =>{\n return prevValues.map(item => {\n ///rule to...
2022/10/22
[ "https://Stackoverflow.com/questions/74162716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11582172/" ]
74,162,740
<p>I am given an array of numbers(unsorted):</p> <p>[1,2,1,2,3,1,3,7]</p> <p>My task is to write a method which returns ALL longest ascending sequences of numbers. In this case for given input,the output should be:</p> <p>[[1,2,3],[1,3,7]]</p> <p>I have a problem in appending arrays in resulting list</p> <pre><code>public List&lt;List&lt;Integer&gt;&gt; getAscendingSequences(String url) { List&lt;Integer&gt; numbers = createListFromFile(url); List&lt;List&lt;Integer&gt;&gt; results = new ArrayList&lt;&gt;(); List&lt;Integer&gt; longestArray = new ArrayList&lt;&gt;(); List&lt;Integer&gt; currentArray = new ArrayList&lt;&gt;(); int maxSize = 0; for (int i = 1; i &lt; numbers.size(); i++) { if (currentArray.isEmpty()) { currentArray.add(numbers.get(i - 1)); } if (numbers.get(i) &gt; numbers.get(i - 1)) { currentArray.add(numbers.get(i)); } else { if (longestArray.size() &lt; currentArray.size()) { longestArray.clear(); longestArray.addAll(currentArray); } if(currentArray.size()==longestArray.size()){ results.add(currentArray); } currentArray.clear(); } } results.add(longestArray); return results; } </code></pre> <p>This returns {[1,3,7],[1,3,7],[1,2,3]}</p>
[ { "answer_id": 74163365, "author": "Ankur Saxena", "author_id": 4157304, "author_profile": "https://Stackoverflow.com/users/4157304", "pm_score": 2, "selected": false, "text": "public static List<List<Integer>> getAscendingSequences(String url) {\n List<Integer> numbers = createLi...
2022/10/22
[ "https://Stackoverflow.com/questions/74162740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19660081/" ]
74,162,742
<p>I have two files, A and B with the columns separated by \.<br/> Column <strong>2</strong> of file <strong>A</strong> is exactly the <strong>same</strong> as column <strong>1</strong> of file <strong>B</strong>.<br /> I want to merge these two files keeping file B the same, add a new column based on the same fields between the two files and a partial match between column 1 of file A and column 2 of file B.</p> <p>By partial match I mean something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>File A (column 1)</th> <th>File B (column 2)</th> <th style="text-align: center;">A=B?</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>A?</td> <td style="text-align: center;">True</td> </tr> <tr> <td>A</td> <td>Asd</td> <td style="text-align: center;">True</td> </tr> <tr> <td>B</td> <td>B</td> <td style="text-align: center;">True</td> </tr> <tr> <td>C</td> <td>c</td> <td style="text-align: center;">True</td> </tr> <tr> <td>C</td> <td>CA</td> <td style="text-align: center;">True</td> </tr> <tr> <td>D</td> <td>A</td> <td style="text-align: center;">False</td> </tr> </tbody> </table> </div> <p><strong>If</strong> there are <strong>values</strong> with the <strong>same column 1 and 2 in file A</strong>, they must be <strong>added to file B</strong> separated by <strong>;</strong><br /></p> <p><strong>File A</strong><br /> A\2022.10.10\note a<br /> A\2022.10.10\note b<br /> B\2022.10.14\note c<br /> A\2022.10.14\note d<br /> C\2022.10.15\note e<br /></p> <p><strong>File B</strong><br /> 2022.10.10\A?<br /> 2022.10.14\B?<br /> 2022.10.14\a<br /> 2022.10.15\C<br /> 2022.10.15\D<br /></p> <p><strong>Desired output</strong><br /> 2022.10.10\A?\note a;note b\<br /> 2022.10.14\B?\note c\<br /> 2022.10.14\a\note d\<br /> 2022.10.15\C\note e\<br /> 2022.10.15\D\<br /></p> <p>How can I do this with awk?</p>
[ { "answer_id": 74163365, "author": "Ankur Saxena", "author_id": 4157304, "author_profile": "https://Stackoverflow.com/users/4157304", "pm_score": 2, "selected": false, "text": "public static List<List<Integer>> getAscendingSequences(String url) {\n List<Integer> numbers = createLi...
2022/10/22
[ "https://Stackoverflow.com/questions/74162742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300364/" ]
74,162,743
<p>When you navigate and open the confirmation dialog. When you select Yes, No or Cancel the page that the app was on is dismissed and it takes you back to the form on the previous page.</p> <p>We also found this happens with alerts too.</p> <p>It's a simple enough app structure, top level tabs then a menu which links to sub pages.</p> <p>Here is a quick demo of the bug:</p> <p><img src="https://i.stack.imgur.com/jrNR7.gif" alt="Demo of the bug" /></p> <p>We put together an example app that demonstrates this. How can we prevent this from happening while also maintaining the app structure?</p> <pre><code>import SwiftUI @main struct testApp: App { var body: some Scene { WindowGroup { NavigationView { TabView() { Form { NavigationLink(destination: SubPage()) { Image(systemName: &quot;clock&quot;) Text(&quot;Sub Page&quot;) } // This is where more menu options would be } .tag(1) .tabItem { Image(systemName: &quot;square.grid.2x2&quot;) Text(&quot;Tab 1&quot;) } // This is where more tab pages would be } } } } } struct SubPage: View { @State private var confirmDialogVisible = false var body: some View { VStack { Button{ confirmDialogVisible = true } label: { Text(&quot;popup&quot;) } } .confirmationDialog(&quot;Confirm?&quot;, isPresented: $confirmDialogVisible) { Button(&quot;Yes&quot;) { print(&quot;yes&quot;) } Button(&quot;No&quot;, role: .destructive) { print(&quot;no&quot;) } } } } </code></pre> <p>We are using XCode 14.1 And running on iOS 16.1</p>
[ { "answer_id": 74163592, "author": "lorem ipsum", "author_id": 12738750, "author_profile": "https://Stackoverflow.com/users/12738750", "pm_score": 1, "selected": false, "text": "ViewModifer" }, { "answer_id": 74163605, "author": "Lawrence Gimenez", "author_id": 1075466, ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2420844/" ]
74,162,764
<p>I am trying to create a Spring Batch project. And I am creating the project.</p> <p>However, after purchasing intelllij idea ultimate version, my project started giving errors. I downloaded the &quot;community&quot; version again and my project is working :)</p> <p>So what is the problem?</p> <p>If I want to run my spring batch project with intelllij idea ultimate 2022.2 version. I cannot access any spring batch objects like JobBuilderFactory, StepBuilderFactory, ItemWriter, ItemReader etc.</p> <p>But if I run the same project with the free version &quot;community&quot; there is no error and the project works.</p> <p>I can't help going crazy :)</p> <p><a href="https://i.stack.imgur.com/WyTqC.png" rel="nofollow noreferrer">Could not autowire. No beans of 'JobBuilderFactory' type found</a></p>
[ { "answer_id": 74163592, "author": "lorem ipsum", "author_id": 12738750, "author_profile": "https://Stackoverflow.com/users/12738750", "pm_score": 1, "selected": false, "text": "ViewModifer" }, { "answer_id": 74163605, "author": "Lawrence Gimenez", "author_id": 1075466, ...
2022/10/22
[ "https://Stackoverflow.com/questions/74162764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14538782/" ]
74,162,782
<p>Our professor wants us to perform our previous problem of inverting the result of a pyramid of numbers, given a certain height, but now using for loops. I seem to be doing something wrong with my code.</p> <p>What I have so far:</p> <pre><code>size = int(input(&quot;Height: &quot;)) for num in range(size, 0, -1): for num2 in range(1, num + 1): print(num2, end=&quot; &quot;) </code></pre> <p>Output:</p> <pre><code>12345678 1234567 123456 12345 1234 123 12 1 </code></pre> <p>Desired Output:</p> <pre><code>87654321 7654321 654321 54321 4321 321 21 1 </code></pre> <p>Any help would be appreciated!</p>
[ { "answer_id": 74162849, "author": "Muhammad Akhlaq Mahar", "author_id": 17416783, "author_profile": "https://Stackoverflow.com/users/17416783", "pm_score": 1, "selected": false, "text": "size = int(input(\"Height: \"))\nfor num in range(size, 0, -1):\n for num2 in range(1, num + 1)[::...
2022/10/22
[ "https://Stackoverflow.com/questions/74162782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19984672/" ]
74,162,793
<p>Last week I passed from a Android 10 phone to Android 12. I had some apks decompiled/recompiled with apktool and autosigned with jarsigner, and in Android 10 I could installed them, but in Android 12 it just shows me the apk is invalid when I try to install them at the phone. If I just decompile one and compile again, and then signed it gives me the same error. I also tryed to install it via adb install with the same result. I also get the same doing it with Apk Edit app in the phone, so I asume with Android 12 google restringed the apk installations in the phone, but not for all of them, because I installed some apk that I had for more than 5 years and they were installed fine. Could it be some attribute in the manifest? I will appreciatte some light to the topic. Regards</p>
[ { "answer_id": 74162849, "author": "Muhammad Akhlaq Mahar", "author_id": 17416783, "author_profile": "https://Stackoverflow.com/users/17416783", "pm_score": 1, "selected": false, "text": "size = int(input(\"Height: \"))\nfor num in range(size, 0, -1):\n for num2 in range(1, num + 1)[::...
2022/10/22
[ "https://Stackoverflow.com/questions/74162793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11618095/" ]
74,162,826
<p>I wanted to create a simple timer that gets shown to the screen and was using QTime to track the amount of time passed. However when I create a time with QTime(0, 0, 0) it will always stay at the initial value and will never change.</p> <pre><code>from PyQt5.QtCore import QTime time = QTime(0, 0, 0) print(time.toString(&quot;hh:mm:ss&quot;)) # 00:00:00 time.addSecs(20) print(time.toString(&quot;hh:mm:ss&quot;)) # Still 00:00:00 for some reason </code></pre> <p>Why is the above code not updating the time variable and is there a simple fix for this?</p>
[ { "answer_id": 74162914, "author": "G.M.", "author_id": 6371123, "author_profile": "https://Stackoverflow.com/users/6371123", "pm_score": 1, "selected": false, "text": "QTime QTime::addSecs(int s) const\n" }, { "answer_id": 74162919, "author": "CaptianFluffy100", "author_...
2022/10/22
[ "https://Stackoverflow.com/questions/74162826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14049314/" ]
74,162,839
<p>I have this code for Row Widget here</p> <pre><code>child: Row( children: const [ Expanded( flex: 1, child: Icon( Icons.house, size: 40, ), ), Expanded( flex: 9, child: Text('HELLOHELLO'), ), ], ), </code></pre> <p>This is the result. <a href="https://i.stack.imgur.com/NORgT.png" rel="nofollow noreferrer">Margin on Row</a></p> <p>As you can see on the left side there's a margin that is too big for my preference. Is there a way to adjust it?</p>
[ { "answer_id": 74162914, "author": "G.M.", "author_id": 6371123, "author_profile": "https://Stackoverflow.com/users/6371123", "pm_score": 1, "selected": false, "text": "QTime QTime::addSecs(int s) const\n" }, { "answer_id": 74162919, "author": "CaptianFluffy100", "author_...
2022/10/22
[ "https://Stackoverflow.com/questions/74162839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307720/" ]
74,162,843
<p>I have the following string: <code>[Example] öäüß asdf 1234 (1aö) (not necessary),</code></p> <p>Explanation:</p> <p><code>[Example] </code> optional, not needed</p> <p><code>öäüß asdf 1234</code> the most important part which I need. Every character, number, special character as well as German characters like <code>äÄöÖüÜß</code> can be found here.<br /> A greedy selection might be the best solution to prevent characters like the German ones, right?</p> <p><code> (1aö)</code> optional and needed</p> <p><code>(not necessary)</code> optional, not needed. If it appears it could be <code>(not ...)</code> or <code>(unusual)</code></p> <p><code>,</code> the comma can be optional, too. But is also not needed.</p> <p>I use the following RegEx: <code>/(?:\[.*\]\s)?(?&lt;name&gt;.*?)(?:\s\([not|unusual].*?\))?\,/g</code></p> <p>The problems:</p> <ol> <li><p>when I use the optional parameter <code>?</code> at the comma it splits the whole string into separate characters.</p> </li> <li><p>when I change the non greedy selection in the <code>name</code> group to a greedy one the optional comma is separated. But now the example string starting with <code>ö</code> is selected up to the end.</p> </li> <li><p>the string inside of the first standard brackets <code>()</code> can start with upper or lower case. At this moment I can only recognize upper case.</p> </li> </ol> <p>Here's my attempt at regex101 with a bunch of examples: <a href="https://regex101.com/r/Lx2anw/1" rel="nofollow noreferrer">https://regex101.com/r/Lx2anw/1</a></p> <p>Sorry for the quite specific question, but I'm at the end with my knowledge ...</p> <p>Does anyone have suggestions what I can do here?</p>
[ { "answer_id": 74163034, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 4, "selected": true, "text": "^(?:\\[.*?]\\s)?(?<name>.*?)(?:\\s\\((?:not|unusual)[^()]*\\))?,?\\s*$\n" }, { "answer_id": 74163053...
2022/10/22
[ "https://Stackoverflow.com/questions/74162843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8280574/" ]
74,162,862
<p>I'm trying to modify a histogram like this:</p> <pre><code>library(tidyverse) iris %&gt;% ggplot(aes(x=Sepal.Length))+ geom_histogram(bins=10, fill=&quot;white&quot;, color=&quot;black&quot;, size=1)+ labs(x=&quot;Sepal Length&quot;, y=&quot;Count&quot;, title = &quot;Sepal Length Histogram&quot;)+ theme_classic()+ theme(plot.title = element_text(face=&quot;bold&quot;))+ scale_x_continuous(expand = c(0.01,0.01))+ scale_y_continuous(expand = c(0.00,0.01)) </code></pre> <p>Which looks like the following plot:</p> <p><a href="https://i.stack.imgur.com/hCx1K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hCx1K.png" alt="enter image description here" /></a></p> <p>I would like to know if there is a way to weight the size of the x and y axis lines like so to make them thicker:</p> <p><a href="https://i.stack.imgur.com/PtrAS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PtrAS.png" alt="enter image description here" /></a></p> <p>I tried this:</p> <pre><code>iris %&gt;% ggplot(aes(x=Sepal.Length))+ geom_histogram(bins=10, fill=&quot;white&quot;, color=&quot;black&quot;, size=1)+ labs(x=&quot;Sepal Length&quot;, y=&quot;Count&quot;, title = &quot;Sepal Length Histogram&quot;)+ theme_classic()+ theme(plot.title = element_text(face=&quot;bold&quot;), panel.border = element_rect(linetype = &quot;solid&quot;, colour = &quot;black&quot;, size=5))+ scale_x_continuous(expand = c(0.01,0.01))+ scale_y_continuous(expand = c(0.00,0.01)) </code></pre> <p>But that basically erased my plot:</p> <p><a href="https://i.stack.imgur.com/3v1uT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3v1uT.png" alt="enter image description here" /></a></p> <p>I've also tried manually drawing them with <code>geom_vline</code> and <code>geom_hline</code> but this is time-consuming and causes other issues with the aesthetics. Any ideas would be appreciated.</p>
[ { "answer_id": 74162920, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 3, "selected": true, "text": "lineend" }, { "answer_id": 74162922, "author": "TarJae", "author_id": 13321647, "author_profile"...
2022/10/22
[ "https://Stackoverflow.com/questions/74162862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16631565/" ]
74,162,909
<p><a href="https://i.stack.imgur.com/KKwfF.png" rel="nofollow noreferrer">Html code</a></p> <p>How can i select all of titleline href's with using BeatifulSoup ?</p>
[ { "answer_id": 74162920, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 3, "selected": true, "text": "lineend" }, { "answer_id": 74162922, "author": "TarJae", "author_id": 13321647, "author_profile"...
2022/10/22
[ "https://Stackoverflow.com/questions/74162909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307796/" ]
74,163,014
<p>I have a dataframe and there are 2 columns [&quot;country&quot;] and [&quot;city&quot;] which basically informs of the country and their cities.</p> <p>I need to create a dict using dict comprehensions, to get as a key, the country and as values, a list of the city/cities (some of them only have one city, others many).</p> <p>I'm able to define the keys and create a list but all the cities existing appears a values, I am not able to create the condition that the country of the value should be the key:</p> <pre><code>Dic = {k: list(megacities[&quot;city&quot;]) for k,f in megacities.groupby('country')} for k in Dic: print(&quot;{}:{}\n&quot;.format(k, Dic[k])) </code></pre> <p>Part of the output that I receive is:</p> <pre><code> Argentina:['Tokyo', 'Jakarta', 'Delhi', 'Manila', 'São Paulo', 'Seoul', 'Mumbai', 'Shanghai', 'Mexico City', 'Guangzhou', 'Cairo', 'Beijing', 'New York', 'Kolkāta', 'Moscow', 'Bangkok', 'Dhaka', 'Buenos Aires', 'Ōsaka', 'Lagos', 'Istanbul', 'Karachi', 'Kinshasa', 'Shenzhen', 'Bangalore', 'Ho Chi Minh City', 'Tehran', 'Los Angeles', 'Rio de Janeiro', 'Chengdu', 'Baoding', 'Chennai', 'Lahore', 'London', 'Paris', 'Tianjin', 'Linyi', 'Shijiazhuang', 'Zhengzhou', 'Nanyang'] Bangladesh:['Tokyo', 'Jakarta', 'Delhi', 'Manila', 'São Paulo', 'Seoul', 'Mumbai', 'Shanghai', 'Mexico City', 'Guangzhou', 'Cairo', 'Beijing', 'New York', 'Kolkāta', 'Moscow', 'Bangkok', 'Dhaka', 'Buenos Aires', 'Ōsaka', 'Lagos', 'Istanbul', 'Karachi', 'Kinshasa', 'Shenzhen', 'Bangalore', 'Ho Chi Minh City', 'Tehran', 'Los Angeles', 'Rio de Janeiro', 'Chengdu', 'Baoding', 'Chennai', 'Lahore', 'London', 'Paris', 'Tianjin', 'Linyi', 'Shijiazhuang', 'Zhengzhou', 'Nanyang'] Brazil:['Tokyo', 'Jakarta', 'Delhi', 'Manila', 'São Paulo', 'Seoul', 'Mumbai', 'Shanghai', 'Mexico City', 'Guangzhou', 'Cairo', 'Beijing', 'New York', 'Kolkāta', 'Moscow', 'Bangkok', 'Dhaka', 'Buenos Aires', 'Ōsaka', 'Lagos', 'Istanbul', 'Karachi', 'Kinshasa', 'Shenzhen', 'Bangalore', 'Ho Chi Minh City', 'Tehran', 'Los Angeles', 'Rio de Janeiro', 'Chengdu', 'Baoding', 'Chennai', 'Lahore', 'London', 'Paris', 'Tianjin', 'Linyi', 'Shijiazhuang', 'Zhengzhou', 'Nanyang'] </code></pre> <p>So basically the expect output would be:</p> <pre><code>Argentina:['Buenos Aires'] Bangladesh:['Dhaka'] Brazil:['São Paulo', 'Rio de Janeiro'] </code></pre> <p>How can I should proceed in terms of syntaxis to stablish that condition for the value in the dict comprehension?</p> <p>Lastly, the dataframe:</p> <pre><code>city city_ascii lat lng country iso2 iso3 admin_name capital population id 0 Tokyo Tokyo 35.6839 139.7744 Japan JP JPN Tōkyō primary 39105000 1392685764 1 Jakarta Jakarta -6.2146 106.8451 Indonesia ID IDN Jakarta primary 35362000 1360771077 2 Delhi Delhi 28.6667 77.2167 India IN IND Delhi admin 31870000 1356872604 3 Manila Manila 14.6000 120.9833 Philippines PH PHL Manila primary 23971000 1608618140 4 São Paulo Sao Paulo -23.5504 -46.6339 Brazil BR BRA São Paulo admin 22495000 1076532519 5 Seoul Seoul 37.5600 126.9900 South Korea KR KOR Seoul primary 22394000 1410836482 6 Mumbai Mumbai 19.0758 72.8775 India IN IND Mahārāshtra admin 22186000 1356226629 7 Shanghai Shanghai 31.1667 121.4667 China CN CHN Shanghai admin 22118000 1156073548 8 Mexico City Mexico City 19.4333 -99.1333 Mexico MX MEX Ciudad de México primary 21505000 1484247881 9 Guangzhou Guangzhou 23.1288 113.2590 China CN CHN Guangdong admin 21489000 1156237133 10 Cairo Cairo 30.0444 31.2358 Egypt EG EGY Al Qāhirah primary 19787000 1818253931 11 Beijing Beijing 39.9040 116.4075 China CN CHN Beijing primary 19437000 1156228865 12 New York New York 40.6943 -73.9249 United States US USA New York NaN 18713220 1840034016 13 Kolkāta Kolkata 22.5727 88.3639 India IN IND West Bengal admin 18698000 1356060520 14 Moscow Moscow 55.7558 37.6178 Russia RU RUS Moskva primary 17693000 1643318494 15 Bangkok Bangkok 13.7500 100.5167 Thailand TH THA Krung Thep Maha Nakhon primary 17573000 1764068610 16 Dhaka Dhaka 23.7289 90.3944 Bangladesh BD BGD Dhaka primary 16839000 1050529279 17 Buenos Aires Buenos Aires -34.5997 -58.3819 Argentina AR ARG Buenos Aires, Ciudad Autónoma de primary 16216000 1032717330 18 Ōsaka Osaka 34.7520 135.4582 Japan JP JPN Ōsaka admin 15490000 1392419823 19 Lagos Lagos 6.4500 3.4000 Nigeria NG NGA Lagos minor 15487000 1566593751 20 Istanbul Istanbul 41.0100 28.9603 Turkey TR TUR İstanbul admin 15311000 1792756324 21 Karachi Karachi 24.8600 67.0100 Pakistan PK PAK Sindh admin 15292000 1586129469 22 Kinshasa Kinshasa -4.3317 15.3139 Congo (Kinshasa) CD COD Kinshasa primary 15056000 1180000363 23 Shenzhen Shenzhen 22.5350 114.0540 China CN CHN Guangdong minor 14678000 1156158707 24 Bangalore Bangalore 12.9791 77.5913 India IN IND Karnātaka admin 13999000 1356410365 25 Ho Chi Minh City Ho Chi Minh City 10.8167 106.6333 Vietnam VN VNM Hồ Chí Minh admin 13954000 1704774326 26 Tehran Tehran 35.7000 51.4167 Iran IR IRN Tehrān primary 13819000 1364305026 27 Los Angeles Los Angeles 34.1139 -118.4068 United States US USA California NaN 12750807 1840020491 28 Rio de Janeiro Rio de Janeiro -22.9083 -43.1964 Brazil BR BRA Rio de Janeiro admin 12486000 1076887657 29 Chengdu Chengdu 30.6600 104.0633 China CN CHN Sichuan admin 11920000 1156421555 30 Baoding Baoding 38.8671 115.4845 China CN CHN Hebei NaN 11860000 1156256829 31 Chennai Chennai 13.0825 80.2750 India IN IND Tamil Nādu admin 11564000 1356374944 32 Lahore Lahore 31.5497 74.3436 Pakistan PK PAK Punjab admin 11148000 1586801463 33 London London 51.5072 -0.1275 United Kingdom GB GBR London, City of primary 11120000 1826645935 34 Paris Paris 48.8566 2.3522 France FR FRA Île-de-France primary 11027000 1250015082 35 Tianjin Tianjin 39.1467 117.2056 China CN CHN Tianjin admin 10932000 1156174046 36 Linyi Linyi 35.0606 118.3425 China CN CHN Shandong NaN 10820000 1156086320 37 Shijiazhuang Shijiazhuang 38.0422 114.5086 China CN CHN Hebei admin 10784600 1156217541 38 Zhengzhou Zhengzhou 34.7492 113.6605 China CN CHN Henan admin 10136000 1156183137 39 Nanyang Nanyang 32.9987 112.5292 China CN CHN Henan NaN 10013600 1156192287 </code></pre> <p>Many thanks!</p>
[ { "answer_id": 74162920, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 3, "selected": true, "text": "lineend" }, { "answer_id": 74162922, "author": "TarJae", "author_id": 13321647, "author_profile"...
2022/10/22
[ "https://Stackoverflow.com/questions/74163014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19220073/" ]
74,163,069
<p>I am currently trying to read a BMP file and write it back out, and when I try and read the headers, it always ends up giving me a segfault. I have tried multiple different solutions from stack as well as other places and now am completely stuck.</p> <p>Here's the BMPImage.h file:</p> <pre><code>#pragma once #include &lt;vector&gt; #include &lt;cstdint&gt; #include &lt;string&gt; #include &quot;../fileHeaders/BMPHeaders.hpp&quot; #ifndef BMPIMAGE_H #define BMPIMAGE_H namespace mediaObjs { class BMPIMAGE { public: //Constructors BMPIMAGE(std::string filename); BMPIMAGE(std::string filename, BMPFILEHEADER fileHeader, BMPINFOHEADER infoHeader, RGBQUAD colourTable, std::vector&lt;uint8_t&gt; pixel_data); //IO methods void loadFile(); void writeFile(); //Getters std::string getFilename(); BMPFILEHEADER getFileHeader(); BMPINFOHEADER getInfoHeader(); RGBQUAD getColourTable(); std::vector&lt;uint8_t&gt; getPixelData(); //Setters/Modifiers std::vector&lt;uint8_t&gt;* modifyPixelData(); private: std::string m_filename; BMPFILEHEADER m_fileHeader; BMPINFOHEADER m_infoHeader; RGBQUAD m_colourTable; std::vector&lt;uint8_t&gt; m_pixel_data; }; } #endif </code></pre> <p>Here's the BMPImage.cpp file:</p> <pre><code>#include &quot;./BMPImage.h&quot; #include &lt;fstream&gt; #include &lt;algorithm&gt; using namespace mediaObjs; BMPIMAGE::BMPIMAGE(std::string filename) : m_filename {filename} {} BMPIMAGE::BMPIMAGE(std::string filename, BMPFILEHEADER fileHeader, BMPINFOHEADER infoHeader, RGBQUAD colourTable, std::vector&lt;uint8_t&gt; pixel_data) : m_filename {filename}, m_fileHeader {fileHeader}, m_infoHeader {infoHeader}, m_colourTable {colourTable}, m_pixel_data {pixel_data} {} void BMPIMAGE::loadFile() { std::ifstream file(this-&gt;m_filename, std::ios::in | std::ios::binary); //Read the file headers. BMPFILEHEADER fileHeader __attribute__((unused)); file.read(reinterpret_cast&lt;char*&gt; (fileHeader.bfType), sizeof(uint16_t)); file.read(reinterpret_cast&lt;char*&gt; (fileHeader.bfSize), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (fileHeader.bfReserved1), sizeof(uint16_t)); file.read(reinterpret_cast&lt;char*&gt; (fileHeader.bfReserved2), sizeof(uint16_t)); file.read(reinterpret_cast&lt;char*&gt; (fileHeader.bfOffBits), sizeof(uint32_t)); this-&gt;m_fileHeader = fileHeader; //Read the info headers. BMPINFOHEADER infoHeader __attribute__((unused)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biSize), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biWidth), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biHeight), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biPlanes), sizeof(uint16_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biBitCount), sizeof(uint16_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biCompression), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biSizeImage), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biXPelsPerMetre), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biYPelsPerMetre), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biClrUsed), sizeof(uint32_t)); file.read(reinterpret_cast&lt;char*&gt; (infoHeader.biClrImportant), sizeof(uint32_t)); this-&gt;m_infoHeader = infoHeader; //Read the colour table. RGBQUAD colourTable __attribute__((unused)); file.read(reinterpret_cast&lt;char*&gt; (colourTable.red), sizeof(uint8_t)); file.read(reinterpret_cast&lt;char*&gt; (colourTable.green), sizeof(uint8_t)); file.read(reinterpret_cast&lt;char*&gt; (colourTable.blue), sizeof(uint8_t)); file.read(reinterpret_cast&lt;char*&gt; (colourTable.reserved), sizeof(uint8_t)); this-&gt;m_colourTable = colourTable; //Read the pixel data. std::vector&lt;char&gt; buffer(m_infoHeader.biSizeImage); file.read(buffer.data(), m_infoHeader.biSizeImage); std::copy(std::begin(buffer), std::end(buffer), std::back_inserter(m_pixel_data)); file.close(); } void BMPIMAGE::writeFile() { std::ofstream file(this-&gt;m_filename, std::ios::out | std::ios::binary); //Write the file headers. file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_fileHeader.bfType), sizeof(uint16_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_fileHeader.bfSize), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_fileHeader.bfReserved1), sizeof(uint16_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_fileHeader.bfReserved2), sizeof(uint16_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_fileHeader.bfOffBits), sizeof(uint32_t)); //Write the info headers. file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biSize), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biWidth), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biHeight), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biPlanes), sizeof(uint16_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biBitCount), sizeof(uint16_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biCompression), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biSizeImage), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biXPelsPerMetre), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biYPelsPerMetre), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biClrUsed), sizeof(uint32_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_infoHeader.biClrImportant), sizeof(uint32_t)); //Write the colour table. file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_colourTable.red), sizeof(uint8_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_colourTable.green), sizeof(uint8_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_colourTable.blue), sizeof(uint8_t)); file.write(reinterpret_cast&lt;char*&gt; (this-&gt;m_colourTable.reserved), sizeof(uint8_t)); //Write the pixel data. uint8_t* pixel_data = &amp;(this-&gt;m_pixel_data[0]); file.write(reinterpret_cast&lt;char*&gt; (pixel_data), this-&gt;m_pixel_data.size()); file.close(); } std::string BMPIMAGE::getFilename() { return this-&gt;m_filename; } BMPFILEHEADER BMPIMAGE::getFileHeader() { return this-&gt;m_fileHeader; } BMPINFOHEADER BMPIMAGE::getInfoHeader() { return this-&gt;m_infoHeader; } RGBQUAD BMPIMAGE::getColourTable() { return this-&gt;m_colourTable; } std::vector&lt;uint8_t&gt; BMPIMAGE::getPixelData() { return this-&gt;m_pixel_data; } std::vector&lt;uint8_t&gt;* BMPIMAGE::modifyPixelData() { return &amp;(this-&gt;m_pixel_data); } </code></pre> <p>And this is the BMPHeaders.h file:</p> <pre><code>#pragma once #include &lt;cstdint&gt; #include &lt;fstream&gt; #ifndef BMPHEADERS_H #define BMPHEADERS_H //Defines the BitMap File Header structure. Contains the information about the BitMap file. struct __attribute__((__packed__)) BMPFILEHEADER { uint16_t bfType; uint32_t bfSize; uint16_t bfReserved1; uint16_t bfReserved2; uint32_t bfOffBits; }; //Defines the BitMap Info Header structure. Contains the metadata about the actual BitMap image. struct __attribute__((__packed__)) BMPINFOHEADER { uint32_t biSize; uint32_t biWidth; uint32_t biHeight; uint16_t biPlanes; uint16_t biBitCount; uint32_t biCompression; uint32_t biSizeImage; uint32_t biXPelsPerMetre; uint32_t biYPelsPerMetre; uint32_t biClrUsed; uint32_t biClrImportant; }; //Defines the RGB structure for the BitMap file. struct __attribute__((__packed__)) RGBQUAD { uint8_t red; uint8_t green; uint8_t blue; uint8_t reserved; }; #endif </code></pre> <p>And the valgrind output dump:</p> <pre><code>==1488== Memcheck, a memory error detector ==1488== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==1488== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==1488== Command: ./image-resizer ==1488== ==1488== error calling PR_SET_PTRACER, vgdb might block Starting the deserialisation process. Found the image file. ==1488== Use of uninitialised value of size 8 ==1488== at 0x4994D8E: std::basic_streambuf&lt;char, std::char_traits&lt;char&gt; &gt;::xsgetn(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x495DC84: std::basic_filebuf&lt;char, std::char_traits&lt;char&gt; &gt;::xsgetn(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x496BA81: std::istream::read(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x10AD01: mediaObjs::BMPIMAGE::loadFile() (BMPImage.cpp:26) ==1488== by 0x10A5E6: main (main.cpp:23) ==1488== ==1488== Invalid write of size 1 ==1488== at 0x4994D8E: std::basic_streambuf&lt;char, std::char_traits&lt;char&gt; &gt;::xsgetn(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x495DC84: std::basic_filebuf&lt;char, std::char_traits&lt;char&gt; &gt;::xsgetn(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x496BA81: std::istream::read(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x10AD01: mediaObjs::BMPIMAGE::loadFile() (BMPImage.cpp:26) ==1488== by 0x10A5E6: main (main.cpp:23) ==1488== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==1488== ==1488== ==1488== Process terminating with default action of signal 11 (SIGSEGV) ==1488== Access not within mapped region at address 0x0 ==1488== at 0x4994D8E: std::basic_streambuf&lt;char, std::char_traits&lt;char&gt; &gt;::xsgetn(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x495DC84: std::basic_filebuf&lt;char, std::char_traits&lt;char&gt; &gt;::xsgetn(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x496BA81: std::istream::read(char*, long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28) ==1488== by 0x10AD01: mediaObjs::BMPIMAGE::loadFile() (BMPImage.cpp:26) ==1488== by 0x10A5E6: main (main.cpp:23) ==1488== If you believe this happened as a result of a stack ==1488== overflow in your program's main thread (unlikely but ==1488== possible), you can try to increase the size of the ==1488== main thread stack using the --main-stacksize= flag. ==1488== The main thread stack size used in this run was 8388608. ==1488== ==1488== HEAP SUMMARY: ==1488== in use at exit: 8,705 bytes in 3 blocks ==1488== total heap usage: 6 allocs, 3 frees, 85,546 bytes allocated ==1488== ==1488== LEAK SUMMARY: ==1488== definitely lost: 0 bytes in 0 blocks ==1488== indirectly lost: 0 bytes in 0 blocks ==1488== possibly lost: 0 bytes in 0 blocks ==1488== still reachable: 8,705 bytes in 3 blocks ==1488== suppressed: 0 bytes in 0 blocks ==1488== Reachable blocks (those to which a pointer was found) are not shown. ==1488== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==1488== ==1488== Use --track-origins=yes to see where uninitialised values come from ==1488== For lists of detected and suppressed errors, rerun with: -s ==1488== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) [1] 1488 segmentation fault (core dumped) valgrind --leak-check=full ./image-resizer </code></pre> <p>Some help, or even a pointer in the right direction would really be appreciated.</p> <p><strong>EDIT</strong>: I have updated the code in accordance with @PaulMckenzie 's answer.</p>
[ { "answer_id": 74162920, "author": "stefan", "author_id": 12993861, "author_profile": "https://Stackoverflow.com/users/12993861", "pm_score": 3, "selected": true, "text": "lineend" }, { "answer_id": 74162922, "author": "TarJae", "author_id": 13321647, "author_profile"...
2022/10/22
[ "https://Stackoverflow.com/questions/74163069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307880/" ]
74,163,075
<p>I am developing a simple tool for <strong>create local user accounts</strong> on windows and add them to administrator group or guest group.</p> <p>I just need to know that how to enable the <strong>&quot;User Must Change The Password At Next Logon&quot;</strong> option when creating a new <strong>local user account</strong>. I am using c# , windows form application to write my script. I have used below code to create the user account and set password to Pass@123 and need to enable <strong>&quot;User Must Change The Password At Next Logon&quot;</strong> option.</p> <p>I have tried to use <code>NewUser.Properties[&quot;pwdLastSet&quot;].Value = 0;</code> but this did not worked, threw an exception since this is used for ActiveDirectory.</p> <p>Can someone assist me regarding this?</p> <pre><code>try { DirectoryEntry AD = new DirectoryEntry(&quot;WinNT://&quot; + Environment.MachineName + &quot;,computer&quot;); DirectoryEntry NewUser = AD.Children.Add(UserID, &quot;user&quot;); NewUser.Invoke(&quot;SetPassword&quot;, new object[] { &quot;Pass@123&quot; }); NewUser.Invoke(&quot;Put&quot;, new object[] { &quot;Description&quot;, &quot;A user account managed by system&quot;}); NewUser.Invoke(&quot;Put&quot;, new object[] { &quot;FullName&quot;, &quot;Work From Home: &quot; + UserID }); NewUser.CommitChanges(); DirectoryEntry grp; grp = AD.Children.Find(AccountType, &quot;group&quot;); if (grp != null) { grp.Invoke(&quot;Add&quot;, new object[] { NewUser.Path.ToString() }); } MessageBox.Show(&quot;Account Created Successfully&quot;,&quot;Successfull&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, &quot;Error&quot;, MessageBoxButtons.OK, MessageBoxIcon.Error); } </code></pre>
[ { "answer_id": 74163382, "author": "Erik Wiström", "author_id": 20307906, "author_profile": "https://Stackoverflow.com/users/20307906", "pm_score": 0, "selected": false, "text": "NewUser.Properties[\"pwdLastSet\"][0] = 0;" }, { "answer_id": 74169258, "author": "Kanishka Kular...
2022/10/22
[ "https://Stackoverflow.com/questions/74163075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20306498/" ]
74,163,098
<p>I have a large text file on the web that I am using requests to obtain and parse data from. The text file begins each line with a format like [Mon Oct 10 08:58:26 2022]. How can I get the latest 7 days or convert only the datetime to an object or string for storing and parsing later? I simply want to extract the timestamps from the log and print them</p>
[ { "answer_id": 74163382, "author": "Erik Wiström", "author_id": 20307906, "author_profile": "https://Stackoverflow.com/users/20307906", "pm_score": 0, "selected": false, "text": "NewUser.Properties[\"pwdLastSet\"][0] = 0;" }, { "answer_id": 74169258, "author": "Kanishka Kular...
2022/10/22
[ "https://Stackoverflow.com/questions/74163098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10244666/" ]
74,163,103
<p>I have given a date range as input ie a start date and an end date, I need to construct an array that contains the week No and the week start date, and the week end date as output.</p> <p>Input:</p> <pre><code>startDate = &quot;2022-10-21&quot; endDate = &quot;2022-12-05&quot; </code></pre> <p>Output:</p> <pre><code>result = [{ weekNo: &quot;Oct 2022 - Week 4&quot;, weekStartDate: &quot;2022-10-21&quot;, weekEndDate: &quot;2022-10-23&quot; }, { weekNo: &quot;Oct 2022 - Week 5&quot;, weekStartDate: &quot;2022-10-24&quot;, weekEndDate: &quot;2022-10-30&quot; }, { weekNo: &quot;Oct 2022 - Week 6&quot;, weekStartDate: &quot;2022-10-31&quot;, weekEndDate: &quot;2022-10-31&quot; }, { weekNo: &quot;Nov 2022 - Week 1&quot;, weekStartDate: &quot;2022-11-01&quot;, weekEndDate: &quot;2022-11-06&quot; }, { weekNo: &quot;Nov 2022 - Week 2&quot;, weekStartDate: &quot;2022-11-07&quot;, weekEndDate: &quot;2022-11-13&quot; }, { weekNo: &quot;Nov 2022 - Week 3&quot;, weekStartDate: &quot;2022-11-14&quot;, weekEndDate: &quot;2022-11-20&quot; }, { weekNo: &quot;Nov 2022 - Week 4&quot;, weekStartDate: &quot;2022-11-21&quot;, weekEndDate: &quot;2022-11-27&quot; }, { weekNo: &quot;Nov 2022 - Week 5&quot;, weekStartDate: &quot;2022-11-28&quot;, weekEndDate: &quot;2022-11-30&quot; }, { weekNo: &quot;Dec 2022 - Week 1&quot;, weekStartDate: &quot;2022-12-01&quot;, weekEndDate: &quot;2022-12-04&quot; }, { weekNo: &quot;Dec 2022 - Week 2&quot;, weekStartDate: &quot;2022-12-05&quot;, weekEndDate: &quot;2022-12-05&quot; }]; </code></pre> <p>Based on the start date and end date I need to construct a monthly calendar week no, monthly calendar start date and end date.</p> <p>My Code:</p> <pre><code>constructWeekDataForCustomDates(startDate, endDate) { let currentDay = moment(startDate).day(), addDays, weekArrayData = []; if (currentDay == 0) { addDays = 1; } else if (currentDay == 1) { addDays = 0; } else if (currentDay == 2) { addDays = 6; } else if (currentDay == 3) { addDays = 5; } else if (currentDay == 4) { addDays = 4; } else if (currentDay == 5) { addDays = 3; } else if (currentDay == 6) { addDays = 2; } while(startDate &lt;= endDate){ weekArrayData.push({ checkboxName: this.getweekNoOfMonth(startDate), checkboxStartValue: moment(startDate).format(&quot;YYYY-MM-DD&quot;), checkboxEndValue: moment(startDate).add(addDays, 'day').format(&quot;YYYY-MM-DD&quot;) }); startDate = moment(startDate).add(addDays, 'day').format(&quot;YYYY-MM-DD&quot;); addDays = 6; } console.log(weekArrayData) } // Function To get week no based on the date getweekNoOfMonth (date) { let input = moment(date) const firstDayOfMonth = input.clone().startOf('month'); const firstDayOfWeek = firstDayOfMonth.clone().startOf('week'); const offset = firstDayOfMonth.diff(firstDayOfWeek, 'days'); return Math.ceil((input.date() + offset) / 7); } </code></pre> <p>In my code I am getting wrong output.</p>
[ { "answer_id": 74164673, "author": "IT goldman", "author_id": 3807365, "author_profile": "https://Stackoverflow.com/users/3807365", "pm_score": 2, "selected": true, "text": "var startDate = \"2022-10-21\"\nvar endDate = \"2022-12-05\"\n\nvar result = getAllWeeks(startDate, endDate);\ncon...
2022/10/22
[ "https://Stackoverflow.com/questions/74163103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11753691/" ]
74,163,106
<p>I'm getting tripped up by this error all the time. I've applied nz to all possible calculations that could have this as a result, forcing a 1 in case of an error, but it doesn't help. What am I missing please? Is there a more elegant /standard way in Pinescript to avoid these errors during the first x bars?</p> <pre><code>//@version=5 indicator(&quot;Pullback&quot;, overlay = true) ema = nz(ta.ema(close, 21),1) plotcolor = color.white message = &quot;&quot; wehavealow = false var pullback1 = false var pullback2 = false var feshort = false var seshort = false downtrendstart = nz(ta.crossunder(high, ema),1) downtrend = high &lt; ema uptrend = low &gt; ema var int count = na if downtrend count := 0 else count += 1 downduration = nz(ta.barssince(downtrendstart),1) lowerlow = low &lt; nz(ta.lowest(low,downduration),1.0) brokelower = low &lt; low[1] pullback = low &gt; low[1] if lowerlow pullback1 := false pullback2 := false feshort := false seshort := false if downtrend and not lowerlow if pullback2 and brokelower seshort := true message := &quot;2es&quot; if pullback1 and feshort and pullback pullback2 := true message := &quot;pb2&quot; if pullback1 and brokelower feshort := true message := &quot;1es&quot; if pullback and not pullback2 pullback1 := true message := &quot;pb1&quot; //Plot if downtrend plotcolor :=color.red if uptrend plotcolor := color.green plot(ema, color=plotcolor) if downtrend downlabel = label.new(bar_index, low, message, yloc=yloc.belowbar, style=label.style_label_up) </code></pre>
[ { "answer_id": 74164673, "author": "IT goldman", "author_id": 3807365, "author_profile": "https://Stackoverflow.com/users/3807365", "pm_score": 2, "selected": true, "text": "var startDate = \"2022-10-21\"\nvar endDate = \"2022-12-05\"\n\nvar result = getAllWeeks(startDate, endDate);\ncon...
2022/10/22
[ "https://Stackoverflow.com/questions/74163106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6761052/" ]
74,163,124
<p>how can I address the candles AFTER the candle I have found a condition in. for example i have identified a doji candle as dojicandle =math.abs( (open-low) ) &gt;= math.abs(dojimultiplier*(close - open))</p> <p>for previous candles we have open[1] but for afterward candles I couldn't find anything. I wanna find out whether the next candle is a bullish one or not</p>
[ { "answer_id": 74164673, "author": "IT goldman", "author_id": 3807365, "author_profile": "https://Stackoverflow.com/users/3807365", "pm_score": 2, "selected": true, "text": "var startDate = \"2022-10-21\"\nvar endDate = \"2022-12-05\"\n\nvar result = getAllWeeks(startDate, endDate);\ncon...
2022/10/22
[ "https://Stackoverflow.com/questions/74163124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307974/" ]
74,163,130
<p>In rust I sometimes need to write chained if-else statements. They are not the nicest way to manage multiple conditionals with multiple things to check in the conditions.</p> <p>Here is an artificial <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2021&amp;gist=b2fb839b82824fccaa57de3ee65d20c1" rel="nofollow noreferrer">rust-playgroung example</a> of what I mean and in the following code you can see the if-else chain in question.</p> <pre class="lang-rust prettyprint-override"><code>// see playground for rest of the code fn check_thing(t: Thing) -&gt; CarryRule { let allowed = vec![&quot;birds&quot;,&quot;dogs&quot;,&quot;cats&quot;,&quot;elefants&quot;,&quot;unknown&quot;,&quot;veggies&quot;,&quot;meat&quot;]; let max_carry_size = 30; let max_carry_unknown_size = 3; let max_carry_dog_size = 5; let typ = &amp;t.typ.as_str(); if t.size &gt; max_carry_size { CarryRule::Forbidden } else if ! allowed.contains(typ) { CarryRule::Forbidden } else if t.typ == &quot;unknown&quot; &amp;&amp; t.size &gt; max_carry_unknown_size { CarryRule::Forbidden } else if t.typ == &quot;dogs&quot; &amp;&amp; t.size &gt; max_carry_dog_size { CarryRule::Forbidden } else if t.typ == &quot;birds&quot; { CarryRule::UseCage } else { CarryRule::UseBox } } </code></pre> <p>I know, I should use a <code>match</code> statement, but I do not see how I can do all of the checks above using a single match block. I would need to</p> <ul> <li>match the <code>t.typ</code></li> <li>check if the <code>t.size</code> is greater than some value</li> <li>call the <code>allowed.contains(typ)</code> function</li> </ul> <p>I am looking for Rust version of Go's non-parametrized switch-case such as the following.</p> <pre class="lang-golang prettyprint-override"><code>switch { case a &amp;&amp; b: return 1 case c || d: fallthrough case e || f: return 2 default: return 0 } </code></pre> <p>Of course, I could also refactor the whole example, modelling <code>t.size</code>, <code>t.typ</code>, and the <code>allowed</code> list in a more consistent way that allows nicer <code>match</code> blocks. But sometimes these types are outside of my control and I do not want to wrap the given types in too much extra wrapping.</p> <p>What are good readable alternatives to such if-else chains with complex conditions in Rust?</p>
[ { "answer_id": 74163315, "author": "tadman", "author_id": 87189, "author_profile": "https://Stackoverflow.com/users/87189", "pm_score": 2, "selected": false, "text": "enum" }, { "answer_id": 74169552, "author": "Chayim Friedman", "author_id": 7884305, "author_profile"...
2022/10/22
[ "https://Stackoverflow.com/questions/74163130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8986/" ]
74,163,169
<p>I have a sparse symmetric matrix which represents authors of some book. Elements Ai,j and Aj,i are both equal to one if the people associated with indices i and j are coauthors and equal to zero otherwise. I'm trying to find a way in matrix representation such that given two columns (authors), I find their common co-authors. Preferably in Matlab or Julia code representation.</p>
[ { "answer_id": 74163363, "author": "Sundar R", "author_id": 8127, "author_profile": "https://Stackoverflow.com/users/8127", "pm_score": 2, "selected": false, "text": "&" }, { "answer_id": 74175845, "author": "Dan Getz", "author_id": 3580870, "author_profile": "https:/...
2022/10/22
[ "https://Stackoverflow.com/questions/74163169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17034335/" ]
74,163,175
<pre><code>def find_corr (data,x,y): corr=data.groupby(by=['x','y']).size() corr=corr.reset_index().rename(columns={0:'count'}).sort_values('count', ascending=False)[:10] plot=sns.barplot(data=corr,'count',y=y,hue=x,orient= 'h') plt.title(f'Correlation between {y} and {x}'.title(), fontsize = 14, weight = &quot;bold&quot;) plt.xlabel(x.title(), fontsize = 10, weight=&quot;bold&quot;) plt.ylabel(y.title(), fontsize = 10, weight=&quot;bold&quot;) </code></pre> <p>This function when used brings a KeyError: 'x'</p>
[ { "answer_id": 74163363, "author": "Sundar R", "author_id": 8127, "author_profile": "https://Stackoverflow.com/users/8127", "pm_score": 2, "selected": false, "text": "&" }, { "answer_id": 74175845, "author": "Dan Getz", "author_id": 3580870, "author_profile": "https:/...
2022/10/22
[ "https://Stackoverflow.com/questions/74163175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20165661/" ]
74,163,179
<p>I have this string</p> <pre><code>&quot;C:\Users\testinguser\OneDrive - Company\Desktop\Hello\Jobs\Testing-Online\_vti_history\101376\Shared Documents\Global PKI\Legacy Stuff\Vehicle Credential Trackers\Tracker_JLN_records_USE.xlsx&quot; </code></pre> <p>I'm just wondering how can I split from \_ and get the result only like this</p> <pre><code>vti_history\101376\Shared Documents\Global JLN\Legacy Stuff\Vehicle Credential Trackers\Tracker_JLN_records_USE.xlsx </code></pre> <p>I've try using -split(&quot;\_&quot;) but it didn’t work.</p> <pre><code>$Path = &quot;C:\Users\testinguser\OneDrive - Company\Desktop\Hello\Jobs\Testing-Online\_vti_history\101376\Shared Documents\Global JLN\Legacy Stuff\Vehicle Credential Trackers\Tracker_JLN_records_USE.xlsx&quot; $Result = $Path -split('\_')[2] </code></pre> <p>any help or suggestion would be really appreciated.</p>
[ { "answer_id": 74163341, "author": "Saddam Hussain I H", "author_id": 15961789, "author_profile": "https://Stackoverflow.com/users/15961789", "pm_score": 3, "selected": true, "text": "$myString = \"C:\\Users\\testinguser\\OneDrive - Company\\Desktop\\Hello\\Jobs\\Testing-Online\\_vti_his...
2022/10/22
[ "https://Stackoverflow.com/questions/74163179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18434231/" ]
74,163,201
<p>I want a constant <code>requestAnimationFrame</code> frame rate. So we have this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var stop = false; var frameCount = 0; var fps, fpsInterval, startTime, now, then, elapsed; startAnimating(30); function startAnimating(fps) { fpsInterval = 1000 / fps; then = window.performance.now(); startTime = then; console.log(startTime); animate(); } function animate(newtime) { // stop if (stop) { return; } // request another frame requestAnimationFrame(animate); // calc elapsed time since last loop now = newtime; elapsed = now - then; // if enough time has elapsed, draw the next frame if (elapsed &gt; fpsInterval) { // Get ready for next frame by setting then=now, but... // Also, adjust for fpsInterval not being multiple of 16.67 then = now - (elapsed % fpsInterval); // draw stuff here // TESTING...Report #seconds since start and achieved fps. var sinceStart = now - startTime; var currentFps = Math.round(1000 / (sinceStart / ++frameCount) * 100) / 100; console.log(currentFps + " fps."); } }</code></pre> </div> </div> </p> <p>But the issue is if you loss your focus on the page and minimize your browser wait seconds <strong>and come back to the window again</strong> the frame rate drops suddenly. But we want a constant frame rate right?</p> <p>How do you fix this?</p>
[ { "answer_id": 74163344, "author": "Kaiido", "author_id": 3702797, "author_profile": "https://Stackoverflow.com/users/3702797", "pm_score": 1, "selected": false, "text": "requestAnimationFrame" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74163201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10715551/" ]
74,163,261
<p>I'm trying to rewrite git repository history and apply new <code>pre-commit</code> hook:</p> <ol> <li>Take every commit</li> <li>Apply <code>pre-commit</code> hook</li> <li>Keep the original metadata (author, date, message)</li> <li>Resolve conflicts manually, if any (the hook can alter the commit)</li> <li>Commit to a new repo</li> </ol> <p>The end state is a new repo with a different commit history.</p> <p>What I already found:</p> <ul> <li><code>cherry-pick</code> doesn't run <code>pre-commit</code> hook.</li> <li>I can do</li> </ul> <pre><code>git cherry-pick --no-commit git commit --no-edit </code></pre> <p>But it doesn't preserve the commit date. Also, not sure how to do that for each commit in history (unless I write a e.g. Python script for that).</p> <p>Any ideas on how to do that efficiently?</p>
[ { "answer_id": 74163519, "author": "larsks", "author_id": 147356, "author_profile": "https://Stackoverflow.com/users/147356", "pm_score": 3, "selected": true, "text": "--exec" }, { "answer_id": 74338142, "author": "Dennis Golomazov", "author_id": 304209, "author_profi...
2022/10/22
[ "https://Stackoverflow.com/questions/74163261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/304209/" ]
74,163,267
<p>I am trying to connect to an API, which should be done with cURL.</p> <p>This is what the documentation is telling me to send (with my own data though, this is just and example).</p> <pre><code>curl --request POST \ --url https://api.reepay.com/v1/subscription \ --header 'Accept: application/json' \ -u 'priv_11111111111111111111111111111111:' \ --header 'Content-Type: application/json' \ --data '{&quot;plan&quot;:&quot;plan-AAAAA&quot;, &quot;handle&quot;: &quot;subscription-101&quot;, &quot;create_customer&quot;: { &quot;handle&quot;: &quot;customer-007&quot;, &quot;email&quot;: &quot;joe@example.com&quot; }, &quot;signup_method&quot;:&quot;link&quot;}' </code></pre> <p>What I have tried is this, but I get and error:</p> <pre><code>$postdata = array(); $postdata['plan'] = 'plan-AAAAA'; $postdata['handle'] = 'subscription-101'; $postdata['create_customer'] = [&quot;handle&quot; =&gt; &quot;customer-007&quot;, &quot;email&quot; =&gt; &quot;joe@example.com&quot;]; $postdata['signup_method'] = 'link'; $cc = curl_init(); curl_setopt($cc,CURLOPT_POST,1); curl_setopt($cc,CURLOPT_RETURNTRANSFER,1); curl_setopt($cc,CURLOPT_URL, &quot;https://api.reepay.com/v1/subscription&quot;); curl_setopt($cc,CURLOPT_POSTFIELDS, $postdata); $result = curl_exec($cc); echo $result; </code></pre> <p>This is the error I get: <em>{&quot;error&quot;:&quot;Unsupported Media Type&quot;,&quot;path&quot;:&quot;/v1/subscription&quot;,&quot;timestamp&quot;:&quot;2022-10-22T11:42:11.733+00:00&quot;,&quot;http_status&quot;:415,&quot;http_reason&quot;:&quot;Unsupported Media Type&quot;}</em></p> <p>Can anyone help me make the correct request?</p>
[ { "answer_id": 74163595, "author": "Honk der Hase", "author_id": 2443226, "author_profile": "https://Stackoverflow.com/users/2443226", "pm_score": 3, "selected": true, "text": "$json_data = json_encode($postdata);\ncurl_setopt($cc, CURLOPT_POSTFIELDS, $json_data);\ncurl_setopt($cc, CURLO...
2022/10/22
[ "https://Stackoverflow.com/questions/74163267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9942644/" ]
74,163,301
<p>I have an app that uses a FastAPI backend and a Next.js frontend. In development and on production with stable origins, I am able to use the CORSMiddleware with no issues. However, I have deployed the Next.js frontend with Vercel, and want to take advantage of the automatic Preview deployments that Vercel makes with each git commit to allow for staging-type qualitative testing and sanity checks.</p> <p>I'm running into CORS issues on the Preview deployments: since each Preview deployment uses an auto-generated URL of the pattern: <code>&lt;project-name&gt;-&lt;unique-hash&gt;-&lt;scope-slug&gt;.vercel.app</code>, I can't add them directly to the <strong>allow_origins</strong> argument of the CORSMiddleware. Instead I am trying to add the pattern to the <strong>allow_origin_regex</strong> argument.</p> <p>I am very new to regex, but was able to figure out a pattern that I've tested to work in REPL. However, because I'm having issues, I've switched to use an ultra-permissive regex of '.*' just to get anything to work but that has failed also.</p> <p><em>main.py (relevant portions)</em></p> <pre><code>from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware app = FastAPI() origins = [ &quot;http://localhost&quot;, &quot;http://localhost:8080&quot;, &quot;http://localhost:3000&quot;, &quot;https://my-project-name.vercel.app&quot; ] app.add_middleware( CORSMiddleware, allow_origins=origins, allow_origin_regex=&quot;.*&quot;, allow_credentials=True, allow_methods=[&quot;*&quot;], allow_headers=[&quot;*&quot;], ) </code></pre> <p>I've looked at the FastAPI/Starlette cors.py file to see how it ingests and uses the origin regex and don't see where the problem would be. I've tested the same methods in REPL with no issues. I'm at a loss as to the next avenue to investigate in order to resolve this issue. Any assistance or pointers or &quot;hey dummy you forgot this&quot; comments are welcome.</p>
[ { "answer_id": 74163595, "author": "Honk der Hase", "author_id": 2443226, "author_profile": "https://Stackoverflow.com/users/2443226", "pm_score": 3, "selected": true, "text": "$json_data = json_encode($postdata);\ncurl_setopt($cc, CURLOPT_POSTFIELDS, $json_data);\ncurl_setopt($cc, CURLO...
2022/10/22
[ "https://Stackoverflow.com/questions/74163301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13623184/" ]
74,163,327
<pre><code>import sys as s import datetime class LoginPage: def __int__(self, username, password): self.username = username self.password = password self.incorrectPass = 0 def loginProgrma(self): while True: while True: nameInput = input(&quot;Enter your username: ➸&quot;) if nameInput != self.username: print(&quot;\t(Username is incorrect. Re-enter your username)&quot;) elif nameInput == self.username: print(&quot;\t(Enter your password)&quot;) break while True: passInput = input(&quot;Enter your password: ➳&quot;) if passInput != self.password: self.incorrectPass += 1 print(&quot;\t(Incorrect password. Re-enter your password)&quot;) if self.incorrectPass == 3: s.exit('\nYou have been locked!') elif passInput == self.password: break time = datetime.datetime.now() print('You logged in', time) return f&quot;\n\t(Welcome back {nameInput}.)&quot; </code></pre> <p>So I'm trying to make a short login program where where the program ask to enter the username and password. The problem I don't know how can I run this code, I tried by calling the class LoginPage and the pass 2 arguments(username, password) which is mot working I tried to find the solution on the internet but I couldn't find.</p> <p>And how can I improve this code?.</p>
[ { "answer_id": 74163360, "author": "Thijzert", "author_id": 20307971, "author_profile": "https://Stackoverflow.com/users/20307971", "pm_score": 1, "selected": false, "text": "__int__" }, { "answer_id": 74163370, "author": "moritz", "author_id": 18466656, "author_profi...
2022/10/22
[ "https://Stackoverflow.com/questions/74163327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17451285/" ]
74,163,391
<p>The problem I am having is that using customtkinter the event &lt;ButtonPress-1&gt; doesn't seem to work in customtkinter Frames</p> <p>This can be re-produced with (doesn't work):</p> <pre class="lang-py prettyprint-override"><code>from customtkinter import CTk, CTkFrame root = CTk() root.geometry('300x300') frame = CTkFrame(root) frame.bind('&lt;ButtonPress-1&gt;', lambda _ : print('clicked')) frame.place(x=100, y=100, width=50, height=50) root.mainloop() </code></pre> <p>But this event works</p> <pre class="lang-py prettyprint-override"><code>from customtkinter import CTk, CTkFrame root = CTk() root.geometry('300x300') frame = CTkFrame(root) frame.bind('&lt;Enter&gt;', lambda _ : print('entered')) frame.place(x=100, y=100, width=50, height=50) root.mainloop() </code></pre>
[ { "answer_id": 74163360, "author": "Thijzert", "author_id": 20307971, "author_profile": "https://Stackoverflow.com/users/20307971", "pm_score": 1, "selected": false, "text": "__int__" }, { "answer_id": 74163370, "author": "moritz", "author_id": 18466656, "author_profi...
2022/10/22
[ "https://Stackoverflow.com/questions/74163391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10343079/" ]
74,163,432
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var cat = { name: 'Athena' }; function swap(feline) { feline.name = 'Wild'; feline = { name: 'Tabby' }; } swap(cat); console.log(cat.name);</code></pre> </div> </div> Can Anyone explain why cat.name showing &quot;Wild&quot; because I've again assigned the <code>feline = {name:'Tabby'}</code></p>
[ { "answer_id": 74163360, "author": "Thijzert", "author_id": 20307971, "author_profile": "https://Stackoverflow.com/users/20307971", "pm_score": 1, "selected": false, "text": "__int__" }, { "answer_id": 74163370, "author": "moritz", "author_id": 18466656, "author_profi...
2022/10/22
[ "https://Stackoverflow.com/questions/74163432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12424622/" ]
74,163,443
<p>I am trying to put a black background behind jus the elements of my calculator. I have tried multiple positions, margins, heights, widths...etc to no avail. The closest I can get creates an extended page, but I would like the body to have its own background and the calculator to have a different one—without moving elements.</p> <p>Any help is appreciated.</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>*, *::before, *::after { box-sizing: border-box; font-style: sans-serif; font-weight: normal; } body { padding: 0; margin: 0; background: linear-gradient(to right, #00AAFF, #00FF6C); } .background { background-color: black; z-index:-1; position:relative; } .calculator { display: grid; justify-content: center; align-content: center; min-height: 100vh; grid-template-columns: repeat(4, 100px); grid-template-rows: minmax(120px, auto) repeat(5, 100px); position: relative; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt; &lt;div class="background"&gt; &lt;div class="calculator"&gt; &lt;div class="output"&gt; &lt;div data-previous-operand class="previous-operand"&gt;&lt;/div&gt; &lt;div data-current-operand class="current-operand"&gt;&lt;/div&gt; &lt;/div&gt; &lt;button data-allClear&gt;AC&lt;/button&gt; &lt;button data-switch-signs&gt;+/-&lt;/button&gt; &lt;button data-percentage&gt;%&lt;/button&gt; &lt;button data-operation&gt;÷&lt;/button&gt; &lt;button data-number&gt;7&lt;/button&gt; &lt;button data-number&gt;8&lt;/button&gt; &lt;button data-number&gt;9&lt;/button&gt; &lt;button data-operation&gt;x&lt;/button&gt; &lt;button data-number&gt;4&lt;/button&gt; &lt;button data-number&gt;5&lt;/button&gt; &lt;button data-number&gt;6&lt;/button&gt; &lt;button data-operation&gt;-&lt;/button&gt; &lt;button data-number&gt;1&lt;/button&gt; &lt;button data-number&gt;2&lt;/button&gt; &lt;button data-number&gt;3&lt;/button&gt; &lt;button data-operation&gt;+&lt;/button&gt; &lt;button data-number class="span-two"&gt;0&lt;/button&gt; &lt;button data-number&gt;.&lt;/button&gt; &lt;button data-equals&gt;=&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74163360, "author": "Thijzert", "author_id": 20307971, "author_profile": "https://Stackoverflow.com/users/20307971", "pm_score": 1, "selected": false, "text": "__int__" }, { "answer_id": 74163370, "author": "moritz", "author_id": 18466656, "author_profi...
2022/10/22
[ "https://Stackoverflow.com/questions/74163443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20308155/" ]
74,163,475
<p>I have a class <code>Vehicule</code> and 3 subclasses <code>Voiture</code>, <code>Camion</code> and <code>Moto</code>. I also have a method <code>getVehicules</code> for the all vehicules (i.e. camion, voiture, moto) but I want to print a specific type like Voiture.</p> <p>I don't know how to solve it .</p> <pre><code> List&lt;Vehicule&gt; vehicules = new ArrayList&lt;&gt;(); public void getVehicules() { vehicules.forEach(vehicule-&gt;{ System.out.println(vehicule); }); } public void getVoitures() { Iterator iterator = vehicules.iterator(); while(iterator.hasNext()) { //I want to do a condtion if vehicule is voiture it will disaplay if(vehicules.equals(voiture)) { System.out.println(iterator); } } } </code></pre>
[ { "answer_id": 74163551, "author": "Stephen C", "author_id": 139985, "author_profile": "https://Stackoverflow.com/users/139985", "pm_score": 0, "selected": false, "text": "java.lang.Class" }, { "answer_id": 74163578, "author": "Ankur Saxena", "author_id": 4157304, "au...
2022/10/22
[ "https://Stackoverflow.com/questions/74163475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20196860/" ]
74,163,544
<p>I am trying to understand how the <code>dplyr::rename</code> function works in a for loop work in R. In principle, I want to rename the column names of multiple data frames coming from another list.</p> <p>Here is an example that fails, where I want to rename the first column of each dataset with a name coming from the <code>new.names</code> data set.</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) iris1 &lt;- iris iris2 &lt;- iris iris3 &lt;- iris files &lt;- list(iris1,iris2,iris3) new.names &lt;- c(&quot;change1&quot;,&quot;change2&quot;,&quot;change&quot;) </code></pre> <p>If I try this for loop it fails, any idea why</p> <pre><code>test &lt;- list() for(i in 1:length(files)){ test[[i]] &lt;- files[[i]] |&gt; dplyr::rename(new.names[i]=1) } test </code></pre> <p>Any help or guidance is appreciated</p>
[ { "answer_id": 74163846, "author": "TimTeaFan", "author_id": 9349302, "author_profile": "https://Stackoverflow.com/users/9349302", "pm_score": 3, "selected": true, "text": "!! sym()" }, { "answer_id": 74163890, "author": "noriega", "author_id": 7097072, "author_profil...
2022/10/22
[ "https://Stackoverflow.com/questions/74163544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7179299/" ]
74,163,546
<p>I am learning react and currently using CDNs. I have been trying to import a header component but am unable to do so. I have been trying to see what is wrong in the code but can't find any. I am getting a blank page if I try to import.</p> <p>react1.js</p> <pre><code>import Header from &quot;./Header&quot;; function MainContent(){ return ( &lt;div&gt; &lt;h1&gt;Reasons why I'm excited to learn React&lt;/h1&gt; &lt;ol&gt; &lt;li&gt;By knowing React, my chances of getting hired increases&lt;/li&gt; &lt;li&gt;It is easy to write and understand&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; ); } function Footer(){ return ( &lt;footer className=&quot;Footer&quot;&gt; &lt;small&gt;2022 Naik development. All Rights Reserved.&lt;/small&gt; &lt;/footer&gt; ); } function Page(){ return ( &lt;div&gt; &lt;Header/&gt; &lt;MainContent/&gt; &lt;Footer/&gt; &lt;/div&gt; ); } ReactDOM.render(&lt;Page/&gt;,document.getElementById(&quot;root&quot;)) </code></pre> <p>Header.js</p> <pre><code>export default function Header(){ return( &lt;header&gt; &lt;nav className=&quot;Navbar&quot;&gt; &lt;img src=&quot;./react1-logo.png&quot; className=&quot;nav-logo&quot;&gt;&lt;/img&gt; &lt;ul className=&quot;NavMenu&quot;&gt; &lt;li&gt;Pricing&lt;/li&gt; &lt;li&gt;About&lt;/li&gt; &lt;li&gt;Contact&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;/header&gt; ); } </code></pre>
[ { "answer_id": 74163846, "author": "TimTeaFan", "author_id": 9349302, "author_profile": "https://Stackoverflow.com/users/9349302", "pm_score": 3, "selected": true, "text": "!! sym()" }, { "answer_id": 74163890, "author": "noriega", "author_id": 7097072, "author_profil...
2022/10/22
[ "https://Stackoverflow.com/questions/74163546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20308267/" ]
74,163,582
<p>Having a dataframe like this:</p> <pre><code>df &lt;- data.frame(id = c(1,2), date1 = c(&quot;Nov 2016 &lt;U+2192&gt; Current&quot;, &quot;Nov 2016 &lt;U+2192&gt; Current&quot;), date2 = c(&quot;Nov 2016 &lt;U+2192&gt; Current&quot;, &quot;Nov 2016 &lt;U+2192&gt; Current&quot;)) </code></pre> <p>Is there any command to replace this character in the whole dataframe?</p> <p>Example:</p> <pre><code>df &lt;- gsub(' &lt;U+2192&gt; ', '-', df) </code></pre>
[ { "answer_id": 74163661, "author": "Panagiotis Togias", "author_id": 6181820, "author_profile": "https://Stackoverflow.com/users/6181820", "pm_score": 1, "selected": false, "text": "library(dplyr)\n\ndf %>% mutate(across(everything(), ~ gsub(' <U+2192> ', '-', ., fixed = TRUE)))\n" }, ...
2022/10/22
[ "https://Stackoverflow.com/questions/74163582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20224217/" ]
74,163,596
<p>How do I change data type in a list of nested dictionary?</p> <p>I have tried the following code but I keep receiving a invalid argument.</p> <pre><code>results = json.load(response) for date in results: last_update = datetime.datetime.fromtimestamp(date[0]['lastUpdatedAt']) date[0]['lastUpdatedAt'] = last_update print(results) json document : [{&quot;createdByUser&quot;: {&quot;id&quot;: &quot;15156&quot;, &quot;username&quot;: &quot;kr.esat@.com&quot;, &quot;first&quot;: &quot;&quot;, &quot;last&quot;: &quot;&quot;, &quot;role&quot;: 2, &quot;userType&quot;: &quot;normal&quot;, &quot;hasLoggedIn&quot;: true, &quot;lastLogin&quot;: 16662687523, &quot;visitorIds&quot;: [&quot;k.eat@cds.com&quot;]}, &quot;createdAt&quot;: 15735485109, &quot;lastUpdatedByUser&quot;: {&quot;id&quot;: &quot;62484203008&quot;, &quot;username&quot;: &quot;ipres.com&quot;, &quot;first&quot;: &quot;I&quot;, &quot;last&quot;: &quot;Trs&quot;, &quot;role&quot;: 2, &quot;userType&quot;: &quot;normal&quot;, &quot;deletedAt&quot;: 1651734030, &quot;hasLoggedIn&quot;: true, &quot;lastLogin&quot;: 16197075936, &quot;visitorIds&quot;: [&quot;ipods.com&quot;, &quot;0&quot;]}, &quot;lastUpdatedAt&quot;: 1578265850, &quot;kind&quot;: &quot;Guide&quot;, &quot;rootVersionId&quot;: &quot;-NXd1A-f3Iy6sOuYhycQLs&quot;, &quot;stableVersionId&quot;: &quot;-NXzsod1A-f3IcQLs-2028418&quot;, &quot;appId&quot;: -323232, &quot;appIds&quot;: [-323232], &quot;id&quot;: &quot;-NXzsod13I6ss&quot;, &quot;name&quot;: &quot;Accommodation Types&quot;, &quot;state&quot;: &quot;disabled&quot;, &quot;emailState&quot;: &quot;&quot;, &quot;launchMethod&quot;: &quot;auto&quot;, &quot;isMultiStep&quot;: false, &quot;isTraining&quot;: false]} Here is the error: Traceback (most recent call last): File &quot;&lt;stdin&gt;&quot;, line 2, in &lt;module&gt; KeyError: 0 Expected result: change epoch to date in lastUpdatedAt key [{&quot;createdByUser&quot;: {&quot;id&quot;: &quot;15156&quot;, &quot;username&quot;: &quot;kr.esat@.com&quot;, &quot;first&quot;: &quot;&quot;, &quot;last&quot;: &quot;&quot;, &quot;role&quot;: 2, &quot;userType&quot;: &quot;normal&quot;, &quot;hasLoggedIn&quot;: true, &quot;lastLogin&quot;: 16662687523, &quot;visitorIds&quot;: [&quot;k.eat@cds.com&quot;]}, &quot;createdAt&quot;: 15735485109, &quot;lastUpdatedByUser&quot;: {&quot;id&quot;: &quot;62484203008&quot;, &quot;username&quot;: &quot;ipres.com&quot;, &quot;first&quot;: &quot;I&quot;, &quot;last&quot;: &quot;Trs&quot;, &quot;role&quot;: 2, &quot;userType&quot;: &quot;normal&quot;, &quot;deletedAt&quot;: 1651734030, &quot;hasLoggedIn&quot;: true, &quot;lastLogin&quot;: 16197075936, &quot;visitorIds&quot;: [&quot;ipods.com&quot;, &quot;0&quot;]}, ***&quot;lastUpdatedAt&quot;: 2015-02-02***, &quot;kind&quot;: &quot;Guide&quot;, &quot;rootVersionId&quot;: &quot;-NXd1A-f3Iy6sOuYhycQLs&quot;, &quot;stableVersionId&quot;: &quot;-NXzsod1A-f3IcQLs-2028418&quot;, &quot;appId&quot;: -323232, &quot;appIds&quot;: [-323232], &quot;id&quot;: &quot;-NXzsod13I6ss&quot;, &quot;name&quot;: &quot;Accommodation Types&quot;, &quot;state&quot;: &quot;disabled&quot;, &quot;emailState&quot;: &quot;&quot;, &quot;launchMethod&quot;: &quot;auto&quot;, &quot;isMultiStep&quot;: false, &quot;isTraining&quot;: false]} </code></pre>
[ { "answer_id": 74163661, "author": "Panagiotis Togias", "author_id": 6181820, "author_profile": "https://Stackoverflow.com/users/6181820", "pm_score": 1, "selected": false, "text": "library(dplyr)\n\ndf %>% mutate(across(everything(), ~ gsub(' <U+2192> ', '-', ., fixed = TRUE)))\n" }, ...
2022/10/22
[ "https://Stackoverflow.com/questions/74163596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15152733/" ]
74,163,619
<p>As you can see in the unit test below, I'm basically checking if all properties have default values. Is there a more fluent way in FluentAssertions to do so that I'm not aware of?</p> <p>This test aims to check whether it throws or not when given no additional information.</p> <pre class="lang-cs prettyprint-override"><code>public class OhlcvBuilderTests { // Happy path [Fact] public void Build_ShouldBeConstructed_WhenGivenEmptyInput() { // Arrange var ohlcvBuilder = new OhlcvBuilder(); var expectedOhlcv = new { Date = DateTimeOffset.MinValue, Open = 0, High = 0, Low = 0, Close = 0, Volume = 0 }; // Act var ohlcv = ohlcvBuilder.Build(); // Assert ohlcv.Should().BeEquivalentTo(expectedOhlcv); } } </code></pre>
[ { "answer_id": 74163762, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 1, "selected": false, "text": "var json1 = JsonConvert.SerializeObject(object1);\nvar json2 = JsonConvert.SerializeObject(object2);\n\nAssert.Ar...
2022/10/22
[ "https://Stackoverflow.com/questions/74163619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12090115/" ]
74,163,628
<p>I have been working on a project where I need to apply image masking that applies an effect like this:</p> <p>Pic1: <a href="https://i.stack.imgur.com/6zI2x.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/6zI2x.jpg</a></p> <p>Pic2: <a href="https://i.stack.imgur.com/z7IVX.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/z7IVX.jpg</a></p> <p>Mask frame: <a href="https://i.stack.imgur.com/3syEm.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/3syEm.jpg</a></p> <p>Desired effect: <a href="https://i.stack.imgur.com/t2kO5.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/t2kO5.jpg</a></p> <p>I got it to work by using OpacityMask however to do that I had to use some photoshop and edit my mask frame image. I need to apply this affect to multiple mask frames with different shapes therefore using photoshop to edit all of them seem troublesome. Moreover, the inside of the mask frame images arent all transparent either.</p> <p>Is there any ideas you can give me to solve this issue without using any pre photoshoping each mask frame images. I tried to look into ShaderEffect but I could not really understand how I should use it for my purpose. Moreover I searched for a OpacityMask like effect but working only on part of the mask image which has a specific color/specific shaped area. However, I could not find any.</p>
[ { "answer_id": 74169458, "author": "Stephen Quan", "author_id": 881441, "author_profile": "https://Stackoverflow.com/users/881441", "pm_score": 0, "selected": false, "text": "OpacityMask" }, { "answer_id": 74169760, "author": "SMR", "author_id": 11603485, "author_prof...
2022/10/22
[ "https://Stackoverflow.com/questions/74163628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12355161/" ]
74,163,655
<p>I really don't understand why I am getting an adress location output when creating a Dataframe with groupby for the 'courses'?</p> <p>code:</p> <pre><code>import pandas as pd technologies = ({ 'Courses':[&quot;Spark&quot;,&quot;PySpark&quot;,&quot;Hadoop&quot;,&quot;Python&quot;,&quot;Pandas&quot;,&quot;Hadoop&quot;,&quot;Spark&quot;,&quot;Python&quot;,&quot;NA&quot;], 'Fee' :[22000,25000,23000,24000,26000,25000,25000,22000,1500], 'Duration':['30days','50days','55days','40days','60days','35days','30days','50days','40days'], 'Discount':[1000,2300,1000,1200,2500,None,1400,1600,0] }) df = pd.DataFrame(technologies) print(df) df2 =df.groupby(['Courses']) print(df2) </code></pre> <p>OutPut:</p> <pre><code> Courses Fee Duration Discount 0 Spark 22000 30days 1000.0 1 PySpark 25000 50days 2300.0 2 Hadoop 23000 55days 1000.0 3 Python 24000 40days 1200.0 4 Pandas 26000 60days 2500.0 5 Hadoop 25000 35days NaN 6 Spark 25000 30days 1400.0 7 Python 22000 50days 1600.0 8 NA 1500 40days 0.0 &lt;pandas.core.groupby.generic.DataFrameGroupBy object at 0x00000290E76C40A0&gt; </code></pre>
[ { "answer_id": 74163737, "author": "misterhuge", "author_id": 20216753, "author_profile": "https://Stackoverflow.com/users/20216753", "pm_score": 2, "selected": true, "text": "df.groupby(['Courses']).size()\nCourses\nHadoop 2\nNA 1\nPandas 1\nPySpark 1\nPython 2\nS...
2022/10/22
[ "https://Stackoverflow.com/questions/74163655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15304042/" ]
74,163,663
<p>I use <a href="https://github.com/Kamalifar/BlazorServerCookieAuthentication-master" rel="nofollow noreferrer">this repo</a> to implement authentication and authorization with cookie on the Blazor Server.</p> <p>Suppose that I'd like to retrieve the current logged-in user in the <code>DeleteHotelRoomAsync</code> method in <a href="https://github.com/Kamalifar/BlazorServerCookieAuthentication-master/blob/main/Services/HotelRoomService.cs" rel="nofollow noreferrer">HotelRoomService.cs</a> to log the information of the user who deleted a room.</p> <pre><code>public async Task&lt;int&gt; DeleteHotelRoomAsync(int roomId) { var roomDetails = await _dbContext.HotelRooms.FindAsync(roomId); if (roomDetails == null) { return 0; } _dbContext.HotelRooms.Remove(roomDetails); //ToDo //_dbContext.DbLog.Add(userId,roomId); return await _dbContext.SaveChangesAsync(); } </code></pre> <p>I can't use of AuthenticationStateProvider as it is <a href="https://stackoverflow.com/questions/73973772/get-current-logged-in-user-in-dbcontext">there</a> or <a href="https://stackoverflow.com/questions/67466157/get-the-id-of-the-current-logged-in-user-with-blazor-server">there</a>, becuase of cookie based system and so the AuthenticationStateProvider is null in below code.</p> <p>I used HttpContextAccessor, and I could retrieve the authenticated userId as below, however, I couldn't use HttpContextAccessor because of <a href="https://github.com/dotnet/aspnetcore/issues/17585#issuecomment-561715797" rel="nofollow noreferrer">Microsoft recommendations</a>.</p> <pre><code>public class GetUserId:IGetUserId { public IHttpContextAccessor _contextAccessor; private readonly AuthenticationStateProvider _authenticationStateProvider; public GetUserId(IHttpContextAccessor contextAccessor,AuthenticationStateProvider authenticationStateProvider) { _contextAccessor = contextAccessor; _authenticationStateProvider = authenticationStateProvider; } public string Get() { var userId = _contextAccessor.HttpContext.User.Claims.First().Value; return userId; } } </code></pre> <p>So is there any safe ways to retrieve authenticated user info (e.g. userId) in a .cs file to log it into database logs for user audit log?</p>
[ { "answer_id": 74166322, "author": "Endi", "author_id": 12776971, "author_profile": "https://Stackoverflow.com/users/12776971", "pm_score": -1, "selected": false, "text": "@page \"/deleteRoom/{token}" }, { "answer_id": 74219805, "author": "VahidN", "author_id": 298573, ...
2022/10/22
[ "https://Stackoverflow.com/questions/74163663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4444757/" ]
74,163,672
<p>First, in this C project we have some conditions as far as writing code: I can´t declare a variable and attribute a value to it on the same line of code and we are only allowed to use while loops. Also, I'm using Ubuntu for reference.</p> <p>I want to print the decimal ASCII value, character by character, of a string passed to the program. For e.g. if the input is &quot;rose&quot;, the program correctly prints 114 111 115 101. But when I try to print the decimal value of a char like a 'Ç', the first char of the extended ASCII table, the program weirdly prints -61 -121. Here is the code:</p> <pre><code>int main (int argc, char **argv) { int i; i = 0; if (argc == 2) { while (argv[1][i] != '\0') { printf (&quot;%i &quot;, argv[1][i]); i++; } } } </code></pre> <p>I did some research and found that i should try <strong>unsigned char argv</strong> instead of char, like this:</p> <pre><code>int main (int argc, unsigned char **argv) { int i; i = 0; if (argc == 2) { while (argv[1][i] != '\0') { printf(&quot;%i &quot;, argv[1][i]); i++; } } } </code></pre> <p>In this case, I run the program with a 'Ç' and the output is 195 135 (still wrong).</p> <p>How can I make this program print the right ASCII decimal value of a char from the extended ASSCCI table, in this case a <strong>&quot;Ç&quot; should be a 128.</strong></p> <p>Thank you!!</p>
[ { "answer_id": 74164949, "author": "Steve Summit", "author_id": 3923896, "author_profile": "https://Stackoverflow.com/users/3923896", "pm_score": 1, "selected": false, "text": "Ç" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74163672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20308129/" ]
74,163,675
<h3>Data</h3> <p>Here is the <code>dput</code> for a subset of the data I'm working with:</p> <pre><code>crime_state &lt;- structure(list(State = c(&quot;ALABAMA&quot;, &quot;&quot;, &quot;ARIZONA&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;ARKANSAS&quot;, &quot;CALIFORNIA&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;, &quot;&quot;), City = c(&quot;HUNTSVILLE4&quot;, &quot;TUSCALOOSA&quot;, &quot;CHANDLER&quot;, &quot;GILBERT&quot;, &quot;GLENDALE&quot;, &quot;MESA&quot;, &quot;PEORIA&quot;, &quot;PHOENIX&quot;, &quot;SCOTTSDALE&quot;, &quot;SURPRISE&quot;, &quot;TEMPE&quot;, &quot;TUCSON&quot;, &quot;LITTLE ROCK&quot;, &quot;ANAHEIM&quot;, &quot;ANTIOCH&quot;, &quot;BAKERSFIELD&quot;, &quot;BERKELEY&quot;, &quot;BURBANK&quot;, &quot;CARLSBAD&quot;, &quot;CHULA VISTA&quot;, &quot;CLOVIS&quot;, &quot;CONCORD&quot;, &quot;CORONA&quot;, &quot;COSTA MESA&quot;, &quot;DALY CITY&quot;, &quot;DOWNEY&quot;, &quot;EL CAJON&quot;, &quot;EL MONTE&quot;, &quot;ELK GROVE&quot;, &quot;ESCONDIDO&quot;, &quot;FAIRFIELD&quot;, &quot;FONTANA&quot;, &quot;FREMONT&quot;, &quot;FRESNO&quot;, &quot;FULLERTON&quot;, &quot;GARDEN GROVE&quot;, &quot;GLENDALE&quot;, &quot;HAYWARD&quot;, &quot;HUNTINGTON BEACH&quot;, &quot;INGLEWOOD&quot;, &quot;IRVINE&quot;, &quot;JURUPA VALLEY&quot;, &quot;LANCASTER&quot;, &quot;LONG BEACH&quot;, &quot;LOS ANGELES&quot;, &quot;MODESTO&quot;, &quot;MORENO VALLEY&quot;, &quot;MURRIETA&quot;, &quot;NORWALK&quot;, &quot;OAKLAND&quot;), X = c(2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L, 2018L ), Population1 = c(&quot;196,620&quot;, &quot;101,764&quot;, &quot;255,986&quot;, &quot;247,463&quot;, &quot;249,799&quot;, &quot;504,873&quot;, &quot;170,177&quot;, &quot;1,653,080&quot;, &quot;254,961&quot;, &quot;136,611&quot;, &quot;188,543&quot;, &quot;537,392&quot;, &quot;199,288&quot;, &quot;354,743&quot;, &quot;112,956&quot;, &quot;385,609&quot;, &quot;123,735&quot;, &quot;105,041&quot;, &quot;116,739&quot;, &quot;274,370&quot;, &quot;111,759&quot;, &quot;130,855&quot;, &quot;170,041&quot;, &quot;114,358&quot;, &quot;107,928&quot;, &quot;113,277&quot;, &quot;104,497&quot;, &quot;116,464&quot;, &quot;174,651&quot;, &quot;153,073&quot;, &quot;117,883&quot;, &quot;213,964&quot;, &quot;238,024&quot;, &quot;531,818&quot;, &quot;141,132&quot;, &quot;174,661&quot;, &quot;204,724&quot;, &quot;162,881&quot;, &quot;203,428&quot;, &quot;110,726&quot;, &quot;288,052&quot;, &quot;107,605&quot;, &quot;160,818&quot;, &quot;470,445&quot;, &quot;4,029,741&quot;, &quot;215,822&quot;, &quot;209,145&quot;, &quot;114,706&quot;, &quot;106,158&quot;, &quot;430,230&quot;), Violent..crime = c(&quot;&quot;, &quot;253&quot;, &quot;287&quot;, &quot;132&quot;, &quot;594&quot;, &quot;967&quot;, &quot;201&quot;, &quot;6,118&quot;, &quot;211&quot;, &quot;67&quot;, &quot;448&quot;, &quot;2,027&quot;, &quot;1,336&quot;, &quot;578&quot;, &quot;283&quot;, &quot;911&quot;, &quot;270&quot;, &quot;129&quot;, &quot;115&quot;, &quot;406&quot;, &quot;106&quot;, &quot;246&quot;, &quot;127&quot;, &quot;170&quot;, &quot;113&quot;, &quot;174&quot;, &quot;246&quot;, &quot;181&quot;, &quot;198&quot;, &quot;237&quot;, &quot;335&quot;, &quot;331&quot;, &quot;274&quot;, &quot;1,489&quot;, &quot;174&quot;, &quot;266&quot;, &quot;83&quot;, &quot;330&quot;, &quot;218&quot;, &quot;349&quot;, &quot;82&quot;, &quot;134&quot;, &quot;586&quot;, &quot;1,702&quot;, &quot;14,709&quot;, &quot;963&quot;, &quot;396&quot;, &quot;49&quot;, &quot;219&quot;, &quot;2,675&quot;), Murder = c(NA, 3L, 1L, 1L, 7L, 10L, 2L, 67L, 7L, 3L, 3L, 26L, 19L, 2L, 1L, 18L, 1L, 0L, 1L, 4L, 1L, 1L, 4L, 3L, 2L, 3L, 2L, 2L, 0L, 1L, 2L, 5L, 1L, 18L, 0L, 2L, 0L, 0L, 0L, 7L, 0L, 5L, 4L, 11L, 132L, 8L, 7L, 2L, 5L, 32L), Rape2 = c(&quot;&quot;, &quot;20&quot;, &quot;74&quot;, &quot;49&quot;, &quot;69&quot;, &quot;143&quot;, &quot;33&quot;, &quot;566&quot;, &quot;53&quot;, &quot;10&quot;, &quot;75&quot;, &quot;255&quot;, &quot;121&quot;, &quot;70&quot;, &quot;24&quot;, &quot;60&quot;, &quot;31&quot;, &quot;7&quot;, &quot;19&quot;, &quot;43&quot;, &quot;23&quot;, &quot;27&quot;, &quot;27&quot;, &quot;35&quot;, &quot;18&quot;, &quot;7&quot;, &quot;20&quot;, &quot;12&quot;, &quot;16&quot;, &quot;28&quot;, &quot;53&quot;, &quot;27&quot;, &quot;32&quot;, &quot;93&quot;, &quot;27&quot;, &quot;28&quot;, &quot;16&quot;, &quot;55&quot;, &quot;41&quot;, &quot;27&quot;, &quot;22&quot;, &quot;8&quot;, &quot;49&quot;, &quot;107&quot;, &quot;1,324&quot;, &quot;47&quot;, &quot;17&quot;, &quot;5&quot;, &quot;4&quot;, &quot;214&quot;), Robbery = c(&quot;&quot;, &quot;71&quot;, &quot;62&quot;, &quot;15&quot;, &quot;171&quot;, &quot;192&quot;, &quot;29&quot;, &quot;1,438&quot;, &quot;52&quot;, &quot;20&quot;, &quot;97&quot;, &quot;670&quot;, &quot;150&quot;, &quot;195&quot;, &quot;102&quot;, &quot;402&quot;, &quot;167&quot;, &quot;48&quot;, &quot;23&quot;, &quot;114&quot;, &quot;15&quot;, &quot;103&quot;, &quot;49&quot;, &quot;59&quot;, &quot;45&quot;, &quot;83&quot;, &quot;86&quot;, &quot;78&quot;, &quot;40&quot;, &quot;71&quot;, &quot;89&quot;, &quot;94&quot;, &quot;115&quot;, &quot;473&quot;, &quot;66&quot;, &quot;90&quot;, &quot;24&quot;, &quot;170&quot;, &quot;59&quot;, &quot;156&quot;, &quot;22&quot;, &quot;45&quot;, &quot;142&quot;, &quot;527&quot;, &quot;5,139&quot;, &quot;204&quot;, &quot;141&quot;, &quot;18&quot;, &quot;61&quot;, &quot;1,220&quot;), Aggravated..assault = c(&quot;&quot;, &quot;159&quot;, &quot;150&quot;, &quot;67&quot;, &quot;347&quot;, &quot;622&quot;, &quot;137&quot;, &quot;4,047&quot;, &quot;99&quot;, &quot;34&quot;, &quot;273&quot;, &quot;1,076&quot;, &quot;1,046&quot;, &quot;311&quot;, &quot;156&quot;, &quot;431&quot;, &quot;71&quot;, &quot;74&quot;, &quot;72&quot;, &quot;245&quot;, &quot;67&quot;, &quot;115&quot;, &quot;47&quot;, &quot;73&quot;, &quot;48&quot;, &quot;81&quot;, &quot;138&quot;, &quot;89&quot;, &quot;142&quot;, &quot;137&quot;, &quot;191&quot;, &quot;205&quot;, &quot;126&quot;, &quot;905&quot;, &quot;81&quot;, &quot;146&quot;, &quot;43&quot;, &quot;105&quot;, &quot;118&quot;, &quot;159&quot;, &quot;38&quot;, &quot;76&quot;, &quot;391&quot;, &quot;1,057&quot;, &quot;8,114&quot;, &quot;704&quot;, &quot;231&quot;, &quot;24&quot;, &quot;149&quot;, &quot;1,209&quot;), Property..crime = c(&quot;&quot;, &quot;2,092&quot;, &quot;2,771&quot;, &quot;1,705&quot;, &quot;4,830&quot;, &quot;5,113&quot;, &quot;1,596&quot;, &quot;28,854&quot;, &quot;2,853&quot;, &quot;1,088&quot;, &quot;3,567&quot;, &quot;13,925&quot;, &quot;6,236&quot;, &quot;4,399&quot;, &quot;1,479&quot;, &quot;8,330&quot;, &quot;2,581&quot;, &quot;1,362&quot;, &quot;1,081&quot;, &quot;1,905&quot;, &quot;1,271&quot;, &quot;2,151&quot;, &quot;1,535&quot;, &quot;1,911&quot;, &quot;719&quot;, &quot;1,353&quot;, &quot;1,164&quot;, &quot;1,216&quot;, &quot;1,128&quot;, &quot;1,370&quot;, &quot;1,639&quot;, &quot;1,683&quot;, &quot;2,387&quot;, &quot;8,628&quot;, &quot;1,878&quot;, &quot;2,096&quot;, &quot;1,491&quot;, &quot;2,434&quot;, &quot;1,871&quot;, &quot;1,382&quot;, &quot;1,670&quot;, &quot;1,389&quot;, &quot;1,855&quot;, &quot;5,936&quot;, &quot;50,093&quot;, &quot;3,965&quot;, &quot;2,933&quot;, &quot;661&quot;, &quot;1,057&quot;, &quot;10,677&quot; ), Burglary = c(&quot;&quot;, &quot;414&quot;, &quot;369&quot;, &quot;214&quot;, &quot;756&quot;, &quot;751&quot;, &quot;281&quot;, &quot;5,465&quot;, &quot;350&quot;, &quot;138&quot;, &quot;456&quot;, &quot;1,690&quot;, &quot;1,068&quot;, &quot;733&quot;, &quot;278&quot;, &quot;1,997&quot;, &quot;403&quot;, &quot;141&quot;, &quot;169&quot;, &quot;307&quot;, &quot;160&quot;, &quot;261&quot;, &quot;191&quot;, &quot;265&quot;, &quot;119&quot;, &quot;243&quot;, &quot;166&quot;, &quot;257&quot;, &quot;147&quot;, &quot;187&quot;, &quot;211&quot;, &quot;289&quot;, &quot;404&quot;, &quot;1,411&quot;, &quot;176&quot;, &quot;329&quot;, &quot;188&quot;, &quot;262&quot;, &quot;227&quot;, &quot;221&quot;, &quot;276&quot;, &quot;201&quot;, &quot;512&quot;, &quot;1,077&quot;, &quot;7,869&quot;, &quot;564&quot;, &quot;591&quot;, &quot;128&quot;, &quot;222&quot;, &quot;1,160&quot;), Larceny..theft = c(&quot;&quot;, &quot;1,569&quot;, &quot;2,241&quot;, &quot;1,409&quot;, &quot;3,581&quot;, &quot;3,901&quot;, &quot;1,224&quot;, &quot;19,461&quot;, &quot;2,362&quot;, &quot;860&quot;, &quot;2,841&quot;, &quot;10,959&quot;, &quot;4,643&quot;, &quot;2,969&quot;, &quot;910&quot;, &quot;4,875&quot;, &quot;1,915&quot;, &quot;1,115&quot;, &quot;830&quot;, &quot;1,244&quot;, &quot;1,024&quot;, &quot;1,611&quot;, &quot;1,082&quot;, &quot;1,486&quot;, &quot;517&quot;, &quot;785&quot;, &quot;827&quot;, &quot;677&quot;, &quot;892&quot;, &quot;933&quot;, &quot;1,121&quot;, &quot;928&quot;, &quot;1,620&quot;, &quot;6,126&quot;, &quot;1,460&quot;, &quot;1,438&quot;, &quot;1,156&quot;, &quot;1,468&quot;, &quot;1,485&quot;, &quot;822&quot;, &quot;1,307&quot;, &quot;791&quot;, &quot;981&quot;, &quot;3,688&quot;, &quot;33,364&quot;, &quot;2,819&quot;, &quot;1,828&quot;, &quot;435&quot;, &quot;604&quot;, &quot;7,021&quot;), Motor..vehicle..theft = c(&quot;&quot;, &quot;109&quot;, &quot;161&quot;, &quot;82&quot;, &quot;493&quot;, &quot;461&quot;, &quot;91&quot;, &quot;3,928&quot;, &quot;141&quot;, &quot;90&quot;, &quot;270&quot;, &quot;1,276&quot;, &quot;525&quot;, &quot;697&quot;, &quot;291&quot;, &quot;1,458&quot;, &quot;263&quot;, &quot;106&quot;, &quot;82&quot;, &quot;354&quot;, &quot;87&quot;, &quot;279&quot;, &quot;262&quot;, &quot;160&quot;, &quot;83&quot;, &quot;325&quot;, &quot;171&quot;, &quot;282&quot;, &quot;89&quot;, &quot;250&quot;, &quot;307&quot;, &quot;466&quot;, &quot;363&quot;, &quot;1,091&quot;, &quot;242&quot;, &quot;329&quot;, &quot;147&quot;, &quot;704&quot;, &quot;159&quot;, &quot;339&quot;, &quot;87&quot;, &quot;397&quot;, &quot;362&quot;, &quot;1,171&quot;, &quot;8,860&quot;, &quot;582&quot;, &quot;514&quot;, &quot;98&quot;, &quot;231&quot;, &quot;2,496&quot;), Arson3 = c(NA, NA, 8L, 5L, 34L, 7L, 4L, 140L, 7L, 3L, 3L, 92L, 24L, 13L, 28L, 116L, 21L, 7L, 5L, 9L, 2L, 12L, 10L, 12L, 3L, 8L, 9L, 10L, 6L, 5L, 11L, 5L, 6L, 129L, 8L, 6L, 5L, 9L, 9L, 7L, 2L, 0L, 14L, 57L, 897L, 26L, 5L, 2L, 4L, 106L)), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;), row.names = c(NA, -50L)) </code></pre> <h3>Problem</h3> <p>I have data that looks like this, where each state has multiple counties, and thus the state rows have several empty values:</p> <pre><code># A tibble: 276 × 14 State City X Popul…¹ Viole…² Murder Rape2 Robbery Aggra…³ &lt;chr&gt; &lt;chr&gt; &lt;int&gt; &lt;chr&gt; &lt;chr&gt; &lt;int&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; 1 &quot;ALABAMA&quot; HUNTSVI… 2018 196,620 &quot;&quot; NA &quot;&quot; &quot;&quot; &quot;&quot; 2 &quot;&quot; TUSCALO… 2018 101,764 &quot;253&quot; 3 &quot;20&quot; &quot;71&quot; &quot;159&quot; 3 &quot;ARIZONA&quot; CHANDLER 2018 255,986 &quot;287&quot; 1 &quot;74&quot; &quot;62&quot; &quot;150&quot; 4 &quot;&quot; GILBERT 2018 247,463 &quot;132&quot; 1 &quot;49&quot; &quot;15&quot; &quot;67&quot; 5 &quot;&quot; GLENDALE 2018 249,799 &quot;594&quot; 7 &quot;69&quot; &quot;171&quot; &quot;347&quot; 6 &quot;&quot; MESA 2018 504,873 &quot;967&quot; 10 &quot;143&quot; &quot;192&quot; &quot;622&quot; 7 &quot;&quot; PEORIA 2018 170,177 &quot;201&quot; 2 &quot;33&quot; &quot;29&quot; &quot;137&quot; 8 &quot;&quot; PHOENIX 2018 1,653,… &quot;6,118&quot; 67 &quot;566&quot; &quot;1,438&quot; &quot;4,047&quot; 9 &quot;&quot; SCOTTSD… 2018 254,961 &quot;211&quot; 7 &quot;53&quot; &quot;52&quot; &quot;99&quot; 10 &quot;&quot; SURPRISE 2018 136,611 &quot;67&quot; 3 &quot;10&quot; &quot;20&quot; &quot;34&quot; </code></pre> <p>For this part of the data, Alabama should fill the first two rows, and Arizona should be filling the last 8 rows that are empty. I tried using the methods <a href="https://stackoverflow.com/questions/39348868/fill-empty-cells-from-the-below-row-values-in-r">in this post 6 years ago</a> but using this code (supplying <code>as.character</code> since that is what most of the data is here):</p> <pre><code>library(tidyverse) crime_state %&gt;% mutate_all(as.character) %&gt;% fill(names(.), .direction = &quot;up&quot;) </code></pre> <p>I have no change in the rows I need fixed. Is there a better alternative for my data? This would be the ideal tibble:</p> <pre><code># A tibble: 276 × 14 State City X Popul…¹ Viole…² Murder Rape2 Robbery Aggra…³ &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; 1 &quot;ALABAMA&quot; HUNTSVI… 2018 196,620 &quot;&quot; 3 &quot;&quot; &quot;&quot; &quot;&quot; 2 &quot;ALABAMA&quot; TUSCALO… 2018 101,764 &quot;253&quot; 3 &quot;20&quot; &quot;71&quot; &quot;159&quot; 3 &quot;ARIZONA&quot; CHANDLER 2018 255,986 &quot;287&quot; 1 &quot;74&quot; &quot;62&quot; &quot;150&quot; 4 &quot;ARIZONA&quot; GILBERT 2018 247,463 &quot;132&quot; 1 &quot;49&quot; &quot;15&quot; &quot;67&quot; 5 &quot;ARIZONA&quot; GLENDALE 2018 249,799 &quot;594&quot; 7 &quot;69&quot; &quot;171&quot; &quot;347&quot; 6 &quot;ARIZONA&quot; MESA 2018 504,873 &quot;967&quot; 10 &quot;143&quot; &quot;192&quot; &quot;622&quot; 7 &quot;ARIZONA&quot; PEORIA 2018 170,177 &quot;201&quot; 2 &quot;33&quot; &quot;29&quot; &quot;137&quot; 8 &quot;ARIZONA&quot; PHOENIX 2018 1,653,… &quot;6,118&quot; 67 &quot;566&quot; &quot;1,438&quot; &quot;4,047&quot; 9 &quot;ARIZONA&quot; SCOTTSD… 2018 254,961 &quot;211&quot; 7 &quot;53&quot; &quot;52&quot; &quot;99&quot; 10 &quot;ARIZONA&quot; SURPRISE 2018 136,611 &quot;67&quot; 3 &quot;10&quot; &quot;20&quot; &quot;34&quot; </code></pre>
[ { "answer_id": 74164949, "author": "Steve Summit", "author_id": 3923896, "author_profile": "https://Stackoverflow.com/users/3923896", "pm_score": 1, "selected": false, "text": "Ç" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74163675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16631565/" ]
74,163,682
<p>So, let's say there is a float number: <code>0.11910000</code></p> <p>and here is a list of numbers: <code>11970, 12020, 12070, 12165, 12400, 11100</code></p> <p>I need them to turn to: <code>0.11970, 0.12020, 0.12070, etc...</code> this is based on the the the decimal point in the float number is <code>0.1191</code>, if it were <code>1.191</code> then the numbers would have been <code>1.197, 1.202, 1.207...</code>. There is another point, that the decimal point should be where the number has the closest value to the original float. meaning:</p> <p>if we take <code>9.21</code> as the original float number and have <code>944 968 1032</code> as the number, it should be <code>9.44, 9.68, 10.32</code> instead of <code>9.44, 9.68, 1.032</code>.</p> <p>Now I have made a function after millions of tries, and my brain is so fried at this point the results are not even close. here is my embarrassing function:</p> <pre><code>def calculate_dec_place(num : float, original_num : float) -&gt; float: return num / 10 ** len(str(int(round(num // original_num, -len(str(int(num // original_num))) + 1)))) - 1 </code></pre>
[ { "answer_id": 74163891, "author": "Tom McLean", "author_id": 14720380, "author_profile": "https://Stackoverflow.com/users/14720380", "pm_score": 3, "selected": true, "text": "def find_exponent(n):\n return math.floor(math.log10(abs(n)))\n\nfind_exponent(0.01) -2\nfind_exponent(0.1) ...
2022/10/22
[ "https://Stackoverflow.com/questions/74163682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9836109/" ]
74,163,703
<p>I would like to to route requests based on a path to two different Angular applications. So when i request <a href="http://example.com/admin" rel="nofollow noreferrer">http://example.com/admin</a> is routes to one app <a href="http://example.com/client" rel="nofollow noreferrer">http://example.com/client</a> routes to the second app. I have the following config but all requests are always sent to the nginx default page. Configuration is as follows:</p> <pre><code>server { listen 80 default_server; listen [::]:80 default_server; server_name _; location /admin { root /home/ubuntu/apps/admin/; index index.html; try_files $uri $uri/ /index.html?$args; } location /client { root /home/ubuntu/apps/client; index index.html; try_files $uri $uri/ /index.html?$args; } } </code></pre> <p>No other confs are in <code>/etc/nginx/sites-enabled</code> and nginx.conf is default post install on Ubuntu. Any help is appreciated.</p>
[ { "answer_id": 74165659, "author": "Mensur", "author_id": 1111198, "author_profile": "https://Stackoverflow.com/users/1111198", "pm_score": 0, "selected": false, "text": "root" }, { "answer_id": 74166234, "author": "Richard Smith", "author_id": 4862445, "author_profil...
2022/10/22
[ "https://Stackoverflow.com/questions/74163703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1111198/" ]
74,163,717
<p>How can I rebuild with my &quot;HomeScreen&quot; with setState after I've manipulated some displayed data (in HomeScreen) in a SecondScreen? I'm using Navigator.pop() but it isn't showing the changes.</p> <p>SecondScreen:</p> <pre><code> onPressed: () { setState( () { holidays[widget.index].start = test; }, ); Navigator.pop( context, ); }, </code></pre> <p>On my homescreen I have a list of &quot;holidays&quot;. In the Holiday class I have a button....</p> <pre><code> GestureDetector( onTap: () async { await Navigator.push( context, MaterialPageRoute( builder: (context) =&gt; EditScreen( start: start, end: end, index: index), ), ); }, </code></pre>
[ { "answer_id": 74165659, "author": "Mensur", "author_id": 1111198, "author_profile": "https://Stackoverflow.com/users/1111198", "pm_score": 0, "selected": false, "text": "root" }, { "answer_id": 74166234, "author": "Richard Smith", "author_id": 4862445, "author_profil...
2022/10/22
[ "https://Stackoverflow.com/questions/74163717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6903678/" ]
74,163,738
<p>I have a ListView with a Login. If I get any error, it shows a snackbar. Currently, it is possible to fill out the Form because of the padding, but the Snackbar is hidden behind the keyboard. I want to avoid the Resize because I have a background as an Image, it looks strange when it gets resized. Any ideas how I should tell my ListView that the end of the screen is the top of the keyboard? Code:</p> <pre><code>resizeToAvoidBottomInset: false, body: Stack(children: [ const Background(), ScrollConfiguration( behavior: MyBehavior(), child: ListView( controller: controllerV, scrollDirection: Axis.vertical, physics: isKeyboardVisible? const AlwaysScrollableScrollPhysics(): const NeverScrollableScrollPhysics(), children: [ LoginForm(controllerH: widget.controllerH, controllerV: controllerV,), RegisterForm(controllerV: controllerV,), Padding( // this is new padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom) ), ]), ), ]), </code></pre> <p>or do you have an idea how I can prevent only the Picture from resizing? This would also fix my problem!</p>
[ { "answer_id": 74163806, "author": "Max Luchterhand", "author_id": 11958481, "author_profile": "https://Stackoverflow.com/users/11958481", "pm_score": 2, "selected": true, "text": " Stack(children: [\n const Background(),\n Scaffold(\n body: ScrollConfiguration(\n behav...
2022/10/22
[ "https://Stackoverflow.com/questions/74163738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19913052/" ]
74,163,758
<p>Consider the following example</p> <pre><code>#include &lt;iostream&gt; #include &lt;any&gt; #include &lt;vector&gt; #include &lt;map&gt; #include &lt;typeinfo&gt; typedef enum TYPE{ INT8=0, INT16=1, INT32=2 } TYPE; int main() { std::map&lt;TYPE, std::any&gt; myMap; myMap[TYPE::INT8] = (int8_t)0; myMap[TYPE::INT16] = (int16_t)0; myMap[TYPE::INT32] = (int32_t)0; std::vector&lt;decltype(myMap[TYPE::INT8])&gt; vec; } </code></pre> <p>I have a map in this example, going from some enum to <code>std::any</code>. I actually need a flexible data structure that can map from a specific type (<code>enum TYPE</code> in this case), to multiple data types (different types of <code>int</code>), hence the use of <code>std::any</code>.</p> <p>Going ahead, I would like to ascertain the type of value given for the key and construct a vector with it. I tried the above code, and it runs into a compilation error because <code>decltype</code> will return <code>std::any</code>(correctly so).</p> <p>I would want to extract the &quot;true type&quot; from the <code>std::any</code> and create that type of vector. How would I achieve that.</p> <p>A small snippet of the compilation error is as follows -</p> <pre><code>/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/new_allocator.h:63:26: error: forming pointer to reference type 'std::any&amp;' 63 | typedef _Tp* pointer; /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/new_allocator.h:112:7: error: forming pointer to reference type 'std::any&amp;' 112 | allocate(size_type __n, const void* = static_cast&lt;const void*&gt;(0)) /opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/stl_vector.h:1293:7: error: 'void std::vector&lt;_Tp, _Alloc&gt;::push_back(value_type&amp;&amp;) [with _Tp = std::any&amp;; _Alloc = std::allocator&lt;std::any&amp;&gt;; value_type = std::any&amp;]' cannot be overloaded with 'void std::vector&lt;_Tp, _Alloc&gt;::push_back(const value_type&amp;) [with _Tp = std::any&amp;; _Alloc = std::allocator&lt;std::any&amp;&gt;; value_type = std::any&amp;]' 1293 | push_back(value_type&amp;&amp; __x) </code></pre> <p>TIA</p>
[ { "answer_id": 74163823, "author": "Vivick", "author_id": 7316365, "author_profile": "https://Stackoverflow.com/users/7316365", "pm_score": 1, "selected": false, "text": "enum class TYPE{\n INT8=0,\n INT16=1,\n INT32=2\n};\n" }, { "answer_id": 74164207, "author": "Ho...
2022/10/22
[ "https://Stackoverflow.com/questions/74163758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13594617/" ]
74,163,768
<p>I have data as you can see in the terminal. I need it to be converted to the Excel sheet format as you can see in the Excel sheet file by creating multi-levels in columns.</p> <p>I researched this and reached many different things but cannot achieve my goal then, I reached &quot;transpose&quot;, and it gave me the shape that I need but unfortunately that it did reshape from a column to a row instead where I got the wrong data ordering.</p> <p><strong>Current result:</strong></p> <p><img src="https://i.stack.imgur.com/BN88i.png" alt="enter image description here" /></p> <p><strong>Desired result:</strong></p> <p><img src="https://i.stack.imgur.com/pWUUH.png" alt="enter image description here" /></p> <p>What can I try next?</p>
[ { "answer_id": 74163823, "author": "Vivick", "author_id": 7316365, "author_profile": "https://Stackoverflow.com/users/7316365", "pm_score": 1, "selected": false, "text": "enum class TYPE{\n INT8=0,\n INT16=1,\n INT32=2\n};\n" }, { "answer_id": 74164207, "author": "Ho...
2022/10/22
[ "https://Stackoverflow.com/questions/74163768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12560046/" ]
74,163,783
<p>Let's say I have a couple elements arranged in a column (using flexbox): <a href="https://i.stack.imgur.com/LDOaD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LDOaD.png" alt="elements in a column" /></a></p> <p>And I would like to &quot;spotlight&quot; element #2 in green and set it aside, but let the rest of the elements remain ordered in a column:</p> <p><a href="https://i.stack.imgur.com/lZLbQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lZLbQ.png" alt="a wider layout, with element #2 set aside" /></a></p> <p>Is there a way to do this with just CSS and retain dynamic layout?</p> <p>I've thought of a workaround by duplicating the green element and wrapping all of this in another flexbox layout (<code>[2[1234]]</code>) so that in the column case, the first green element is hidden (<code>[#[1234]</code>) whereas in the wider case, the second element is hidden (<code>[2[1#34]</code>), but this is a bit messy in the markup - and actually causes issues when the element has some kind of state (e.g. a <code>&lt;video&gt;</code>) that is expected to be retained in both cases.</p> <p>I've also thought about using <code>position: absolute</code> on the green element, but I couldn't get that to work nicely either: once I set <code>position: relative</code> on the top-level (black) container, I can position the green element where I want, but setting <code>position: absolute</code> on the column container (red) so that I can position in to the right means green element is now positioned relative to the column container again.</p> <p>Is there a solution I'm overlooking?</p>
[ { "answer_id": 74164160, "author": "Andrei Fedorov", "author_id": 6641198, "author_profile": "https://Stackoverflow.com/users/6641198", "pm_score": 1, "selected": false, "text": "const expand = document.querySelector('.expand');\n\nexpand.addEventListener('click', () => {\n expand.paren...
2022/10/22
[ "https://Stackoverflow.com/questions/74163783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3833159/" ]
74,163,790
<p>I'm trying to implement a checkbox widget that ought to only allow me to pass data to a new screen once I have selected a specific checkbox . whilst i was trying to pass these different values to a new screen i keep on getting the error :</p> <blockquote> <p>The named parameter 'saveCheck' is required, but there's no corresponding argument. Try adding the required argument.</p> </blockquote> <p>below is the snippet of code that displays the checkbox ui:</p> <pre><code>class CheckBoxPage extends ConsumerStatefulWidget { const CheckBoxPage({Key? key}) : super(key: key); static const String route = &quot;/checkbox&quot;; @override ConsumerState&lt;CheckBoxPage&gt; createState() =&gt; _CheckBoxPageState(); } class _CheckBoxPageState extends ConsumerState&lt;CheckBoxPage&gt; { @override Widget build(BuildContext context) { final readAsync = ref.watch(checkRepoProvider); final model = ref.watch(checkboxProvider); bool check1 = false; bool check2 = false; String? saveFirstValue; String? saveSecondValue; return Scaffold( appBar: AppBar( title: const Text(&quot;check&quot;), ), bottomNavigationBar: Padding( padding: const EdgeInsets.fromLTRB(24, 0, 24, 24), child: MaterialButton( padding: const EdgeInsets.all(16), color: Colors.black, onPressed: () { if (saveFirstValue!.isNotEmpty &amp;&amp; saveSecondValue!.isNotEmpty) { String bothValues = &quot;$saveFirstValue $saveSecondValue&quot;; Navigator.push( context, MaterialPageRoute( builder: (context) =&gt; DisplayPage(bothValues: bothValues))); } else { if (saveFirstValue!.isNotEmpty) { String saveCheck = &quot;$saveFirstValue&quot;; Navigator.push( context, MaterialPageRoute( builder: (context) =&gt; DisplayPage( saveCheck: saveCheck, ))); } else if (saveSecondValue!.isNotEmpty) { String saveCheck2 = &quot;$saveSecondValue&quot;; Navigator.push( context, MaterialPageRoute( builder: (context) =&gt; DisplayPage( saveCheck2: saveCheck2, ))); } } }, child: const Text( &quot;Add meal&quot;, style: TextStyle(color: Color.fromARGB(255, 247, 245, 245)), ), ), ), body: readAsync.when( data: (check) =&gt; ListView( children: check .map( (e) =&gt; Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ CheckboxListTile( title: Text(e.checkbox1), controlAffinity: ListTileControlAffinity.leading, value: check1, onChanged: (value) { check1 = value!; saveFirstValue = e.checkbox1; }, contentPadding: EdgeInsets.zero, ), CheckboxListTile( title: Text(e.checkbox2), controlAffinity: ListTileControlAffinity.leading, value: check2, onChanged: (value) { check2 = value!; saveSecondValue = e.checkbox2; }, contentPadding: EdgeInsets.zero, ), ], ), ) .toList()), error: (e, s) =&gt; Center( child: Text(&quot;$e&quot;), ), </code></pre> <p>}</p> <p>below is the screen where i'm trying to display selected values:</p> <pre><code>class DisplayPage extends StatefulWidget { const DisplayPage( {Key? key, required this.saveCheck, required this.saveCheck2, required this.bothValues, }) : super(key: key); final String saveCheck; final String saveCheck2; final String bothValues; static const String route = &quot;/display&quot;; @override State&lt;DisplayPage&gt; createState() =&gt; _DisplayPageState(); } class _DisplayPageState extends State&lt;DisplayPage&gt; { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text(&quot;display&quot;), ), body: Column( children: [Text(widget.saveCheck)], ), ); }} </code></pre>
[ { "answer_id": 74164160, "author": "Andrei Fedorov", "author_id": 6641198, "author_profile": "https://Stackoverflow.com/users/6641198", "pm_score": 1, "selected": false, "text": "const expand = document.querySelector('.expand');\n\nexpand.addEventListener('click', () => {\n expand.paren...
2022/10/22
[ "https://Stackoverflow.com/questions/74163790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18630809/" ]
74,163,800
<p>I have some simple code that randomly changes the background color on the page. Why do I need to use <code>let letters = &quot;0123456789ABCDEF&quot;.split('')</code> in the code?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function changeColor() { document.body.style.backgroundColor = getRandomColor() } function getRandomColor() { let color = "#"; let letters = "0123456789ABCDEF".split(''); for (let i = 0; i &lt; 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } return color; } function test() { changeColor(); setInterval(changeColor, 1000) } test();</code></pre> </div> </div> </p>
[ { "answer_id": 74163848, "author": "Rory McCrossan", "author_id": 519413, "author_profile": "https://Stackoverflow.com/users/519413", "pm_score": 1, "selected": false, "text": "\"0123456789ABCDEF\"" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74163800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20204288/" ]
74,163,831
<p>I'm using Xamarin Forms 5 to build an app that uses the stock flyout menu. When Voiceover is activated, it reads the menu items from the flyout menu when the menu is not showing and the menu items are not selectable. When the menu is showing, Voiceover behaves as expected. How do I prevent VO from &quot;reading&quot; the menu when it isn't in view? Thanks!</p>
[ { "answer_id": 74163848, "author": "Rory McCrossan", "author_id": 519413, "author_profile": "https://Stackoverflow.com/users/519413", "pm_score": 1, "selected": false, "text": "\"0123456789ABCDEF\"" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74163831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/911867/" ]
74,163,834
<p>I can not decide the fastest way to pick the k nearest points to some point P from an n-points set. My guesses are below:</p> <ol> <li>Compute the n-distance, order it and pick the k smallest values;</li> <li>Compute pointwise distance and update a k-sized point stack;</li> </ol> <p>Any other manners are welcome.</p>
[ { "answer_id": 74163848, "author": "Rory McCrossan", "author_id": 519413, "author_profile": "https://Stackoverflow.com/users/519413", "pm_score": 1, "selected": false, "text": "\"0123456789ABCDEF\"" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74163834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19299349/" ]
74,163,850
<p>im looking for the right way to flash multiple *.img files in the same folder without duplicating &quot;fastboot flash xxxxx xxxxx.img&quot; command on all lines I want the output to be like this</p> <pre><code>flash boot... OKAY flash recovery... OKAY flash fastboot... OKAY flash fastboot... FAILED </code></pre> <p>I was using</p> <pre><code>for %%i in (*.img) do fastboot flash %%i %%i do @echo flash %%i ...OKAY </code></pre> <p>but the output is not what i want</p> <pre><code>Start Flashing .... target reported max download size of 805306368 bytes sending 'boot.img' (131072 KB)... OKAY [ 3.751s] target reported max download size of 805306368 bytes sending 'boot_b.img' (131072 KB)... OKAY [ 3.755s] writing 'boot_b.img'... FAILED (remote: (boot_b.img_a) No such partition) ::: fail because partition name contain file extension target reported max download size of 805306368 bytes sending 'frp.img' (512 KB)... OKAY [ 0.023s] writing 'frp.img'... FAILED (remote: (frp.img_a) No such partition) target reported max download size of 805306368 bytes sending 'modem.img' (262144 KB)... OKAY [ 7.520s] writing 'modem.img'... FAILED (remote: (modem.img_a) No such partition) </code></pre> <p>it shows FAILED No such partition in output Because the partition name contain the file extension and It should be &quot;fastboot flash filename filename.img&quot; for works correctly</p> <pre><code>for %%i in (*.img) do fastboot flash %%i %%i do @echo flash %%i ...ok </code></pre> <p>any help or suggestion to fix command ?</p>
[ { "answer_id": 74163848, "author": "Rory McCrossan", "author_id": 519413, "author_profile": "https://Stackoverflow.com/users/519413", "pm_score": 1, "selected": false, "text": "\"0123456789ABCDEF\"" } ]
2022/10/22
[ "https://Stackoverflow.com/questions/74163850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20308372/" ]
74,163,865
<p>I am working on a chat analyzer, and trying to make a pie chart for most active users. Suppose I have the following data.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">Name</th> <th style="text-align: center;">Number of messages</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">A</td> <td style="text-align: center;">234</td> </tr> <tr> <td style="text-align: left;">B</td> <td style="text-align: center;">128</td> </tr> <tr> <td style="text-align: left;">C</td> <td style="text-align: center;">112</td> </tr> <tr> <td style="text-align: left;">D</td> <td style="text-align: center;">97</td> </tr> <tr> <td style="text-align: left;">E</td> <td style="text-align: center;">86</td> </tr> <tr> <td style="text-align: left;">F</td> <td style="text-align: center;">43</td> </tr> <tr> <td style="text-align: left;">G</td> <td style="text-align: center;">32</td> </tr> <tr> <td style="text-align: left;">H</td> <td style="text-align: center;">24</td> </tr> <tr> <td style="text-align: left;">I</td> <td style="text-align: center;">22</td> </tr> <tr> <td style="text-align: left;">J</td> <td style="text-align: center;">9</td> </tr> </tbody> </table> </div> <p>I want to convert it into the following</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">Name</th> <th style="text-align: center;">Number of messages</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">A</td> <td style="text-align: center;">234</td> </tr> <tr> <td style="text-align: left;">B</td> <td style="text-align: center;">128</td> </tr> <tr> <td style="text-align: left;">C</td> <td style="text-align: center;">112</td> </tr> <tr> <td style="text-align: left;">D</td> <td style="text-align: center;">97</td> </tr> <tr> <td style="text-align: left;">E</td> <td style="text-align: center;">86</td> </tr> <tr> <td style="text-align: left;">Other</td> <td style="text-align: center;">130</td> </tr> </tbody> </table> </div> <p>I am using <em>pandas.value_counts()</em> method for getting all the data for the first table, but am not able to use <em>pandas.group_by()</em> to get the second table.</p> <p>Please can anyone help me out?</p>
[ { "answer_id": 74163901, "author": "Code Different", "author_id": 2538939, "author_profile": "https://Stackoverflow.com/users/2538939", "pm_score": 3, "selected": true, "text": "df.where" }, { "answer_id": 74164008, "author": "I'mahdi", "author_id": 1740577, "author_p...
2022/10/22
[ "https://Stackoverflow.com/questions/74163865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13738155/" ]
74,163,883
<p>Was trying to scrape the stock quantities for a product on this link: <a href="https://sizeer.ro/v2/products/searchnearpos?address=44.4199549%2C26.1238619&amp;distance=50&amp;product=3046070" rel="nofollow noreferrer">https://sizeer.ro/v2/products/searchnearpos?address=44.4199549%2C26.1238619&amp;distance=50&amp;product=3046070</a></p> <p>This is the json that gives as response:</p> <pre><code>{&quot;pos&quot;:[{&quot;id&quot;:&quot;1110&quot;,&quot;name&quot;:&quot;BUCURESTI MALL SIZEER&quot;,&quot;code&quot;:&quot;RO31&quot;,&quot;slug&quot;:&quot;bucuresti-mall-sizeer&quot;,&quot;warehouse&quot;:&quot;RO31 - RO31 NEW SIZEER EU - RO&quot;,&quot;warehouse_id&quot;:&quot;1842&quot;,&quot;street&quot;:&quot;Calea Vitan 3rd District&quot;,&quot;house_number&quot;:&quot;55-59&quot;,&quot;apartment_number&quot;:&quot;&quot;,&quot;postcode&quot;:&quot;031282&quot;,&quot;city&quot;:&quot;Bucharest&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0771567291&quot;,&quot;latitude&quot;:&quot;44.4199549&quot;,&quot;longitude&quot;:&quot;26.1238619&quot;,&quot;distance&quot;:&quot;0&quot;,&quot;availability_variants&quot;:[{&quot;offer_id&quot;:943027879,&quot;product_id&quot;:3046070,&quot;size&quot;:&quot;46,5&quot;,&quot;stock&quot;:2,&quot;availability_id&quot;:&quot;43&quot;,&quot;availability_name&quot;:&quot;Disponibil&quot;,&quot;add_to_cart&quot;:true}],&quot;products_availability&quot;:true},{&quot;id&quot;:&quot;703&quot;,&quot;name&quot;:&quot;BUCURE\u0218TI PARKLAKE SIZEER&quot;,&quot;code&quot;:&quot;RO05&quot;,&quot;slug&quot;:&quot;bucuresti-parklake-sizeer&quot;,&quot;warehouse&quot;:&quot;RO05 - NEW SIZEER EU - RO&quot;,&quot;warehouse_id&quot;:&quot;1363&quot;,&quot;street&quot;:&quot;Strada Liviu Rebreanu&quot;,&quot;house_number&quot;:&quot;4&quot;,&quot;apartment_number&quot;:&quot;3 district&quot;,&quot;postcode&quot;:&quot;031783&quot;,&quot;city&quot;:&quot;Bucure\u0219ti&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0770314565&quot;,&quot;latitude&quot;:&quot;44.4206244&quot;,&quot;longitude&quot;:&quot;26.1500617&quot;,&quot;distance&quot;:&quot;2.0820717992071485&quot;,&quot;open_hour&quot;:{&quot;1&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;1&quot;},&quot;2&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;2&quot;},&quot;3&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;3&quot;},&quot;4&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;4&quot;},&quot;5&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;5&quot;},&quot;6&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;6&quot;},&quot;0&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;0&quot;}},&quot;availability_variants&quot;:[{&quot;offer_id&quot;:943076353,&quot;product_id&quot;:3046070,&quot;size&quot;:&quot;46,5&quot;,&quot;stock&quot;:1,&quot;availability_id&quot;:&quot;15&quot;,&quot;availability_name&quot;:&quot;Disponibil&quot;,&quot;add_to_cart&quot;:true}],&quot;products_availability&quot;:true},{&quot;id&quot;:&quot;707&quot;,&quot;name&quot;:&quot;BUCURE\u0218TI SUN PLAZA SIZEER&quot;,&quot;code&quot;:&quot;RO02&quot;,&quot;slug&quot;:&quot;bucuresti-sun-plaza-sizeer&quot;,&quot;warehouse&quot;:&quot;RO02 - NEW SIZEER EU - RO 17B2\/02 (BUKARESZT - )&quot;,&quot;warehouse_id&quot;:&quot;1357&quot;,&quot;street&quot;:&quot;Calea V\u0103c\u0103re\u0219ti&quot;,&quot;house_number&quot;:&quot;391&quot;,&quot;apartment_number&quot;:&quot;4 district&quot;,&quot;postcode&quot;:&quot;040055&quot;,&quot;city&quot;:&quot;Bucure\u0219ti&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0770314860&quot;,&quot;latitude&quot;:&quot;44.3954567&quot;,&quot;longitude&quot;:&quot;26.1234794&quot;,&quot;distance&quot;:&quot;2.7242449964645985&quot;,&quot;open_hour&quot;:{&quot;1&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;1&quot;},&quot;2&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;2&quot;},&quot;3&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;3&quot;},&quot;4&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;4&quot;},&quot;5&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;5&quot;},&quot;6&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;6&quot;},&quot;0&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;0&quot;}},&quot;availability_variants&quot;:[{&quot;offer_id&quot;:943076351,&quot;product_id&quot;:3046070,&quot;size&quot;:&quot;46,5&quot;,&quot;stock&quot;:1,&quot;availability_id&quot;:&quot;15&quot;,&quot;availability_name&quot;:&quot;Disponibil&quot;,&quot;add_to_cart&quot;:true}],&quot;products_availability&quot;:true},{&quot;id&quot;:&quot;705&quot;,&quot;name&quot;:&quot;BUCURE\u0218TI MEGA MALL SIZEER&quot;,&quot;code&quot;:&quot;RO01&quot;,&quot;slug&quot;:&quot;bucuresti-mega-mall-sizeer&quot;,&quot;warehouse&quot;:&quot;RO01 - NEW SIZEER EU - RO 17B2\/01 (BUKARESZT - )&quot;,&quot;warehouse_id&quot;:&quot;1355&quot;,&quot;street&quot;:&quot;Bulevardul Pierre de Coubertin&quot;,&quot;house_number&quot;:&quot;3-5&quot;,&quot;apartment_number&quot;:&quot;2 District&quot;,&quot;postcode&quot;:&quot;021901&quot;,&quot;city&quot;:&quot;Bucure\u0219ti&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0770634923&quot;,&quot;latitude&quot;:&quot;44.4423985&quot;,&quot;longitude&quot;:&quot;26.1525885&quot;,&quot;distance&quot;:&quot;3.380976816641149&quot;,&quot;open_hour&quot;:{&quot;1&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;1&quot;},&quot;2&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;2&quot;},&quot;3&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;3&quot;},&quot;4&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;4&quot;},&quot;5&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;5&quot;},&quot;6&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;6&quot;},&quot;0&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;22:00&quot;,&quot;weekday&quot;:&quot;0&quot;}},&quot;availability_variants&quot;:[],&quot;products_availability&quot;:false},{&quot;id&quot;:&quot;1112&quot;,&quot;name&quot;:&quot;BUCURE\u0218TI IRIS TITAN SIZEER&quot;,&quot;code&quot;:&quot;RO38&quot;,&quot;slug&quot;:&quot;bucuresti-iris-titan-sizeer&quot;,&quot;warehouse&quot;:&quot;RO38 - NEW SIZEER EU - RO&quot;,&quot;warehouse_id&quot;:&quot;2182&quot;,&quot;street&quot;:&quot;Bulevardul1 Decembrie 1918 Sector 3&quot;,&quot;house_number&quot;:&quot;33A&quot;,&quot;apartment_number&quot;:&quot;&quot;,&quot;postcode&quot;:&quot;032455&quot;,&quot;city&quot;:&quot;Bucure\u0219ti&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0770142178&quot;,&quot;latitude&quot;:&quot;44.4226633&quot;,&quot;longitude&quot;:&quot;26.1769066&quot;,&quot;distance&quot;:&quot;4.223391316193692&quot;,&quot;availability_variants&quot;:[{&quot;offer_id&quot;:943076359,&quot;product_id&quot;:3046070,&quot;size&quot;:&quot;46,5&quot;,&quot;stock&quot;:1,&quot;availability_id&quot;:&quot;15&quot;,&quot;availability_name&quot;:&quot;Disponibil&quot;,&quot;add_to_cart&quot;:true}],&quot;products_availability&quot;:true},{&quot;id&quot;:&quot;1142&quot;,&quot;name&quot;:&quot;BUCURE\u0218TI AFI SIZEER&quot;,&quot;code&quot;:&quot;RO39&quot;,&quot;slug&quot;:&quot;bucuresti-afi-sizeer&quot;,&quot;warehouse&quot;:&quot;RO39 - NEW SIZEER EU - RO&quot;,&quot;warehouse_id&quot;:&quot;2226&quot;,&quot;street&quot;:&quot;Blvd General Vasile Milea&quot;,&quot;house_number&quot;:&quot;4&quot;,&quot;apartment_number&quot;:&quot;&quot;,&quot;postcode&quot;:&quot;061344&quot;,&quot;city&quot;:&quot;Bucure\u0219ti&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0770448458&quot;,&quot;latitude&quot;:&quot;44.4292343&quot;,&quot;longitude&quot;:&quot;26.0512946&quot;,&quot;distance&quot;:&quot;5.854383966823716&quot;,&quot;open_hour&quot;:{&quot;1&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;1&quot;},&quot;2&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;2&quot;},&quot;3&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;3&quot;},&quot;4&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;4&quot;},&quot;5&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;5&quot;},&quot;6&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;6&quot;}},&quot;availability_variants&quot;:[],&quot;products_availability&quot;:false},{&quot;id&quot;:&quot;972&quot;,&quot;name&quot;:&quot;BUCURE\u0218TI PROMENADA SIZEER&quot;,&quot;code&quot;:&quot;RO21&quot;,&quot;slug&quot;:&quot;bucuresti-promenada-sizeer&quot;,&quot;warehouse&quot;:&quot;RO21 - NEW SIZEER EU - RO&quot;,&quot;warehouse_id&quot;:&quot;1681&quot;,&quot;street&quot;:&quot;Calea Floreasca&quot;,&quot;house_number&quot;:&quot;246B&quot;,&quot;apartment_number&quot;:&quot;&quot;,&quot;postcode&quot;:&quot;014476&quot;,&quot;city&quot;:&quot;Bucure\u0219ti&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0770922114&quot;,&quot;latitude&quot;:&quot;44.478427&quot;,&quot;longitude&quot;:&quot;26.1013649&quot;,&quot;distance&quot;:&quot;6.742584831194388&quot;,&quot;availability_variants&quot;:[{&quot;offer_id&quot;:943027875,&quot;product_id&quot;:3046070,&quot;size&quot;:&quot;46,5&quot;,&quot;stock&quot;:1,&quot;availability_id&quot;:&quot;15&quot;,&quot;availability_name&quot;:&quot;Disponibil&quot;,&quot;add_to_cart&quot;:true}],&quot;products_availability&quot;:true},{&quot;id&quot;:&quot;1160&quot;,&quot;name&quot;:&quot;BUCURE\u0218TI PALLADY SIZEER OUTLET&quot;,&quot;code&quot;:&quot;RO40&quot;,&quot;type_code&quot;:&quot;outlety&quot;,&quot;slug&quot;:&quot;bucuresti-pallady-sizeer-outlet&quot;,&quot;warehouse&quot;:&quot;RO40 - NEW SIZEER EU - RO&quot;,&quot;warehouse_id&quot;:&quot;2228&quot;,&quot;street&quot;:&quot;Autostrada Soarelui km 15&quot;,&quot;house_number&quot;:&quot;&quot;,&quot;apartment_number&quot;:&quot;&quot;,&quot;postcode&quot;:&quot;917110&quot;,&quot;city&quot;:&quot;Cernica&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0770458228&quot;,&quot;latitude&quot;:&quot;44.4064481&quot;,&quot;longitude&quot;:&quot;26.2741342&quot;,&quot;distance&quot;:&quot;12.029918380409567&quot;,&quot;availability_variants&quot;:[],&quot;products_availability&quot;:false},{&quot;id&quot;:&quot;952&quot;,&quot;name&quot;:&quot;BUCURE\u0218TI FASHION HOUSE SIZEER OUTLET&quot;,&quot;code&quot;:&quot;RO18&quot;,&quot;slug&quot;:&quot;bucuresti-fashion-house-sizeer-outlet&quot;,&quot;warehouse&quot;:&quot;RO18 - NEW SIZEER EU - RO&quot;,&quot;warehouse_id&quot;:&quot;1725&quot;,&quot;street&quot;:&quot;Strada Comertului&quot;,&quot;house_number&quot;:&quot;13A&quot;,&quot;apartment_number&quot;:&quot;&quot;,&quot;postcode&quot;:&quot;077090&quot;,&quot;city&quot;:&quot;Bucure\u0219ti&quot;,&quot;province&quot;:&quot;Bucuresti&quot;,&quot;phone&quot;:&quot;0770591017&quot;,&quot;latitude&quot;:&quot;44.4339543&quot;,&quot;longitude&quot;:&quot;25.9524912&quot;,&quot;distance&quot;:&quot;13.697139076366327&quot;,&quot;open_hour&quot;:{&quot;1&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;1&quot;},&quot;2&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;2&quot;},&quot;3&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;3&quot;},&quot;4&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;4&quot;},&quot;5&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;5&quot;},&quot;6&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;21:00&quot;,&quot;weekday&quot;:&quot;6&quot;},&quot;0&quot;:{&quot;open_hour_from&quot;:&quot;10:00&quot;,&quot;open_hour_to&quot;:&quot;20:00&quot;,&quot;weekday&quot;:&quot;0&quot;}},&quot;availability_variants&quot;:[],&quot;products_availability&quot;:false}]} </code></pre> <p>I've tried to do something like that for storing the stock quantities for each store but it doesn't work</p> <pre><code>for i in responsejs[&quot;pos&quot;][0][&quot;name&quot;]: available_stock.append([&quot;pos&quot;][0][&quot;availability_variants&quot;][0][&quot;stock&quot;]) </code></pre> <p>How can i scrape those multiple values?</p>
[ { "answer_id": 74163901, "author": "Code Different", "author_id": 2538939, "author_profile": "https://Stackoverflow.com/users/2538939", "pm_score": 3, "selected": true, "text": "df.where" }, { "answer_id": 74164008, "author": "I'mahdi", "author_id": 1740577, "author_p...
2022/10/22
[ "https://Stackoverflow.com/questions/74163883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15160663/" ]
74,163,898
<p>The script in the video originally had a plethora of errors, and I've tried my best to fix the code and reduce the errors to as few as possible</p> <p>The errors in my current script are: Assets\PlayerMotor.cs(9,14): error CS1519: Invalid token '=' in class, struct, or interface member declaration</p> <p>Assets\PlayerMotor.cs(9,32): error CS1001: Identifier expected</p> <p>My script is:</p> <pre><code>using UnityEngine; [RequireComponent(typeof(Rigidbody))] public class PlayerMotor : MonoBehaviour { private Vector3 velocity; velocity = new Vector3(zero); private Rigidbody rb; void Start() { rb = GetComponent&lt;Rigidbody&gt;(); } //Gets a movement vector public void Move (Vector3 _velocity) { velocity = _velocity; } //Run every physics iteration void FixedUpdate () { PerformMovement(); } //Perfrom movement based on velocity variable void PerformMovement() { if (velocity != Vector3.zero){ rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime); } } } </code></pre>
[ { "answer_id": 74163988, "author": "Max Play", "author_id": 5593150, "author_profile": "https://Stackoverflow.com/users/5593150", "pm_score": 0, "selected": false, "text": "private Vector3 velocity;\nvelocity = new Vector3(zero);\n" }, { "answer_id": 74164011, "author": "bart...
2022/10/22
[ "https://Stackoverflow.com/questions/74163898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16475546/" ]