qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,197,336
<p>In my Application.cfc, I setup a mapping</p> <pre><code>this.mappings[&quot;/downloads&quot;]=&quot;J:\Downloads\documents&quot;; </code></pre> <p>In my template, I have</p> <pre><code>&lt;cfdirectory action=&quot;list&quot; directory=&quot;#expandpath(&quot;/downloads&quot;)#&quot; filter=&quot;*.zip|*.docx&quot; name=&quot;downloads&quot; recurse=&quot;yes&quot;&gt; &lt;!--- &lt;cfdump var=&quot;#expandpath(&quot;/software&quot;)#&quot;&gt; ---&gt; &lt;cfdump var=&quot;#downloads#&quot;&gt; &lt;ul&gt; &lt;cfoutput query=&quot;#downloads#&quot;&gt; &lt;li&gt;&lt;a href=&quot;#downloads.directory#/#downloads.name#&quot;&gt;#downloads.name#&lt;/a&gt;&lt;/li&gt; &lt;/cfoutput&gt; &lt;/ul&gt; </code></pre> <p>I'm trying to make the documents downloadable but when the link is clicked, nothing is happening which makes me think my links are not correct however when I mouse over the link, I see the full path which is correct.</p> <p>What am I missing to make the list of documents clickable?</p> <p><a href="https://i.stack.imgur.com/36V7D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/36V7D.png" alt="enter image description here" /></a></p> <p>Here is the URL displayed when mouseover the 3rd document for example.</p> <p><a href="https://i.stack.imgur.com/ShQ5G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ShQ5G.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74197558, "author": "etchesketch", "author_id": 4066795, "author_profile": "https://Stackoverflow.com/users/4066795", "pm_score": 3, "selected": true, "text": "<cfheader name=\"Content-disposition\" value=\"attachment;filename=#datafile#\">\n<cfcontent file=\"#datafile#\" ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/483140/" ]
74,197,392
<p>When I go to remove the argument</p> <pre><code>`tryingtoremove` </code></pre> <p>The code breaks.</p> <p>It's not being used anywhere else in the code.</p> <p>How do I remove it without the code breaking?</p> <p>code <a href="https://jsfiddle.net/y78uaqsL/" rel="nofollow noreferrer">https://jsfiddle.net/y78uaqsL/</a></p> <pre><code> function createVideoOptions(tryingtoremove, ids) { const options = createOptions(ids); return options; } </code></pre>
[ { "answer_id": 74197497, "author": "Nelson González Peñate", "author_id": 3029898, "author_profile": "https://Stackoverflow.com/users/3029898", "pm_score": 1, "selected": false, "text": "tryingtoremove" }, { "answer_id": 74197511, "author": "Federico", "author_id": 197434...
2022/10/25
[ "https://Stackoverflow.com/questions/74197392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17631451/" ]
74,197,405
<p>I am trying to implement a function that removes all the occurrences of a given number from a list using in-place. I tried this:</p> <pre><code>def removeElement(L, n): for i in L: if i == n: L.remove(i) return L L = [1,1,2,3,3,3,4,3] n = 3 v = removeElement(L,n) print(v) </code></pre> <p>However it is not removing the last occurrence of '3' here giving [1,1,2,4,3] as output while expected output is [1,1,2,4]. Can someone point the mistake here.</p>
[ { "answer_id": 74197697, "author": "dansh", "author_id": 17709997, "author_profile": "https://Stackoverflow.com/users/17709997", "pm_score": 3, "selected": true, "text": "def remove_elements(num_list, item):\n\n items_count = num_list.count(item)\n for i in range(items_count):\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332331/" ]
74,197,412
<p>I've been trying for some time to get this function to work, but I've tried several ways and I still can't. can anybody help me?</p> <p>My goal is to prevent multiple browsers from being opened, that is, to check if there is already an instance of selenium firefox already open and return it so that the already open window can be used.</p> <p>I tried with webdriver.remote, but no success.</p> <pre><code>from selenium import webdriver from selenium.webdriver.firefox.service import Service from webdriver_manager.firefox import GeckoDriverManager def getDriver(): if isAlreadyRunning() == False: firefox_service = Service(GeckoDriverManager().install()) driver = webdriver.Firefox(service=firefox_service) return driver else: # Get the driver from the previous instance return driver def isAlreadyRunning(): try: # Checks if a previous instance already exists to avoid opening a new browser return True except: print('Driver is not running') return False driver = getDriver() driver.get('https://stackoverflow.com') </code></pre> <p>The last attempts were activating the option marionette.debugging.clicktostart in <code>about:config</code>, opening <code>cmd</code> and starting firefox with the options:</p> <pre><code>cd 'C:\Program Files\Mozilla Firefox\' .\firefox.exe -marionette -start-debugger-server 2828 </code></pre> <p>and the code snippet below:</p> <pre><code>firefox_service = Service(GeckoDriverManager().install(), service_args=['--marionette-port', '2828', '--connect-existing']) driver = webdriver.Firefox(service=firefox_service) </code></pre> <p>But after several seconds, <code>selenium.common.exceptions.TimeoutException</code> error is thrown</p> <p>I'm using:</p> <ul> <li>Python 3.10.4</li> <li>Selenium 4.5.0</li> </ul>
[ { "answer_id": 74197697, "author": "dansh", "author_id": 17709997, "author_profile": "https://Stackoverflow.com/users/17709997", "pm_score": 3, "selected": true, "text": "def remove_elements(num_list, item):\n\n items_count = num_list.count(item)\n for i in range(items_count):\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4594324/" ]
74,197,452
<p>I have a couple MAUI projects that include references to other projects which provide access to an API. The referenced projects generate dll's. When I compile the MAUI app in release mode and target my physical iPhone, the compile fails stating &quot;Asset file '../project.Domain.Shared/obj/project.assets.json' doesn't have a target for 'net6.0-ios'. The referenced project is the .dll generating project that shouldn't (and cannot) contain a net6.0-ios property. This error only occurs if I attach my phone and target it during the compile. I can attach an Android device and compile in release mode without errors and even create an archive. Any help in resolving this issue is appreciated.</p> <p>I tried adding the net6.0-ios property in the project that was referenced in the error, but doing so caused the whole solution to fail to compile. I am using Xcode 14.x and have seen other posts that suggested using version 13.x may resolve the problem. I tried that and still was unable to get the project to compile correctly.</p>
[ { "answer_id": 74197697, "author": "dansh", "author_id": 17709997, "author_profile": "https://Stackoverflow.com/users/17709997", "pm_score": 3, "selected": true, "text": "def remove_elements(num_list, item):\n\n items_count = num_list.count(item)\n for i in range(items_count):\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16528764/" ]
74,197,477
<pre><code>def country(): country_url= 'https://restcountries.com/v3.1/name/india' request = urllib.request.urlopen(country_url) result = json.loads(request.read()) for values in result: print(values['currencies']) indian_currency= values['currencies']['INR']['name'] capital= values[&quot;capital&quot;] for capital in values[&quot;capital&quot;]: capital_city=capital continent= values[&quot;region&quot;] print(f&quot;The currency of India is the {indian_currency}, the capital city is {capital_city} and it is in the continent of {continent}.&quot;) </code></pre> <pre><code>Traceback (most recent call last): File &quot;main.py&quot;, line 19, in &lt;module&gt; country() File &quot;main.py&quot;, line 11, in country indian_currency= values['currencies']['INR']['name'] KeyError: 'INR' </code></pre> <pre><code> </code></pre> <p>I am trying to retrieve information about a country from an API by using a function. The indian_currency variable actually works and the value is printed from the dictionary in the fstring, but I am still getting a KeyError for the key &quot;INR&quot;. I have already confirmed that it exists and the value would not print if it didn't so Im not quite sure what I'm doing wrong.</p>
[ { "answer_id": 74197697, "author": "dansh", "author_id": 17709997, "author_profile": "https://Stackoverflow.com/users/17709997", "pm_score": 3, "selected": true, "text": "def remove_elements(num_list, item):\n\n items_count = num_list.count(item)\n for i in range(items_count):\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332337/" ]
74,197,482
<p>Learning python casually, and decided to give rock paper scissors a go as a quick project. Went pretty smooth, but I got really caught up in the process of trying to shorten the code you use to compare the results.</p> <pre><code>def check_results(ai, self): if ai == self: return 'tralf' if self == 'rock': if ai == 'paper': return False else: return True if self == 'scissors': if ai == 'rock': return False else: return True if self == 'paper': if ai == 'scissors': return False else: return True </code></pre> <blockquote> <p>ai and self, as you can probably guess, are the computers pick and the players pick just being passed in.</p> </blockquote> <p>Something about having to hard code this was very very unsatisfying to me, and I spent about 20 minutes sort of refusing to do it, and just trying out random stuff to see if I could shorten it.</p> <p>The one thing I tried was to involve something where you get the index of both players choice from a list, and use that to compare them by running it through a separate list. Couldn't get it to work, or at least couldn't get it to work in a way that was better than just hard coding it, so I gave up and did it the boring way. Any help would be appreciated.</p>
[ { "answer_id": 74197575, "author": "Paul M.", "author_id": 10987432, "author_profile": "https://Stackoverflow.com/users/10987432", "pm_score": 1, "selected": false, "text": "def did_player_win(player_choice, computer_choice):\n choices = ['scissors', 'paper', 'rock']\n # The order ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332364/" ]
74,197,487
<p>I have a problem with Angular and Promises I don't understand.</p> <p>This is my html:</p> <pre><code>&lt;div&gt;Is Ready? {{isReady}}&lt;/div&gt; &lt;div *ngIf=&quot;isReady&quot;&gt;Show this&lt;/div&gt; &lt;div *ngIf=&quot;!isReady&quot;&gt;Show that&lt;/div&gt; </code></pre> <p>This is my TS file:</p> <pre><code>isReady: boolean = false; constructor( private myService: MyService){ await this.giveMeSlowData(); } async giveMeSlowData() : Promise&lt;void&gt;{ console.log(await this.myService.getResult()); this.isReady = await this.myService.getResult(); } </code></pre> <p>Usually everything in this {{}} in HTML changes as soon as the variable in TS file. But not now. I can see console log after 5-6 seconds, but the HTML doesn't change. Why?</p> <p>Thanks anyone!</p>
[ { "answer_id": 74197623, "author": "hasnaas", "author_id": 12077805, "author_profile": "https://Stackoverflow.com/users/12077805", "pm_score": 0, "selected": false, "text": "async giveMeSlowData() : Promise<void>{\n this.isReady = await this.myService.getResult();\n console.log(this.isRe...
2022/10/25
[ "https://Stackoverflow.com/questions/74197487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/785053/" ]
74,197,505
<p>In the <code>OnParametersSetAsync</code> method we get the parameters. Based on a parameter (like Id), I need to fetch some async data. I want this initial fetch only once when the component first renders. In order to do that I am managing an extra private boolean field (like _firstRender). So based on this private field I am calling that async method. I want to know is there any other way to achieve this? One more thing is that when <code>StateHasChanged</code> method is necessary to invoke manually and when this gets invoked automatically?</p>
[ { "answer_id": 74205964, "author": "MrC aka Shaun Curtis", "author_id": 13065781, "author_profile": "https://Stackoverflow.com/users/13065781", "pm_score": 2, "selected": false, "text": "ShowRender" }, { "answer_id": 74317204, "author": "Robin Khan", "author_id": 13026962...
2022/10/25
[ "https://Stackoverflow.com/questions/74197505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13026962/" ]
74,197,510
<p>We had a leak in code which resulted in few keys not getting deleted in redis elasticache. We noticed it only when the number became &gt; 3 million. We have fixed code around it, however we need to fix the redis as well. Now we cant flush all as it will delete all the keys. We only want to delete keys, lets say older than 15 days. I found few commands online like however how can I iterate over 3 million records without getting the system stuck. Please help.</p> <p>Thank you in advance.</p> <blockquote> <p>object idletime del record</p> </blockquote>
[ { "answer_id": 74273583, "author": "Neha Agarwal", "author_id": 5253009, "author_profile": "https://Stackoverflow.com/users/5253009", "pm_score": 1, "selected": false, "text": "Iterable<String> iter = redissonClient.getKeys().getKeysByPattern(patternNew, scanLimit);\n delList ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5253009/" ]
74,197,520
<p>I use vue3-simple-html2pdf.</p> <pre><code>&lt;vue3-simple-html2pdf ref=&quot;vue3SimpleHtml2pdf&quot; :options=&quot;pdfOptions&quot; :filename=&quot;exportFilename&quot;&gt; &lt;div class=&quot;main-content&quot;&gt; &lt;h1&gt;PDF&lt;/h1&gt; &lt;/div&gt; &lt;/vue3-simple-html2pdf&gt; &lt;button @click=&quot;download&quot;&gt;Download pdf&lt;/button&gt; </code></pre> <p>documentation says to do this when i want to download pdf</p> <pre><code>this.$refs.vue3SimpleHtml2pdf.download() </code></pre> <p>I use composition api and try to do like this</p> <pre><code>const vue3SimpleHtml2pdf = ref(null) const download = () =&gt; { vue3SimpleHtml2pdf.download() } </code></pre> <p>but it doesn't work</p> <p>how can I fix it?</p>
[ { "answer_id": 74273583, "author": "Neha Agarwal", "author_id": 5253009, "author_profile": "https://Stackoverflow.com/users/5253009", "pm_score": 1, "selected": false, "text": "Iterable<String> iter = redissonClient.getKeys().getKeysByPattern(patternNew, scanLimit);\n delList ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19529980/" ]
74,197,532
<p>I have the below dataset that I am working with in R:</p> <pre><code>df &lt;- data.frame(day=seq(1,3,1), tot.infected=c(1,2,4), tot.ind=5) df </code></pre> <p>And I would like to transform the tot.infected column into a binomial variable with 1's and 0's, such as the following dataframe:</p> <pre><code>df2 &lt;- data.frame(year = c(rep(1,5), rep(2,5), rep(3,5)), infected = c(rep(1,1), rep(0,4), rep(1,2), rep(0,3), rep(1,4), rep(0,1))) </code></pre> <p>Is there a more elegant way to do this in R?</p> <p>Thank you for your help!</p> <p>I tried hard-coding a dataframe using rep(), but this is extremely time-consuming for large datasets and I was looking for a more elegant way to achieve this.</p>
[ { "answer_id": 74273583, "author": "Neha Agarwal", "author_id": 5253009, "author_profile": "https://Stackoverflow.com/users/5253009", "pm_score": 1, "selected": false, "text": "Iterable<String> iter = redissonClient.getKeys().getKeysByPattern(patternNew, scanLimit);\n delList ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332397/" ]
74,197,561
<p>I need to user to choose a file from storage. Once user chooses the file I can't do anything with it because it comes back with an exception &quot;File does not exist&quot;, although it most certainly does. Permissions are granted and I even take persistent URI permission. This sample code is not the prettiest, I know but it still shouldn't give me that excpetion I think. Did I write something wrong or that could cause this problem?</p> <p>Currently this sample code doesn't throw an exception but if statement fails and logs &quot;File does not exist&quot;. I need it to pass if statement and call openMap(). If I were to remove the if statement I would get <code>org.mapsforge.map.reader.header.MapFileException: file does not exist: content:/com.android.externalstorage.documents/document/primary%3Aestonia.map</code></p> <pre><code> final ActivityResultLauncher&lt;Intent&gt; sARL = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback&lt;ActivityResult&gt;() { @Override public void onActivityResult(ActivityResult result) { if (result.getResultCode() == Activity.RESULT_OK){ Intent data = result.getData(); assert data != null; Uri uri = data.getData(); File oFile = new File(uri.getPath()); getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION); if (new File(uri.getPath()).exists()){ openMap(oFile); }else{ Log.w(&quot;File&quot;, &quot;File does not exist&quot;); } } } }); public void openFileDialog(){ Intent data = new Intent(Intent.ACTION_OPEN_DOCUMENT); data.setType(&quot;*/*&quot;); data = Intent.createChooser(data, &quot;Choose tile&quot;); sARL.launch(data); } </code></pre>
[ { "answer_id": 74273583, "author": "Neha Agarwal", "author_id": 5253009, "author_profile": "https://Stackoverflow.com/users/5253009", "pm_score": 1, "selected": false, "text": "Iterable<String> iter = redissonClient.getKeys().getKeysByPattern(patternNew, scanLimit);\n delList ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12899275/" ]
74,197,592
<pre><code>#[derive(Serialize, Deserialize, Debug)] struct Product { id: usize, name: String, timestamp: i128 } </code></pre> <p>I deserialize this struct value from a JSON value.</p> <p>Now I want to expose another property on my struct:</p> <pre><code> dt: OffsetDateTime </code></pre> <p>I want this property to be immutable, and set only once. So I don't want to expose a function that like below b/c it would re-calculate each time I call it:</p> <pre><code>impl Product { fn dt(&amp;self) -&gt; OffsetDateTime { OffsetDateTime::from_unix_timestamp_nanos(self.timestamp) } } </code></pre> <p>In java world or other languages I would do something like this:</p> <pre><code>private dt: OffsetDateTime = null; public OffsetDateTime getDt() { if(dt == null) { dt = OffsetDateTime::from_unix_timestamp_nanos(self.timestamp) } return dt; } </code></pre> <p>Does Rust have a similar pattern I can use?</p>
[ { "answer_id": 74197718, "author": "Chayim Friedman", "author_id": 7884305, "author_profile": "https://Stackoverflow.com/users/7884305", "pm_score": 2, "selected": false, "text": "Option<OffsetDateTime>" }, { "answer_id": 74197738, "author": "etchesketch", "author_id": 40...
2022/10/25
[ "https://Stackoverflow.com/questions/74197592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
74,197,626
<p>I am trying to find out where the state of the radio buttons is saved within the browser, in order to find the selected one.</p> <p>I did some research and I did find out that by using jQuery and the <a href="https://api.jquery.com/serializearray/" rel="nofollow noreferrer">serializeArray</a> on the <code>input</code> I can get the selected value.</p> <p>Nevertheless, in the browser's HTML when clicking on a radio button nothing visually changes. Which makes me think, that this is impossible with Vanilla JS?</p> <p>I am quite confused by the browser's behavior and in addition, I do not understand how the <code>serializeArray</code> is working.</p> <p>The documentation states</p> <blockquote> <p>The .serializeArray() method uses the standard W3C rules for successful controls to determine which elements it should include;</p> </blockquote> <p>So I guess this is a black box and some magic happens in there, to determine the selected checkbox?</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 fun() { const a = $('#fieldset').find('input') const b = a.serializeArray() console.log(b) }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt; &lt;fieldset id="fieldset"&gt; &lt;legend&gt;Select a maintenance drone:&lt;/legend&gt; &lt;div&gt; &lt;input type="radio" id="huey" name="drone" value="huey" checked&gt; &lt;label for="huey"&gt;Huey&lt;/label&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="radio" id="dewey" name="drone" value="dewey"&gt; &lt;label for="dewey"&gt;Dewey&lt;/label&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="radio" id="louie" name="drone" value="louie"&gt; &lt;label for="louie"&gt;Louie&lt;/label&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;button onclick="fun()"&gt; click me &lt;/button&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74197718, "author": "Chayim Friedman", "author_id": 7884305, "author_profile": "https://Stackoverflow.com/users/7884305", "pm_score": 2, "selected": false, "text": "Option<OffsetDateTime>" }, { "answer_id": 74197738, "author": "etchesketch", "author_id": 40...
2022/10/25
[ "https://Stackoverflow.com/questions/74197626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8188498/" ]
74,197,627
<p>I have a list consisting of different types of values - that is, ints and strings. I want to use a loop to find character indexes that are not numbers.</p> <pre><code>#for a list list = [2, 3, 4, '*', 2, '^', '+'] #Output should look like this 3, 5, 6 </code></pre>
[ { "answer_id": 74197665, "author": "It_is_Chris", "author_id": 9177877, "author_profile": "https://Stackoverflow.com/users/9177877", "pm_score": 1, "selected": false, "text": "type" }, { "answer_id": 74197797, "author": "user2506943", "author_id": 2506943, "author_pro...
2022/10/25
[ "https://Stackoverflow.com/questions/74197627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332400/" ]
74,197,645
<p>I'm looking to replace strings inside DataFrame columns, these strings contain special characters.</p> <p>I tried the following, but nothing changed in the DataFrame:</p> <pre><code>data = {'col1': [&quot;series ${z_mask0}&quot;, &quot;series ${z_mask1}&quot;, &quot;series ${z_mask2}&quot;]} df = pd.DataFrame(data) print(df) old_values = [&quot;${z_mask0}&quot;, &quot;${z_mask1}&quot;, &quot;${z_mask2}&quot;] new_values = [&quot;${z_00}&quot;, &quot;${z_01}&quot;, &quot;${z_02}&quot;] df = df.replace(old_values_sign, new_values_sign, regex=True) print(df) </code></pre> <p>The intended output is: ['series ${z_00}', 'series ${z_01}', 'series ${z_02']</p>
[ { "answer_id": 74197693, "author": "JRiggles", "author_id": 8512262, "author_profile": "https://Stackoverflow.com/users/8512262", "pm_score": 0, "selected": false, "text": "old_values" }, { "answer_id": 74197796, "author": "Carmoreno", "author_id": 4508767, "author_pr...
2022/10/25
[ "https://Stackoverflow.com/questions/74197645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16910664/" ]
74,197,655
<p>How I take 2D array input in same line. in C# Console.ReadLine() allow us to take input one at a time .I want to take input as a row</p> <pre><code>int [,] arr = new int[m,n]; for(i = 0; i &lt; m; i++) { for(j = 0; j &lt; n; j++) { arr[i, j] = int.Parse(Console.ReadLine()); } } </code></pre> <p>I want to take input this way 2 2, 10 20, 30 40</p>
[ { "answer_id": 74197693, "author": "JRiggles", "author_id": 8512262, "author_profile": "https://Stackoverflow.com/users/8512262", "pm_score": 0, "selected": false, "text": "old_values" }, { "answer_id": 74197796, "author": "Carmoreno", "author_id": 4508767, "author_pr...
2022/10/25
[ "https://Stackoverflow.com/questions/74197655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14190745/" ]
74,197,667
<p>I am trying to check whether a number is greater or smaller in a <code>while</code> loop without using an array. I am trying to do it with the <code>scanf()</code> function, but have been unsuccesful so far.</p> <p>I tried storing the initial value of the first number into a variable and then checking it at the next iteration of the loop, but I just don't know how. Any advice that helps me move with the code is appreciated greatly.</p> <pre><code>int number, nextNumber; while (...) { scanf(&quot;%d&quot;, &amp;number) nextNumber = number; if (number &gt;= nextNumber) { printf(...); } </code></pre>
[ { "answer_id": 74197693, "author": "JRiggles", "author_id": 8512262, "author_profile": "https://Stackoverflow.com/users/8512262", "pm_score": 0, "selected": false, "text": "old_values" }, { "answer_id": 74197796, "author": "Carmoreno", "author_id": 4508767, "author_pr...
2022/10/25
[ "https://Stackoverflow.com/questions/74197667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14628066/" ]
74,197,710
<p>I want a way to make it so that I can use list B to find out if a copy of it's self exists in list A. I want a way to make it so that I can use list B to find out if a copy of it's self exists in list A.</p> <p>this is the way data a has been collected:</p> <pre><code>for i in range(len(fsa)): if fsa[i] &lt; fsb[i]: kol.append('1') else: kol.append('0') start = 0 end = len(fsa) j = [ ] for x in range(start, end, 6): m = fsb[x:x+6] t = kol[x:x+6] if m[0] &lt; m[-1]: t.append('up') else: t.append('down') j.append(t) counter = Counter(tuple(j) for j in j) for members, count, in counter.items(): print(list(members), count) </code></pre> <p>output:</p> <pre><code>listA = ['1', '1', '0', '1', '0', '1', 'down'] 2 ['0', '0', '1', '1', '1', '1', 'up'] 2 ['1', '0', '0', '1', '0', '1', 'up'] 1 ['0', '0', '0', '1', '1', '0', 'up'] 2 ['1', '1', '0', '0', '0', '0', 'up'] 1 ['0', '0', '1', '1', '0', '1', 'down'] 1 ['1', '0', '0', '0', '0', '1', 'down'] 1 ['1', '1', '1', '1', '1', '1', 'up'] 1 </code></pre> <p>this is how data b was collected:</p> <pre><code>for _ in range(num): inner = driver.find_element_by_xpath(&quot;//html/body/div[1]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div/div/div[2]/div[4]/span[1]&quot;).get_attribute(&quot;innerHTML&quot;) print(inner) lok.append(inner) time.sleep(20)#the hour print(lok) lokk = [] num = 7 for _ in range(num): inner = driver.find_element_by_xpath(&quot;//html/body/div[1]/div[2]/div/div/div/div[2]/div/div[2]/div[2]/div/div/div[2]/div[4]/span[1]&quot;).get_attribute(&quot;innerHTML&quot;) print(inner) lokk.append(inner) time.sleep(20) print(lokk) </code></pre> <p>output:</p> <pre><code>listB = ['1', '1', '1', '1', '1', '1'] </code></pre> <p>list A also shows how many times that particular list has appeared</p> <p>so I want a way to first find the repeating list of list B in list A, secondly to select the one with the most repetitions in the case that there are multiple versions of it.</p> <p>I tried a bunch of things but non really helped as i am still quite new at coding</p>
[ { "answer_id": 74198002, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 0, "selected": false, "text": "listA =[ \n ['1', '1', '0', '1', '0', '1', 'down', 2],\n ['0', '0', '1', '1', '1', '1', 'up', 2],\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20092618/" ]
74,197,732
<p>In my app upcoming project, I plan to use the google ecosystem - that means firebase auth, firestore (noSQL), cloud functions. I want to stick to noSQL as it fits better for this project. While scoping the project, the client asked for a leaderboard of all users (application has some kind of xp system), which is not a problem, but then I remembered I'm working in noSQL.</p> <p>What is the best approach for this problem? This is a duplicate of <a href="https://stackoverflow.com/questions/46720997/leaderboard-ranking-with-firebase">this question</a>, but I don't feel satisfied with the approaches that were presented. Is there any better way to do this? I expect rapidly scaling user base in 10's of thousands of users.</p> <p>I did a quick math considering <a href="https://stackoverflow.com/a/72043234/20332465">this answer</a>. The max size of document in Google Firestore is 1MiB, which amounts to maximum of <strong>62,500</strong> users that can fit into the document, considering they have userID that spans to 8 digits and XP that spans to 6 digits. This solution felt like the most peaceful amongst any others.</p> <p>The problem is, that sorting would have be executed on the client, in Flutter app.</p> <p>Would this solution be somehow good?</p>
[ { "answer_id": 74198002, "author": "Swifty", "author_id": 20267366, "author_profile": "https://Stackoverflow.com/users/20267366", "pm_score": 0, "selected": false, "text": "listA =[ \n ['1', '1', '0', '1', '0', '1', 'down', 2],\n ['0', '0', '1', '1', '1', '1', 'up', 2],\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332465/" ]
74,197,746
<p>1 ) Why would we provide the compiler with the same information two times ? 2 ) Isn't it redundant ? 3) When should we follow this rule ? 4) When can we omit this double declaration and definition ?</p> <pre><code> void fx(void); void fx ( void ){ printf(&quot;Hello World\n&quot;); } int main(void) { fx(); } </code></pre>
[ { "answer_id": 74197827, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 2, "selected": false, "text": "double fx(double x);\n\nint main(void)\n{\n printf(\"%f\\n\", fx(4.0)); \n printf(\"%f\\n\", dx(4.0)); \n...
2022/10/25
[ "https://Stackoverflow.com/questions/74197746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18503064/" ]
74,197,747
<p>I need a solution to group the times of entry and the display the respective time interval and count of users/records during that time interval eg</p> <p>Time Interval Count</p> <p>07:00 AM-07:30 24</p> <p>12:30 PM-13:00 26</p> <p>How can we group time based on interval in Java or SQL</p> <p>I tried group by in sql and LocalTime grouping by using streams But i m not able to segregate based on the time interval</p> <p>Time Interval Count</p> <p>07:00:34 12</p> <p>12:30:23 14</p> <p>07:23:53 12</p> <p>12:46:21 12</p> <p>I m able to get data in the above format only using sql/java(tried both ways)</p>
[ { "answer_id": 74197827, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 2, "selected": false, "text": "double fx(double x);\n\nint main(void)\n{\n printf(\"%f\\n\", fx(4.0)); \n printf(\"%f\\n\", dx(4.0)); \n...
2022/10/25
[ "https://Stackoverflow.com/questions/74197747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11942296/" ]
74,197,765
<p>`</p> <pre><code>//soldity is synchronous lang const ethers = require(&quot;ethers&quot;); const fs = require(&quot;fs-extra&quot;); async function main() { //http://127.0.0.1:7545 const provider = new ethers.providers.JsonRpcProvider( &quot;http://127.0.0.1:7545&quot; ); const wallet = new ethers.Wallet( &quot;5248c9dfa1d4fb6369c105999f1362867d6acd5cf1dee7ef949870231520fa4f&quot;, provider ); const abi = fs.readFileSync(&quot;./SimpleStorage_sol_SimpleStorage.abi&quot;, &quot;utf8&quot;); const binary = fs.readFileSync( &quot;./SimpleStorage_sol_SimpleStorage.bin&quot;, &quot;utf8&quot; ); const contractFactory = new ethers.ContractFactory(abi, binary, wallet); console.log(&quot;Deploying, please wait...&quot;); const contract = await contractFactory.deploy(); //stop here and wait for the contract to deploy console.log(contract); } main() .then(() =&gt; ProcessingInstruction.exit(0)) .catch((error) =&gt; { console.error(error); process.exit(1); }); </code></pre> <p>`</p> <p>The error is -</p> <pre><code>Error: could not detect network (event=&quot;noNetwork&quot;, code=NETWORK_ERROR, version=providers/5.7.2) at Logger.makeError (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/@ethersproject/logger/lib/index.js:238:21) at Logger.throwError (/root/hh-fcc/ethers-simple-storage-fcc/node_modules/@ethersproject/logger/lib/index.js:247:20) </code></pre> <p>So, I am working with JavaScript and solidity and developing a contract. While deploying the contract on a ganache network using node (all code in VS), I am experiencing this network error. PLeasee help! I am trying to learn and have been trying to solve this. Below is the code.</p>
[ { "answer_id": 74197827, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 2, "selected": false, "text": "double fx(double x);\n\nint main(void)\n{\n printf(\"%f\\n\", fx(4.0)); \n printf(\"%f\\n\", dx(4.0)); \n...
2022/10/25
[ "https://Stackoverflow.com/questions/74197765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19872367/" ]
74,197,779
<p>I am using <a href="https://everything.curl.dev/usingcurl/smtp" rel="nofollow noreferrer">Curl</a> to send simple email alerts:</p> <pre><code>curl smtp://mail.example.com --mail-from me@example.com --mail-rcpt \ to@example.com --upload-file email.txt </code></pre> <p>email.txt content:</p> <pre><code>From: John &lt;me@example.com&gt; To: Joe &lt;to@example.com&gt; Subject: Example email Date: Wed, 26 Oct 2022 08:45:16 Welcome to this example email. </code></pre> <p>Is it possible to have variables inside <code>email.txt</code> (e.g., make the date dynamic <code>date</code> or include bash user <code>who</code>)?</p>
[ { "answer_id": 74197827, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 2, "selected": false, "text": "double fx(double x);\n\nint main(void)\n{\n printf(\"%f\\n\", fx(4.0)); \n printf(\"%f\\n\", dx(4.0)); \n...
2022/10/25
[ "https://Stackoverflow.com/questions/74197779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/748789/" ]
74,197,794
<p>I'm importing some values from a csv file and using them to create a adb command for an Android intent with the following code.</p> <pre><code>Write-Host adb shell am start -a android.intent.action.VIEW '-d' '&quot;https://api.whatsapp.com/send?phone=' $($c.number)'&quot;' </code></pre> <p>This gives me an out put of:</p> <pre><code>adb shell am start -a android.intent.action.VIEW -d &quot;https://api.whatsapp.com/send?phone= 12345678 &quot; </code></pre> <p>How can I remove the spaces where the variable is concatenated to the string to give the output of:</p> <pre><code>adb shell am start -a android.intent.action.VIEW -d &quot;https://api.whatsapp.com/send?phone=12345678&quot; </code></pre>
[ { "answer_id": 74197827, "author": "0___________", "author_id": 6110094, "author_profile": "https://Stackoverflow.com/users/6110094", "pm_score": 2, "selected": false, "text": "double fx(double x);\n\nint main(void)\n{\n printf(\"%f\\n\", fx(4.0)); \n printf(\"%f\\n\", dx(4.0)); \n...
2022/10/25
[ "https://Stackoverflow.com/questions/74197794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5721449/" ]
74,197,826
<p>I am trying to pick out all values from an object I have in string form. I have created the regular expression, but I am still having issues with not being able to remove the quotes and have hit a wall...</p> <p>Here is the code I have with results I get compared to desired results:</p> <pre><code>const regex = /(?:&quot;([^&quot;]+)\&quot;)|([^=&quot;,{}.]+)/g const string = 'obj{a=&quot;0&quot;,b=&quot;1&quot;,domain=&quot;a-ss.test.io:666&quot;,f=&quot;g&quot;,range=&quot;3.594e-04...4.084e-04&quot;}' const matches = string.match(regex) console.log(matches) </code></pre> <p>Here is the resulting array:</p> <pre><code>[ &quot;obj&quot;, &quot;a&quot;, &quot;\&quot;0\&quot;&quot;, &quot;b&quot;, &quot;\&quot;1\&quot;&quot;, &quot;domain&quot;, &quot;\&quot;a-ss.test.io:666\&quot;&quot;, &quot;f&quot;, &quot;\&quot;g\&quot;&quot;, &quot;range&quot;, &quot;\&quot;3.594e-04...4.084e-04\&quot;&quot; ] </code></pre> <p>Though the desired result I would like is:</p> <pre><code>[ &quot;obj&quot;, &quot;a&quot;, &quot;0&quot;, &quot;b&quot;, &quot;1&quot;, &quot;domain&quot;, &quot;a-ss.test.io:666&quot;, &quot;f&quot;, &quot;g&quot;, &quot;range&quot;, &quot;3.594e-04...4.084e-04&quot; ] </code></pre> <p>Does anyone know how to also remove the quotes from each array value that is returned?</p>
[ { "answer_id": 74198895, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "String#match" }, { "answer_id": 74204516, "author": "Peter Thoeny", "author_id": 7475450, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1842562/" ]
74,197,844
<p>I want to copy a file from AWS S3 to SFTP server without downloading to local using python,any help on this can be appreciated, thank you.</p> <p>Sample python code to run.</p>
[ { "answer_id": 74198895, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "String#match" }, { "answer_id": 74204516, "author": "Peter Thoeny", "author_id": 7475450, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332631/" ]
74,197,867
<p>Using Azure Speech Service, I'm trying to transcribe a bunch a wav files (compressed in the PCMU aka mu-law format).</p> <p>I came up with the following code based on the articles referenced below. The code works fine sometimes with few files, but I keep getting <code>Segmentation fault</code> errors while looping a bigger list of files (~50) and it never break on the same file (could be 2nd, 15th or 27th).</p> <p>Also, when running a subset of files, transcription results seems the same with or without the decompression part of the code which makes me wonder if the decompression method recommended by Microsoft works at all.</p> <pre class="lang-py prettyprint-override"><code>import azure.cognitiveservices.speech as speechsdk def azurespeech_transcribe(audio_filename): class BinaryFileReaderCallback(speechsdk.audio.PullAudioInputStreamCallback): def __init__(self, filename: str): super().__init__() self._file_h = open(filename, &quot;rb&quot;) def read(self, buffer: memoryview) -&gt; int: try: size = buffer.nbytes frames = self._file_h.read(size) buffer[:len(frames)] = frames return len(frames) except Exception as ex: print('Exception in `read`: {}'.format(ex)) raise def close(self) -&gt; None: try: self._file_h.close() except Exception as ex: print('Exception in `close`: {}'.format(ex)) raise compressed_format = speechsdk.audio.AudioStreamFormat( compressed_stream_format=speechsdk.AudioStreamContainerFormat.MULAW ) callback = BinaryFileReaderCallback(filename=audio_filename) stream = speechsdk.audio.PullAudioInputStream( stream_format=compressed_format, pull_stream_callback=callback ) speech_config = speechsdk.SpeechConfig( subscription=&quot;&lt;my_subscription_key&gt;&quot;, region=&quot;&lt;my_region&gt;&quot;, speech_recognition_language=&quot;en-CA&quot; ) audio_config = speechsdk.audio.AudioConfig(stream=stream) speech_recognizer = speechsdk.SpeechRecognizer(speech_config, audio_config) result = speech_recognizer.recognize_once() return result.text </code></pre> <p>Code is running on WSL.</p> <hr /> <p><strong>I have already tried:</strong></p> <ul> <li>Logging a more meaningful error with <code>faulthandler</code> module</li> <li>Increasing Python stack limit: <code>resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY))</code></li> <li>Adding some sleep timers</li> </ul> <hr /> <p><strong>References:</strong></p> <ul> <li><a href="https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/how-to-recognize-speech?pivots=programming-language-python#recognize-speech-from-a-file" rel="nofollow noreferrer">How to recognize speech</a></li> <li><a href="https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/how-to-use-codec-compressed-audio-input-streams?tabs=linux%2Cdebian%2Cjava-android%2Cterminal&amp;pivots=programming-language-python" rel="nofollow noreferrer">How to use compressed input audio</a></li> </ul>
[ { "answer_id": 74198895, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "String#match" }, { "answer_id": 74204516, "author": "Peter Thoeny", "author_id": 7475450, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5960632/" ]
74,197,872
<p>i'm new on it and i'm trying from this JSON array in Javascript</p> <p>So i need to sort the &quot;Name&quot; by Product they were assigned</p> <pre><code>[ { &quot;Name&quot;:&quot;Marcelo Rocha&quot;, &quot;Product_Line__c&quot;:&quot;SAP&quot;, &quot;Role&quot;:&quot;Regional Manager, SAP Support Delivery, LATAM&quot; }, { &quot;Name&quot;:&quot;Marcelo Rocha&quot;, &quot;Product_Line__c&quot;:&quot;Business Objects&quot;, &quot;Role&quot;:&quot;Regional Manager, SAP Support Delivery, LATAM&quot; }, { &quot;Name&quot;:&quot;Marcelo Rocha&quot;, &quot;Product_Line__c&quot;:&quot;Oracle Technology&quot;, &quot;Role&quot;:&quot;Regional Manager, SAP Support Delivery, LATAM&quot; }, { &quot;Name&quot;:&quot;Leonardo Gracioli&quot;, &quot;Product_Line__c&quot;:&quot;SAP&quot;, &quot;Role&quot;:&quot;Senior Support Engineer, SAP&quot; }, { &quot;Name&quot;:&quot;Leonardo Gracioli&quot;, &quot;Product_Line__c&quot;:&quot;Business Objects&quot;, &quot;Role&quot;:&quot;Senior Support Engineer, SAP&quot; }, { &quot;Name&quot;:&quot;Leonardo Gracioli&quot;, &quot;Product_Line__c&quot;:&quot;Oracle Technology&quot;, &quot;Role&quot;:&quot;Senior Support Engineer, SAP&quot; }, { &quot;Name&quot;:&quot;Adriane Yonamine&quot;, &quot;Product_Line__c&quot;:&quot;SAP&quot;, &quot;Role&quot;:&quot;SAP Consultant&quot; } ] </code></pre> <p>Combine the &quot;Name&quot; by ProductLime in order to be like this:</p> <pre><code>[ { &quot;Name&quot;:&quot;Marcelo Rocha&quot;, &quot;Product_Line__c&quot;:&quot;SAP,Business Objects,Oracle Technology&quot;, &quot;Role&quot;:&quot;Regional Manager, SAP Support Delivery, LATAM&quot; }, { &quot;Name&quot;:&quot;Leonardo Gracioli&quot;, &quot;Product_Line__c&quot;:&quot;SAP,Business Objects,Oracle Technology&quot;, &quot;Role&quot;:&quot;Senior Support Engineer, SAP&quot; }, { &quot;Name&quot;:&quot;Adriane Yonamine&quot;, &quot;Product_Line__c&quot;:&quot;SAP&quot;, &quot;Role&quot;:&quot;SAP Consultant&quot; } ] </code></pre> <p>Please could anyone know an easier way to do it?</p>
[ { "answer_id": 74198895, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "String#match" }, { "answer_id": 74204516, "author": "Peter Thoeny", "author_id": 7475450, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74197872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17108604/" ]
74,197,904
<p>I'm sure this is a silly question, I have a couple of strings such as <code>data_PB_Belf.csv</code> and I need to exctract only <code>PB_Belf</code> (and so on). <strong>How can I exctract everything after the first _ up to . (preferably using <code>stringr</code> ) ?</strong></p> <pre><code>data [1] &quot;data_PB_Belf.csv&quot; &quot;data_PB_NI.csv&quot; ... str_replace(data[1], &quot;^[^_]+_([^_]+)_.*&quot;, &quot;\\1&quot;) ## the closer I got, it returns &quot;PB&quot; </code></pre> <ul> <li>I tried to adapt the code from <a href="https://stackoverflow.com/questions/73939789/regex-get-string-between-intervals-underscores">here</a>, but I wasn't able to. I'm sure that there's a way to use <code>str_replace()</code> or <code>str_sub()</code> or <code>str_extract()</code>, I just can't get the right Regex. Thanks in advance!</li> </ul>
[ { "answer_id": 74197913, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 3, "selected": true, "text": "_" }, { "answer_id": 74199162, "author": "Chris Ruehlemann", "author_id": 8039978, "author_profile"...
2022/10/25
[ "https://Stackoverflow.com/questions/74197904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18364222/" ]
74,197,914
<p>Say i have some iterations. In each iteration, a list of integers and a float number are created.</p> <pre><code>1st iteration: [0,2,4,3,0] , 285 are created 2nd iteration: [0,8,5,6,0] , 230 are created ... nth iteration: [0,9,8,1,0] , 340 are created </code></pre> <p>I want to iteratively append each list-float pair to an object, so I can later get the list with the lowest float value. Desired output could be for example something like this:</p> <pre><code>ListColumn, FloatColumn [0,2,4,3,0], 285 [0,8,5,6,0], 230 ... [0,9,8,1,0], 340 </code></pre> <p>I tried to append these lists and floats to a dictionary (with floats as keys) but since some floats can be equal, the number of elements inside the dictionary is less than expected. Any ideas?</p>
[ { "answer_id": 74197913, "author": "akrun", "author_id": 3732271, "author_profile": "https://Stackoverflow.com/users/3732271", "pm_score": 3, "selected": true, "text": "_" }, { "answer_id": 74199162, "author": "Chris Ruehlemann", "author_id": 8039978, "author_profile"...
2022/10/25
[ "https://Stackoverflow.com/questions/74197914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18354667/" ]
74,197,915
<p>I'm attempting to create <code>pl.Series</code> where each element for row n is a list of items 1...n. Using <code>pl.arange</code> doesn't seem to work and I'm not sure how to finagle it into my desired result:</p> <pre class="lang-py prettyprint-override"><code>import polars as pl df = pl.DataFrame({ 'a': [1, 2, 3, 4, 5] }).select( pl.arange(1, pl.col('a')+1) ) </code></pre> <p>It appears <code>pl.arange</code> generates a [vertical] Series and cannot be aggregated into lists. I can get around this by using python's range:</p> <pre class="lang-py prettyprint-override"><code>df = pl.DataFrame({ 'a': [1, 2, 3, 4, 5] }) print(df.with_columns([ pl.col('a').apply(lambda x: list(range(1, x+1))).alias('c') ])) </code></pre> <pre><code>shape: (5, 2) ┌─────┬───────────────┐ │ a ┆ c │ │ --- ┆ --- │ │ i64 ┆ list[i64] │ ╞═════╪═══════════════╡ │ 1 ┆ [1] │ ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ │ 2 ┆ [1, 2] │ ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ │ 3 ┆ [1, 2, 3] │ ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ │ 4 ┆ [1, 2, ... 4] │ ├╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤ │ 5 ┆ [1, 2, ... 5] │ └─────┴───────────────┘ </code></pre> <p>But this probably isn't nearly as performant.</p>
[ { "answer_id": 74282728, "author": "braaannigan", "author_id": 5387991, "author_profile": "https://Stackoverflow.com/users/5387991", "pm_score": 2, "selected": true, "text": "groupby_rolling" }, { "answer_id": 74620883, "author": "jqurious", "author_id": 19355181, "au...
2022/10/25
[ "https://Stackoverflow.com/questions/74197915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3681427/" ]
74,197,932
<p>I try to create a border around a container, that is not that difficult ofcourse, but i need also a text IN the border with space around it. Like horizontal divder but i need a complete border.</p> <p>Attached what i like to achieve.</p> <p>Any one who can help me how to approach this?</p> <p>Thanks!</p> <p><a href="https://i.stack.imgur.com/6Kt4w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6Kt4w.png" alt="enter image description here" /></a></p> <p>Tried to use the horizontal and vertical divider packages, but then the border is not in full.</p>
[ { "answer_id": 74198221, "author": "Kamlendra Pandey", "author_id": 5340621, "author_profile": "https://Stackoverflow.com/users/5340621", "pm_score": 0, "selected": false, "text": "Stack(\n children: [\n Positioned(\n top: 12,\n left: 0,\n rig...
2022/10/25
[ "https://Stackoverflow.com/questions/74197932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13084852/" ]
74,197,933
<p>I have two classes Employee, Address. And an employee can have multiple addresses.</p> <pre><code>Employee emp1 = new Employee(&quot;emp1&quot;, &quot;emp1&quot;); Employee emp2 = new Employee(&quot;emp2&quot;, &quot;emp2&quot;); Address address1 = new Address(&quot;city1&quot;); Address address2 = new Address(&quot;city2&quot;); List&lt;Address&gt; list1 = new ArrayList&lt;&gt;(); list1.add(address1); List&lt;Address&gt; list2 = new ArrayList&lt;&gt;(); list2.add(address2); emp1.setAddressList(list1); emp2.setAddressList(list2); </code></pre> <p>Given the above inputs, how can I create Map&lt;String, List&gt; list of employees grouped by city using Java stream functions.</p> <pre><code> Given the above inputs, how can I create Map&lt;String, List&lt;Employee&gt;&gt; list of employees grouped by city using Java stream functions. </code></pre>
[ { "answer_id": 74198221, "author": "Kamlendra Pandey", "author_id": 5340621, "author_profile": "https://Stackoverflow.com/users/5340621", "pm_score": 0, "selected": false, "text": "Stack(\n children: [\n Positioned(\n top: 12,\n left: 0,\n rig...
2022/10/25
[ "https://Stackoverflow.com/questions/74197933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4707814/" ]
74,197,943
<p>I am trying to figure out how to an if/else or if/elif statement along with a for loop in python to loop through a program to print out a statement based on the number of items in a list for the value from the key value pairs. .</p> <pre><code>favoritePlaces = { 'tom': ['alaska', 'wales', 'italy',], 'rory': ['hawaii',], 'frank': ['greenland', 'south africa',], } lengths = {key:len(value) for key,value in favoritePlaces.items()} print(lengths.values()) for person, places in favoritePlaces.items(): if length in lengths.values() &gt; 1: print(f&quot;\n{person.title()}'s favorite places are:&quot;) for place in places: print(f&quot;\t- {place.title()}&quot;) else: print(f&quot;\n{person.title()}'s favorite place is:&quot;) for place in places: print(f&quot;\t- {place.title()}&quot;) The output should look like this: </code></pre> <p>Tom's favorite places are: - Alaska - Wales - Italy</p> <p>Rory's favorite place is: - Hawaii</p> <p>Frank's favorite places are: - Greenland - South Africa</p> <pre><code> I have tried placing the for loops and if statements in different configurations to try and get it to work. Every configuration gives me length not defined. I have looked though stackoverflow for an answer and that is where I put in the lengths variable hoping the would help. I am fairly new to coding and trying to learn and I am not sure if I put in the wrong search parameters. Any help would be greatly appreciated, and thanks in advance. </code></pre>
[ { "answer_id": 74198221, "author": "Kamlendra Pandey", "author_id": 5340621, "author_profile": "https://Stackoverflow.com/users/5340621", "pm_score": 0, "selected": false, "text": "Stack(\n children: [\n Positioned(\n top: 12,\n left: 0,\n rig...
2022/10/25
[ "https://Stackoverflow.com/questions/74197943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17450103/" ]
74,197,945
<p>I have a matrix like this:</p> <pre><code>df1 ABC DEF GHI JKL 1 2 8 2 3 8 9 5 3 2 1 9 </code></pre> <p>Then another df that has a column</p> <pre><code>df2 ID ABC DEF GHI </code></pre> <p>Can I filter the matrix based on column name so only those that are in the ID column are kept? I tried:</p> <pre><code>list&lt;-as_list(df2$ID) df3&lt;-df1[colnames(df1)%in% list,] </code></pre> <p>I want to get</p> <pre><code> ABC DEF GHI 1 2 8 3 8 9 3 2 1 </code></pre>
[ { "answer_id": 74197993, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 1, "selected": false, "text": "df1[, intersect(colnames(df1), as.character(df2$ID)]\n" }, { "answer_id": 74198041, "author": "akr...
2022/10/25
[ "https://Stackoverflow.com/questions/74197945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12860167/" ]
74,197,951
<p>Having an issue with where i seem to be connecting to SQL Server but cannot find the server/db.</p> <p><a href="https://i.stack.imgur.com/zcLBk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zcLBk.png" alt="enter image description here" /></a></p> <p>I have been trying to follow the steps in this guide for Cypress 9 but to no avail.</p> <p><a href="https://www.npmjs.com/package/cypress-sql-server" rel="nofollow noreferrer">https://www.npmjs.com/package/cypress-sql-server</a></p> <p>There was an answer on SO that i've been trying to use but I can't reply to a comment and add a comment but it was deleted by the mods for some reason. This is the URL to the answer I have been trying to follow but can't connect.</p> <p><a href="https://stackoverflow.com/questions/73831176/how-to-configure-cypress-sql-server-with-no-cypress-json-updated">How to configure cypress-sql-server with no cypress.json? (updated)</a></p> <p>Has someone please got a working example?</p> <p>cypress.config.ts</p> <pre><code>const { defineConfig } = require(&quot;cypress&quot;); const sqlServer = require(&quot;cypress-sql-server&quot;); module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { // allows db data to be accessed in tests config.db = { &quot;userName&quot;: &quot;x&quot;, &quot;password&quot;: &quot;x&quot;, &quot;server&quot;: &quot;xxx\\SQLEXPRESS&quot;, &quot;options&quot;: { &quot;database&quot;: &quot;xxxxxx&quot;, &quot;encrypt&quot;: true, &quot;rowCollectionOnRequestCompletion&quot;: true, &quot;trusted_connection&quot;: true } } // code from /plugins/index.js const tasks = sqlServer.loadDBPlugin(config.db); on('task', tasks); return config // implement node event listeners here }, }, }); export default defineConfig({ chromeWebSecurity: false, videosFolder: 'cypress/videos', screenshotsFolder: 'cypress/screenshots', fixturesFolder: 'cypress/fixtures', video: false, reporter: 'cypress-mochawesome-reporter', reporterOptions: { reportDir: 'cypress/reports', charts: true, reportPageTitle: 'xxxxxxxx', embeddedScreenshots: true, inlineAssets: true, }, e2e: { // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { return require('./cypress/plugins/index.ts')(on, config) }, experimentalSessionAndOrigin: true, specPattern: 'cypress/e2e/tests/orders/*', baseUrl: 'http://localhost:4200', }, }) </code></pre> <p>index.ts</p> <pre><code>const { defineConfig } = require('cypress') module.exports = (on, config) =&gt; { require('@cypress/code-coverage/task')(on, config); require('cypress-mochawesome-reporter/plugin')(on); return config; } </code></pre> <p>e2e.ts</p> <pre><code>import '@cypress/code-coverage/support'; import './commands'; import 'cypress-mochawesome-reporter/register'; import sqlServer from 'cypress-sql-server'; sqlServer.loadDBCommands(); } </code></pre> <p>Tried creating a new sysadmin also on SQL Server in case it was an access issue</p>
[ { "answer_id": 74197993, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 1, "selected": false, "text": "df1[, intersect(colnames(df1), as.character(df2$ID)]\n" }, { "answer_id": 74198041, "author": "akr...
2022/10/25
[ "https://Stackoverflow.com/questions/74197951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10596570/" ]
74,197,990
<p>I started a new game project, and I have tried to find a way to only use a <code>rigidbody2D</code> component to move my player game object instead of using <code>transform.position</code>. And I can't come up with a good way to do it or find a tutorial or documentation about it.</p> <p>I have got it to work with <code>transform.position</code>, but how could I do it with <code>rigidbody2D</code>?</p>
[ { "answer_id": 74197993, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 1, "selected": false, "text": "df1[, intersect(colnames(df1), as.character(df2$ID)]\n" }, { "answer_id": 74198041, "author": "akr...
2022/10/25
[ "https://Stackoverflow.com/questions/74197990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332681/" ]
74,197,996
<p>i am beginner of python and i have a question. How to pass the result of one function to another one. I want to make new list based on first one only with prime digits, and when i run my program second list is empty</p> <pre><code>def get_list_of_int_numbers(n: int): list1 = [random.randint(10, 100) for x in range(random.randint(10, 100))] * n return list1 def get_prime_digits(n: int) -&gt; bool: return n in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.] def get_second_list_based_on_old_one_with_prime_digits(expression: list) -&gt; list: list2 = [n for n in expression if n == get_prime_digits(n)] return list2 def main() -&gt; None: n1 = random.randint(10, 100) print(get_list_of_int_numbers(n1)) print(get_second_list_based_on_old_one_with_prime_digits(get_list_of_int_numbers(n1))) if __name__ == '__main__': main() </code></pre> <p>any help would be appreciated</p>
[ { "answer_id": 74197993, "author": "Jilber Urbina", "author_id": 1315767, "author_profile": "https://Stackoverflow.com/users/1315767", "pm_score": 1, "selected": false, "text": "df1[, intersect(colnames(df1), as.character(df2$ID)]\n" }, { "answer_id": 74198041, "author": "akr...
2022/10/25
[ "https://Stackoverflow.com/questions/74197996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332737/" ]
74,198,003
<p>I am trying to implement the <strong>IDisposable</strong> pattern on a derived class, and it's not working as expecting to work,</p> <p>Suppose I have two classes and I want to call the <strong>Dispose</strong> method of the derived class:</p> <p>Below is the code of my base class</p> <pre><code>public class BaseClass : IDisposable { // To detect redundant calls private bool _disposedValue; // Public implementation of Dispose pattern callable by consumers. public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } // Protected implementation of Dispose pattern. protected virtual void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects) } // TODO: free unmanaged resources (unmanaged objects) and override finalizer // TODO: set large fields to null _disposedValue = true; } } } </code></pre> <p>And I've something like this as a derived class</p> <pre><code>public class DerivedClass : BaseClass { // To detect redundant calls private bool _disposedValue; // Protected implementation of Dispose pattern. protected override void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { } _disposedValue = true; } // Call base class implementation. base.Dispose(disposing); } } </code></pre> <p>And I've some wrapper class</p> <pre><code>public class WrapperClass : IDisposable { public ReadOnlyCollection&lt;BaseClass&gt; Items { get; set;} // To detect redundant calls private bool _disposedValue; // Public implementation of Dispose pattern callable by consumers. public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } // Protected implementation of Dispose pattern. protected virtual void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { foreach (var item in Items) { item.Dispose(); } } _disposedValue = true; } } } </code></pre> <p>My issue is in the wrapper class, it doesn't call the <strong>Dispose</strong> method of the <strong>DerivedClass</strong>, and it calls the Dispose method of the <strong>BaseClass</strong> instead.</p> <p><strong>Update</strong></p> <p>It's my bad, I forget to say that the collections of items were created by <strong>NSubstitute</strong> like below:</p> <pre><code> // Having this will not call the Dispose method of the derived class Items = new ReadOnlyCollection&lt;BaseClass&gt;(new List&lt;BaseClass&gt; { Substitute.For&lt;DerivedClass&gt;() }) // Having this will call the Dispose method of the derived class Items = new ReadOnlyCollection&lt;BaseClass&gt;(new List&lt;BaseClass&gt; { new DerivedClass&gt;() }) </code></pre>
[ { "answer_id": 74198309, "author": "Mike Hofer", "author_id": 47580, "author_profile": "https://Stackoverflow.com/users/47580", "pm_score": -1, "selected": false, "text": "DerivedClass" }, { "answer_id": 74200537, "author": "Joel Coehoorn", "author_id": 3043, "author_...
2022/10/25
[ "https://Stackoverflow.com/questions/74198003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9091039/" ]
74,198,021
<p>I'm fairly new to Docker and am struggling with <code>JAVA_HOME</code> not being seen in a Dockerfile. I get the titular error; which includes <code>Please set the JAVA_HOME variable in your environment to match the location of your Java installation.</code> &amp; <code>executor failed running [/bin/sh -c /opt/Android/cmdline-tools/latest/bin/sdkmanager --update]: exit code: 1</code> when it runs <code>RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --update</code>.</p> <p>I feel like I'm at a loss but I think my issue is not knowing where the JDK is being installed to or knowing how to find it from a Dockerfile; I've tried echoing <code>JAVA_HOME</code> thinking I could see it while the image built but, again, no luck. Any help with this would be greatly appreciated. I've been pulling my hair out Googling &amp; trying things. Thank you.</p> <pre><code>FROM node:12.12.0 ARG CMDLINE_TOOLS_VERSION=7583922 ARG ANDROID_BUILD_TOOLS=30.0.3 RUN apt-get -qqy update \ &amp;&amp; apt-get -qqy install \ python-dev \ --no-install-recommends RUN apt-get install -y software-properties-common gcc RUN apt-get update &amp;&amp; apt-get install -y python3-pip RUN pip3 install awscli RUN apt-get install -y jq RUN mkdir -p /usr/share/man/man1 /usr/share/man/man2 RUN apt-get update &amp;&amp; apt-get install -y --no-install-recommends openjdk-8-jdk &amp;&amp; apt-get clean; ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 ENV PATH=$PATH:$JAVA_HOME/bin RUN wget -q https://services.gradle.org/distributions/gradle-4.5.1-bin.zip &amp;&amp; unzip gradle-4.5.1-bin.zip -d /opt &amp;&amp; rm gradle-4.5.1-bin.zip ENV GRADLE_HOME=/opt/gradle-4.5.1 ENV PATH=$PATH:/opt/gradle-4.5.1/bin RUN wget https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINE_TOOLS_VERSION}_latest.zip RUN mkdir -p /opt/Android/cmdline-tools RUN unzip commandlinetools-linux-7583922_latest.zip -d /opt/Android/cmdline-tools RUN mv /opt/Android/cmdline-tools/cmdline-tools /opt/Android/cmdline-tools/latest ENV ANDROID_HOME=/opt/Android ENV PATH=&quot;$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin \ :$ANDROID_HOME/cmdline-tools/latest:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH&quot; RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --update RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --list RUN /opt/Android/cmdline-tools/latest/bin/sdkmanager --list | grep build-tools RUN echo y | /opt/Android/cmdline-tools/latest/bin/sdkmanager &quot;build-tools;${ANDROID_BUILD_TOOLS}&quot; &quot;platform-tools&quot; &quot;platforms;android-30&quot; &quot;tools&quot; &gt;/dev/null RUN yes | /opt/Android/cmdline-tools/latest/bin/sdkmanager --licenses CMD [&quot;yarn&quot;, &quot;start&quot;] </code></pre>
[ { "answer_id": 74258544, "author": "gvisoc", "author_id": 1916029, "author_profile": "https://Stackoverflow.com/users/1916029", "pm_score": 1, "selected": false, "text": "ENV" }, { "answer_id": 74258599, "author": "Martin Zeitler", "author_id": 549372, "author_profile...
2022/10/25
[ "https://Stackoverflow.com/questions/74198021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7407119/" ]
74,198,022
<p>I need to access server data in a javascript file that gets loaded with an admin page. In my case, I'll need a json variable that is set in the <code>settings.py</code> file (in the production version, this json-variable gets loaded from env-variable which means that the content of the variable is known at startup-time but is not hard coded).</p> <p>I use the javascript to validate and populate some fields in an admin-page - that is a better UX than doing it server side.</p> <p>Is it possible to add script-tag to the admin html-pages' head section, that contains server data, i.e. non-static data?</p>
[ { "answer_id": 74199867, "author": "Mina Atef", "author_id": 12860808, "author_profile": "https://Stackoverflow.com/users/12860808", "pm_score": 1, "selected": false, "text": "class TestAdmin(admin.ModelAdmin):\n\n class Media:\n\n js = ('js/some_js_file.js',)\n" }, { ...
2022/10/25
[ "https://Stackoverflow.com/questions/74198022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/522209/" ]
74,198,026
<p>So I want to implement a simple CarShop contract in Solidity. The contract should be initiated with a constructor where I input the current stock amount for the cars I already have in my Shop. I call these in the constructor (ToyotaCount, AudiCount, BmwCount)...</p> <p>Then I think I need to create a struct that would store the CarCount and the CarType. So I created an enum with (Toyota, Audi, Bmw)...</p> <p>Finally, I would like to create this struct with the values CarCount from the constructor (as the initial state) together with carType of the cars from the enum... However, I am confused how exactly I should implement it and where I am going wrong.</p> <p>Also, as a next step I want to implement a function called &quot;AddCar&quot; to update the values in the struct when I add some cars... for example I want to add 3 Audi cars...</p> <p>Can you perhaps show me how I would need to correct my code, so the constructor, struct, enum work together. I would also really appreciate if you could point me to some similar projects or implementations.</p> <p>This is my current Code. I think I initiated the constructor correctly. However, then something goes wrong with the interplay of struct and enum and constructor.</p> <p>'''</p> <pre><code>contract CarShop { address owner; uint256 toyotaCount; uint256 audiCount; uint256 bmwCount; constructor(uint256 _toyotaCount, uint256 _audiCount, uint256 _bmwCount) { owner = msg.sender; toyotaCount = _toyotaCount; audiCount = _audiCount; bmwCount = _bmwCount; } enum CarType {None, Toyota, Audi, Bmw} struct Cars { CarType carType; uint count; } Cars public item; Cars memory toyota = Cars(carType, toyotaCount) } </code></pre> <p>'''</p>
[ { "answer_id": 74199867, "author": "Mina Atef", "author_id": 12860808, "author_profile": "https://Stackoverflow.com/users/12860808", "pm_score": 1, "selected": false, "text": "class TestAdmin(admin.ModelAdmin):\n\n class Media:\n\n js = ('js/some_js_file.js',)\n" }, { ...
2022/10/25
[ "https://Stackoverflow.com/questions/74198026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18310872/" ]
74,198,030
<p>I have a dataset composed of reddit posts where each row shows the post, date, the predicted ML sentiment based on the content in the post, and whether a given post is directed at a specific politician.</p> <p>Here is a data example:</p> <pre><code>post date mood directed_to_whom Cartman 2012-09-03. negative Romney Cartman 2012-09-06. negative Romney Cartman 2012-09-13. negative Romney Cartman 2012-09-15. neutral Bush Mackey 2012-09-03. negative Bush Mackey 2012-09-08. neutral Bush Mackey 2012-09-13. neutral post Garrison 2012-09-03. negative Romney Garrison 2012-09-04. negative pre Garrison 2012-09-04. negative pre Garrison 2012-09-05. negative Obama </code></pre> <p>I have created a graph showing the monthly share of negative, neutral, versus positive posts throughout time as below. However, I am interested in creating a variable that measures the number/share of posts that were negative and directed at Obama, or positive and directed at Romney, but I am not sure if that's possible?</p> <pre><code>ggplot(both_group, aes(x = as.Date(month_year), fill = sentiment ,y = sentiment_percentage)) + geom_bar(stat = &quot;identity&quot;, position=position_dodge()) + scale_x_date(date_breaks = &quot;1 month&quot;, date_labels = &quot;%b %Y&quot;) + xlab(&quot;Sentiment&quot;) + theme(plot.title = element_text(size = 18, face = &quot;bold&quot;)) + scale_y_continuous (name = &quot;Sentiment share&quot;) + theme_classic()+ theme(plot.title = element_text(size = 5, face = &quot;bold&quot;), axis.text.x = element_text(angle = 90, vjust = 0.5)) </code></pre> <p>Here is the Output: <a href="https://i.stack.imgur.com/J4Y2j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J4Y2j.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74199867, "author": "Mina Atef", "author_id": 12860808, "author_profile": "https://Stackoverflow.com/users/12860808", "pm_score": 1, "selected": false, "text": "class TestAdmin(admin.ModelAdmin):\n\n class Media:\n\n js = ('js/some_js_file.js',)\n" }, { ...
2022/10/25
[ "https://Stackoverflow.com/questions/74198030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19060810/" ]
74,198,043
<p>I am making 2 deep copies of a list. The problem is that first deep copy behaves fine, but second deep copy of the list is being altered based on changes on my original list.</p> <pre><code>import copy def findThreeLargestNumbers(array): # Write your code here. org_array2=copy.deepcopy(array) org_array1=copy.deepcopy(array) largest1=0 largest2=0 largest3=0 for i in range(0,len(array)-1): if(array[i] &gt;= array[i+1]): array[i+1]=array[i] largest1=array[-1] print(largest1) print(array) org_array1.remove(largest1) for i in range(0,len(org_array1)-1): if(org_array1[i] &gt;= org_array1[i+1]): org_array1[i+1]=org_array1[i] largest2=org_array1[-1] print(largest2) print(org_array1) org_array2.remove(largest2) for i in range(0,len(org_array2)-1): if(org_array2[i] &gt;= org_array2[i+1]): org_array2[i+1]=org_array2[i] largest3=org_array2[-1] print(largest3) print(org_array2) array= [10,5,9,10,12,3,517,69,81,74] findThreeLargestNumbers(array) 517 [10, 10, 10, 10, 12, 12, 517, 517, 517, 517] 81 [10, 10, 10, 10, 12, 12, 69, 81, 81] 517 [10, 10, 10, 10, 12, 12, 517, 517, 517] </code></pre> <p>I want my both the newly copied lists to be independent of each other, as well as independent of original list.</p>
[ { "answer_id": 74198251, "author": "Mark", "author_id": 2203038, "author_profile": "https://Stackoverflow.com/users/2203038", "pm_score": 1, "selected": false, "text": "import copy\n\ndef findThreeLargestNumbers(array):\n # Write your code here.\n org_array2=copy.deepcopy(array)\n\...
2022/10/25
[ "https://Stackoverflow.com/questions/74198043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11302568/" ]
74,198,046
<p>In the following, I expected class <code>Child</code>'s protected field member <code>_AorB</code> to be of type <code>B</code>, and not <code>A</code>, but reality shows otherwise.</p> <p>What am I mis-understanding, and how can I adjust the code for the desired behavior?</p> <pre><code>class A{ public: void doit(){ std::cout&lt;&lt;&quot; this is A!&quot;&lt;&lt;std::endl; } }; class B{ public: void doit(){ std::cout&lt;&lt;&quot; this is B!&quot;&lt;&lt;std::endl; } }; class Parent{ public: void doit(){ _AorB.doit(); } protected: A _AorB; }; class Child: public virtual Parent{ protected: B _AorB; }; int main() { cout&lt;&lt;&quot;Hello World&quot;; auto c = Child(); c.doit(); // I expected this to print &quot;This is B&quot; because c is Child(), and Child class's _AorB is of type B. return 0; } </code></pre>
[ { "answer_id": 74198251, "author": "Mark", "author_id": 2203038, "author_profile": "https://Stackoverflow.com/users/2203038", "pm_score": 1, "selected": false, "text": "import copy\n\ndef findThreeLargestNumbers(array):\n # Write your code here.\n org_array2=copy.deepcopy(array)\n\...
2022/10/25
[ "https://Stackoverflow.com/questions/74198046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008636/" ]
74,198,061
<p>My task is creating a function that can find a score for different DataFrame objects that are passed into it, i settled on using if else statements to attempt to make a score, but i keep running into ValueError exceptions.</p> <p>My data is all contained in dataframes as i collected it from csv files and performed analysis on them, will be using generic data for the purposes of the question here since i can't use the actual data for contract reasons.</p> <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame(np.random.randint(0,1000,size=(1000))) </code></pre> <p>just using a generic random generated data frame just to see if i can make the idea work</p> <pre class="lang-py prettyprint-override"><code>def generic_function_name(self): score=0 if ((df&gt; 700) and (DF&gt;500) and (DF&gt;300)== True): score += 3 if ((df&gt;500) and (df&gt;300) ==True): score+=2 if ((df&gt;300)== True): score += 1 if ((df&gt;300) ==False): score +=0 print(score) return </code></pre> <p>this is the function I've created, but I keep getting the following exception:</p> <pre><code>ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). </code></pre> <p>I'm sure someone much more competent than me will probably be horrified at my creation but I would please beg that you keep the laughter to a minimum while you explain just how wrong I am.</p> <pre><code>edits </code></pre> <p>Ok so following someof your suggestions i made changes to the function</p> <pre><code>def generic_function_name(self): score=0 if ((df&gt; 700)) : score += 3 if ((df&gt;500)): score+=2 if ((df&gt;300)): score += 1 if ((df&lt;300)): score +=0 print(score) return </code></pre> <p>then whed i do generic_function_name(df) it returns</p> <pre><code>ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). </code></pre> <p>so the problem is still their</p> <pre><code>df.head(20) 0 0 822 1 484 2 471 3 866 4 883 5 578 6 986 7 133 8 801 9 126 10 415 11 777 12 956 13 2 14 273 15 281 16 741 17 999 18 699 19 367 </code></pre> <p>i have been informed im doing too many comparisons, and i feel i need to say that the events which this is a data is a generic version of have higher values which are equivalent to high danger that i need to look out for, and the middle and lower thresholds are meant to be equivalent to middle to low danger, which is why i had so many comparisons, since i want the score to include low to high dangers in the results, just was weighting the higher danger worth more to the score then the lower dangers.</p> <p>if thier is an easier way please help me understand as i struggle with understanding how to create this score anyother way.</p>
[ { "answer_id": 74198251, "author": "Mark", "author_id": 2203038, "author_profile": "https://Stackoverflow.com/users/2203038", "pm_score": 1, "selected": false, "text": "import copy\n\ndef findThreeLargestNumbers(array):\n # Write your code here.\n org_array2=copy.deepcopy(array)\n\...
2022/10/25
[ "https://Stackoverflow.com/questions/74198061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19437673/" ]
74,198,082
<p>We have the following data</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th>Col. B</th> <th>Col. C</th> </tr> </thead> <tbody> <tr> <td>3</td> <td>noun</td> <td>spring</td> </tr> <tr> <td>4</td> <td>ver.</td> <td>spring</td> </tr> <tr> <td>5</td> <td>ver.</td> <td>spring</td> </tr> </tbody> </table> </div> <p>We need rows 4 and 5 (both columns <code>B</code> and <code>C</code>) to turn red because they are duplicates</p> <p>We have tried</p> <p><code>=(COUNTIF(B$3:B377,B3)&gt;1)*(COUNTIF(C$3:C377,C3)&gt;1) </code></p> <p><code>=AND((COUNTIF(B$3:B377,B3)&gt;1),(COUNTIF(C$3:C377,C3)&gt;1)) </code></p> <p><code>=COUNTIF(B$3:B377&amp;C$3:C377,B3&amp;C3)&gt;1</code></p> <p>but cannot make it work.</p> <p>Using <code> =COUNTIFS(B$3:B377,B3,C$3:C377,C3)&gt;1</code> works for just column <code>B</code></p>
[ { "answer_id": 74198251, "author": "Mark", "author_id": 2203038, "author_profile": "https://Stackoverflow.com/users/2203038", "pm_score": 1, "selected": false, "text": "import copy\n\ndef findThreeLargestNumbers(array):\n # Write your code here.\n org_array2=copy.deepcopy(array)\n\...
2022/10/25
[ "https://Stackoverflow.com/questions/74198082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15425623/" ]
74,198,098
<p>I have a ts object</p> <pre><code>TorontoTempts &lt;- ts(tempToronto$AvgTemperature, start=c(2015, 1), frequency=12) </code></pre> <p>I want to split it to train and test using subset:</p> <pre><code>train.ts &lt;- subset(TorontoTempts, start = 1, end = 176) testing.ts &lt;- subset(TorontoTempts, start = 177, end = 200) </code></pre> <p>I did get the following error:</p> <pre><code>argument &quot;subset&quot; is missing, with no default </code></pre> <p>If works with the following code:</p> <pre><code>train.ts &lt;- subset(TorontoTempts, subset=TRUE, start = 1, end = 176) testing.ts &lt;- subset(TorontoTempts,subset=TRUE, start = 177, end = 200) </code></pre> <p>However, when I want to pass it to tslm:</p> <pre><code>regModel &lt;- tslm(train.ts ~ trend + season) </code></pre> <p>I receive the following error:</p> <pre><code>Error in tslm(train.ts ~ trend + season) : Not time series data, use lm() </code></pre>
[ { "answer_id": 74198627, "author": "G. Grothendieck", "author_id": 516548, "author_profile": "https://Stackoverflow.com/users/516548", "pm_score": 2, "selected": false, "text": "subset" }, { "answer_id": 74198957, "author": "Ric Villalba", "author_id": 6912817, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74198098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3425989/" ]
74,198,111
<p>I am trying to visualize my longtudinal data by graphs using <code>ggplot</code> through <code>for</code> loop.</p> <pre><code>for(i in colnames(dat_longC)[c(3,5:10,14,17:19,30:39)]){ print(ggplot(dat_longC, aes(x = exam, y = i, group = zz_nr))+ geom_point()+ geom_line() + xlab(&quot;Examination&quot;) + ylab(i))} } </code></pre> <p>when I use the <code>ggplot</code> command in a <code>for</code> loop, I only get a line extending between examination times. If I use the same command on a single variable, it works and gives me trajectory graphs. What do you think could be the problem?</p>
[ { "answer_id": 74198220, "author": "AndS.", "author_id": 9778513, "author_profile": "https://Stackoverflow.com/users/9778513", "pm_score": 1, "selected": false, "text": "i" }, { "answer_id": 74212715, "author": "Nuhash", "author_id": 18173625, "author_profile": "https...
2022/10/25
[ "https://Stackoverflow.com/questions/74198111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18173625/" ]
74,198,159
<p>I have downloaded sample <code>css</code> file: <a href="https://github.com/lwindolf/liferea/blob/master/css/liferea.css" rel="nofollow noreferrer">https://github.com/lwindolf/liferea/blob/master/css/liferea.css</a></p> <p>and I am trying to change the font size of:</p> <ol> <li>the feed name in the left pane (feed list)</li> <li>the headline in the top right pane (headline)</li> </ol> <p>see red markings on attached screenshot: <a href="https://i.stack.imgur.com/fC7WP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fC7WP.jpg" alt="enter image description here" /></a></p> <p>so far, all changes I have tried in <code>liferea.css</code> only affect the bottom right pane, which displays the actual page content</p> <p>How can I change the text size in liferea of the feed list, and the headline?</p> <p>I have found similar questions on the liferea mailing list, but they only point to editing the <code>liferea.css</code> file, without explaining which property has to be changed:</p> <p><a href="https://sourceforge.net/p/liferea/mailman/message/31652848/" rel="nofollow noreferrer">https://sourceforge.net/p/liferea/mailman/message/31652848/</a></p> <p>I am using <code>liferea 1.12.6</code> on Debian 10.</p>
[ { "answer_id": 74220060, "author": "ZombieChowder", "author_id": 5894918, "author_profile": "https://Stackoverflow.com/users/5894918", "pm_score": 0, "selected": false, "text": "table.itemhead * a.itemhead {\n text-decoration:none;\n color:#GTK-COLOR-TEXT;\n font-weight:bold;\n ...
2022/10/25
[ "https://Stackoverflow.com/questions/74198159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7287412/" ]
74,198,179
<p>I Have a scenario in which I am reading some data from a database. This data is returned in the form of <code>IAsyncEnumerable&lt;MyData&gt;</code>. After reading the data I want to send it to a consumer. This consumer is asynchronous. Right now my code looks something like this:</p> <pre class="lang-cs prettyprint-override"><code>// C# IAsyncEnumerable&lt;MyData&gt; enumerable = this.dataSource.Read(query); await foreach (var data in enumerable) { await this.consumer.Write(data); } </code></pre> <p>My problem with this is that while I am enumerating the database, I am holding a lock on the data. I don't want to hold this lock for longer than I need to.</p> <p>In the event that the consumer is consuming data slower than the producer is producing it, is there any way I can eagerly read from the datasource without just calling <code>ToList</code> or <code>ToListAsync</code>. I want to avoid reading all the data into memory at once, which would cause the opposite problem if now the producer is slower than the consumer. It is ok if the lock on the database is not as short as possible, I want a configurable tradeoff between how much data is in memory at once, and how long we keep the enumeration running.</p> <p>My thought is that there would be some way to use a queue or channel-like datastructure to act as a buffer between the producer and consumer.</p> <p>In Golang I would do something like this:</p> <pre class="lang-golang prettyprint-override"><code>// go queue := make(chan MyData, BUFFER_SIZE) go dataSource.Read(query, queue) // Read sends data on the channel, closes it when done for data := range queue { consumer.Write(data) } </code></pre> <p>Is there any way to get similar behavior in C#?</p>
[ { "answer_id": 74199747, "author": "Rafael", "author_id": 9723960, "author_profile": "https://Stackoverflow.com/users/9723960", "pm_score": 0, "selected": false, "text": "BlockingCollection<T>" }, { "answer_id": 74201074, "author": "Theodor Zoulias", "author_id": 11178549...
2022/10/25
[ "https://Stackoverflow.com/questions/74198179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9723960/" ]
74,198,234
<p>In macOS ventura I cannot duplicate my terminal app.</p> <p>I want to do this as I have a M1 processor and I want to have one that opens using Rosetta2 and one that opens natively.</p> <p>Any ideas how to get around this?</p>
[ { "answer_id": 74531940, "author": "julianobrasil", "author_id": 6433166, "author_profile": "https://Stackoverflow.com/users/6433166", "pm_score": 1, "selected": false, "text": "~/.zshrc" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74198234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7512228/" ]
74,198,246
<p>Hi I'm very new to both the forum and python writing language. There is something I would like to ask you, dear group members and masters, and I hope I can express it correctly.</p> <pre><code># LOAD BARS 5m bars = exchange.fetch_ohlcv(symbol, timeframe=&quot;5m&quot;, since = None, limit = 100) df = pd.DataFrame(bars, columns=[&quot;timestamp&quot;, &quot;open&quot;, &quot;high&quot;, &quot;low&quot;, &quot;close&quot;, &quot;volume&quot;]) </code></pre> <p>in a dataset (100 rows) expressed in the figure above;</p> <ul> <li>the smallest value in the last 3 data?</li> <li>the smallest value in the last 50 data? within the last 50 data - excluding the most recent data</li> <li>the smallest value? in the last 50 data - excluding the 2 most recent data</li> <li>the smallest value? the smallest value in the last 50 data - excluding the 3 most recent data?</li> </ul> <p>How can it be written in python???</p>
[ { "answer_id": 74531940, "author": "julianobrasil", "author_id": 6433166, "author_profile": "https://Stackoverflow.com/users/6433166", "pm_score": 1, "selected": false, "text": "~/.zshrc" } ]
2022/10/25
[ "https://Stackoverflow.com/questions/74198246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332916/" ]
74,198,248
<p>How could I extract only alphabets of this column not considering characters after number? Also, there are situations where there are no numbers. In this case, is it possible to create a condition using CASE and WHEN to apply extraction condition only in cases where there are numbers?</p> <p>Input:</p> <pre><code>medication_title GLYXAMBI 25 MG E 5 MG GLIFAGE XR 750 MG AD TIL SIMETICON GOTAS </code></pre> <p>Output:</p> <pre><code>medication_title | medication_commercialname GLYXAMBI 25 MG E 5 MG GLYXAMBI GLIFAGE XR 750 MG GLIFAGE XR AD TIL AD TIL SIMETICON GOTAS SIMETICON GOTAS </code></pre> <p>Thanks!</p>
[ { "answer_id": 74198374, "author": "Luuk", "author_id": 724039, "author_profile": "https://Stackoverflow.com/users/724039", "pm_score": 1, "selected": false, "text": "SELECT rtrim(substring(medication_title from '[A-Z ]*')) FROM tablename:\n" }, { "answer_id": 74198489, "auth...
2022/10/25
[ "https://Stackoverflow.com/questions/74198248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18609422/" ]
74,198,255
<p>I have a dataframe that looks something like this:</p> <pre><code>df = pd.DataFrame([1,'A','X','1/3/22 12:00:00AM','1/1/22 12:00:00 AM','1/2/22 12:00:00 AM'], [1,'A','X','1/4/22 12:00:00AM','1/3/22 12:00:00 AM','1/3/22 12:00:00 AM'], [1,'A','Y','1/3/22 12:00:00AM','1/2/22 12:00:00 AM','1/1/22 12:00:00 AM'], [1,'B','X','1/3/22 12:00:00AM','1/2/22 12:00:00 AM','1/3/22 12:00:00 AM'], [2,'A','X','1/5/22 12:00:00AM','1/3/22 12:00:00 AM','1/4/22 12:00:00 AM'], [2,'A','X','1/6/22 12:00:00AM','1/4/22 12:00:00 AM','1/5/22 12:00:00 AM']], columns = ['ID','Category','Site','Task Completed','Access Completed', 'Upload Completed']) </code></pre> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Category</th> <th>Site</th> <th>Task Completed</th> <th>Access Completed</th> <th>Upload Completed</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>A</td> <td>X</td> <td>1/3/22 12:00:00AM</td> <td>1/1/22 12:00:00 AM</td> <td>1/2/22 12:00:00 AM</td> </tr> <tr> <td>1</td> <td>A</td> <td>X</td> <td>1/4/22 12:00:00AM</td> <td>1/3/22 12:00:00 AM</td> <td>1/3/22 12:00:00 AM</td> </tr> <tr> <td>1</td> <td>A</td> <td>Y</td> <td>1/3/22 12:00:00AM</td> <td>1/2/22 12:00:00 AM</td> <td>1/1/22 12:00:00 AM</td> </tr> <tr> <td>1</td> <td>B</td> <td>X</td> <td>1/3/22 12:00:00AM</td> <td>1/2/22 12:00:00 AM</td> <td>1/3/22 12:00:00 AM</td> </tr> <tr> <td>2</td> <td>A</td> <td>X</td> <td>1/5/22 12:00:00AM</td> <td>1/3/22 12:00:00 AM</td> <td>1/4/22 12:00:00 AM</td> </tr> <tr> <td>2</td> <td>A</td> <td>X</td> <td>1/6/22 12:00:00AM</td> <td>1/4/22 12:00:00 AM</td> <td>1/5/22 12:00:00 AM</td> </tr> </tbody> </table> </div> <p>What I want to find is the time difference (in hours) between the later of <strong>max</strong> access completed date or <strong>min</strong> upload completed date and the first Task Completed date for every ID/Category/Site combination within the dataset.</p> <p>In plain text, the logic is (the later date of (max access completed date vs min upload completed date)) - (min/first task completed date).</p> <p>Based on this dataset, my intended result would look like:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Category</th> <th>Site</th> <th>Time Difference</th> <th>First Task Completed</th> <th>Max Access Date</th> <th>Min Upload Date</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>A</td> <td>X</td> <td>0</td> <td>1/3/22 12:00:00AM</td> <td>1/3/22 12:00:00 AM</td> <td>1/2/22 12:00:00 AM</td> </tr> <tr> <td>1</td> <td>A</td> <td>Y</td> <td>24</td> <td>1/3/22 12:00:00AM</td> <td>1/2/22 12:00:00 AM</td> <td>1/1/22 12:00:00 AM</td> </tr> <tr> <td>1</td> <td>B</td> <td>X</td> <td>0</td> <td>1/3/22 12:00:00AM</td> <td>1/2/22 12:00:00 AM</td> <td>1/3/22 12:00:00 AM</td> </tr> <tr> <td>2</td> <td>A</td> <td>X</td> <td>24</td> <td>1/5/22 12:00:00AM</td> <td>1/4/22 12:00:00 AM</td> <td>1/4/22 12:00:00 AM</td> </tr> </tbody> </table> </div> <p>I know how to get the max access date minus the first task completed date:</p> <pre><code>out = (df .groupby(['ID', 'Category', 'Site'], as_index=False) .agg({'Task Completed': 'first', 'Access Completed': 'max'}) .assign(**{'Time Difference': lambda d: d['Task Completed'] .sub(d['Access Completed']) .dt.total_seconds().floordiv(3600)}) ) </code></pre> <p>Which has output:</p> <pre><code> ID Category Site Task Completed Access Completed Time Difference 0 1 A X 2022-01-03 00:00:00 2022-01-02 24.0 1 1 A Y 2022-01-01 01:00:00 2022-01-01 1.0 2 1 B X 2022-01-01 01:00:00 2022-01-01 1.0 3 2 A X 2022-01-03 00:00:00 2022-01-02 24.0 </code></pre> <p>But I don't know how to incorporate min upload completed date.</p>
[ { "answer_id": 74198981, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "df[\"Task Completed\"] = pd.to_datetime(\n df[\"Task Completed\"], format=\"%m/%d/%y %H:%M:%S%p\"\n)\ndf[\...
2022/10/25
[ "https://Stackoverflow.com/questions/74198255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12309258/" ]
74,198,265
<p>I need to calculate cumulative calculations (sum,mean,median,etc) based on the values of Indicator</p> <p>It should do the calculations for all the false indicator and print it adjacent to the true. then calculated value should reset and start from true until true appears again for Indicator.</p> <p>Input data frame</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Amount</th> <th>Indicator</th> </tr> </thead> <tbody> <tr> <td>10</td> <td>False</td> </tr> <tr> <td>20</td> <td>False</td> </tr> <tr> <td>5</td> <td>True</td> </tr> <tr> <td>8</td> <td>False</td> </tr> <tr> <td>4</td> <td>False</td> </tr> <tr> <td>6</td> <td>True</td> </tr> </tbody> </table> </div> <p>output would be</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Amount</th> <th>Indicator</th> <th>Sum</th> <th>Mean</th> </tr> </thead> <tbody> <tr> <td>10</td> <td>False</td> <td></td> <td></td> </tr> <tr> <td>20</td> <td>False</td> <td></td> <td></td> </tr> <tr> <td>5</td> <td>True</td> <td>30</td> <td>15</td> </tr> <tr> <td>8</td> <td>False</td> <td></td> <td></td> </tr> <tr> <td>4</td> <td>False</td> <td></td> <td></td> </tr> <tr> <td>6</td> <td>True</td> <td>17</td> <td>5.6</td> </tr> </tbody> </table> </div> <p>I tried to use groupby with cumsum() using Indicator as group , but have not had any luck yet.</p>
[ { "answer_id": 74198981, "author": "Andrej Kesely", "author_id": 10035985, "author_profile": "https://Stackoverflow.com/users/10035985", "pm_score": 3, "selected": true, "text": "df[\"Task Completed\"] = pd.to_datetime(\n df[\"Task Completed\"], format=\"%m/%d/%y %H:%M:%S%p\"\n)\ndf[\...
2022/10/25
[ "https://Stackoverflow.com/questions/74198265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4553150/" ]
74,198,275
<p>So, there is a problem when i start include my dependencies in DI container. I have a data access library of my database. And when i try to add this in DI container it fails in app.build statement with 3 exceptions related to the same errors. Exceptions:</p> <blockquote> <p>! System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: DAL.Repos.Interfaces.ICarRepo Lifetime: Scoped ImplementationType: DAL.Repos.CarRepo': Unable to activate type 'DAL.Repos.CarRepo'. The following constructors are ambiguous: Void .ctor(DAL.EfMainStructures.ApplicationContext) Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[DAL.EfMainStructures.ApplicationContext]))</p> </blockquote> <blockquote> <p>! System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: DAL.Repos.Interfaces.ICarRepo Lifetime: Scoped ImplementationType: DAL.Repos.CarRepo': Unable to activate type 'DAL.Repos.CarRepo'. The following constructors are ambiguous: Void .ctor(DAL.EfMainStructures.ApplicationContext) Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[DAL.EfMainStructures.ApplicationContext])</p> </blockquote> <blockquote> <p>! System.InvalidOperationException: Unable to activate type 'DAL.Repos.CarRepo'. The following constructors are ambiguous: Void .ctor(DAL.EfMainStructures.ApplicationContext) Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[DAL.EfMainStructures.ApplicationContext])</p> </blockquote> <p>All of them are related to constructors ambiguous, but i can't understand what it means. This my Program.cs code</p> <pre><code>var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllersWithViews(); // Add services to the container. var connectionString = builder.Configuration.GetConnectionString(&quot;Default&quot;); builder.Services.AddDbContextPool&lt;ApplicationContext&gt;(options =&gt; options.UseNpgsql(connectionString,sqlOp =&gt; sqlOp.EnableRetryOnFailure())); builder.Services.AddScoped&lt;ICarRepo,CarRepo&gt;(); /*builder.Services.AddScoped&lt;ICustomerRepo,CustomerRepo&gt;(); builder.Services.AddScoped&lt;ICreditRiskRepo,CreditRiskRepo&gt;(); builder.Services.AddScoped&lt;IMakeRepo,MakeRepo&gt;(); builder.Services.AddScoped&lt;IOrderRepo,OrderRepo&gt;();*/ /*builder.Services.AddScoped(typeof(IAppLogging&lt;&gt;),typeof(AppLogging&lt;&gt;)); builder.Host.ConfigureSerilog();*/ var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler(&quot;/Home/Error&quot;); if (app.Configuration.GetValue&lt;bool&gt;(&quot;RebuildDataBase&quot;)) { var context = new DatabaseContextFactory().CreateDbContext(new string[1]); SampleDataInitializer.InitializeData(context); } // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.MapControllerRoute( name: &quot;default&quot;, pattern: &quot;{controller=Home}/{action=Index}/{id?}&quot;); app.Run(); </code></pre> <p>This my ApplicationContext code</p> <pre><code>public partial class ApplicationContext : DbContext { public ApplicationContext(DbContextOptions&lt;ApplicationContext&gt; options) : base(options) { } public virtual DbSet&lt;CreditRisk&gt;? CreditRisks { get; set; } public virtual DbSet&lt;Customer&gt;? Customers { get; set; } public virtual DbSet&lt;Make&gt;? Makes { get; set; } public virtual DbSet&lt;Car&gt;? Cars { get; set; } public virtual DbSet&lt;Order&gt;? Orders { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); } </code></pre> <p>This GitHub repository: <a href="https://github.com/DIDIVERG/Train" rel="nofollow noreferrer">https://github.com/DIDIVERG/Train</a> (There considered MVC project)</p> <p>It has to add my interfaces with their implementations to DI container, but it doesn't and throws exceptions described above. I'm sorry if this question is hackneyed.</p>
[ { "answer_id": 74198723, "author": "Neil W", "author_id": 2936204, "author_profile": "https://Stackoverflow.com/users/2936204", "pm_score": 1, "selected": true, "text": "public CarRepo(ApplicationContext context)\n{\n}\n\npublic CarRepo(DbContextOptions<ApplicationContext> options)\n{\n}...
2022/10/25
[ "https://Stackoverflow.com/questions/74198275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332185/" ]
74,198,282
<p>I created a program that retrieves every single line from a txt file (Numbers and text written inside) one by one, filtering it based around if it's an int or specific string. If it's an int,I use it with a function from Pyauogui(An automation library that controls keyboard and mouse) that makes it click a position on the screen (The int being used as coordinates) and if it's a string I make it do other stuff, I am sure that the code I put in the first 2 if statements does not cause any problems since I tested it with the exact code written below and it still seemed to give me the same error.</p> <p>When I run the code below, It get's the first coordinate perfectly fine, clicks at the correct location. Then the second line it gives me the &quot;ValueError: invalid literal for int() with base 10:&quot; error.</p> <pre><code>with open('file.txt', 'r') as coords: # Check if the line in the coordinates.txt is a valid coordinate or a string # Enumarate the coordinates.txt line by line (implemented from deneme.py) line = str(coords.readline()) cnt = 1 while line: if &quot;[mail]&quot; in line: #do stuff print('true') if &quot;[sifre]&quot; in line: #do other stuff print(&quot;also true&quot;) else: coordinates = str(line) coordinates = coordinates.strip(',()') xcoords = coordinates[0:3] ycoords = coordinates[4:8] xcoords = int(xcoords) ycoords = int(ycoords) pyautogui.click(x=xcoords,y=ycoords) time.sleep(2) </code></pre> <p>file.txt looks like this:</p> <pre><code> (294, 128) [mail] (294, 145) [sifre] (294, 200) </code></pre> <p>It get's the first line correctly, clicks at the location and then it just stops and gives me the error.</p> <p>I have tried removing the [mail] and [sifre] from file.txt using the same code as before and that made it work for reason.</p> <p>My purpose for writing this code was to get the first line from the text file, determine if it's a string or an int then operate based on that and go to the next line and do it again until it goes through the whole text file.</p> <p>Please help.</p>
[ { "answer_id": 74198560, "author": "NoDakker", "author_id": 6032177, "author_profile": "https://Stackoverflow.com/users/6032177", "pm_score": 0, "selected": false, "text": "with open('file.txt', 'r') as coords:\n # Check if the line in the coordinates.txt is a valid coordinate or a st...
2022/10/25
[ "https://Stackoverflow.com/questions/74198282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20234338/" ]
74,198,292
<p>Let's say I have a <code>timeInterval</code> parameter that's a <code>std::chrono::duration</code>, but of a non-predetermined unit size - sometimes it'll be <code>std::chrono::seconds</code>, sometimes <code>std::chrono:milliseconds</code>, who knows.</p> <p>Let's say I have a <code>float DamagePerSecond</code> - to calculate the damage done over the time interval, I need to calculate the floating point value of the <code>timeInterval</code> in seconds, and just multiply them.</p> <p>From a lot of Googling, viewing tutorials on YouTube, and viewing solutions on here, it seems that <code>.count()</code> gives whole number of seconds.</p> <p>Ultimately, I just want to find:</p> <pre class="lang-cpp prettyprint-override"><code>float totalDamage = DamagePerSecond * timeIntervalInSeconds; </code></pre> <p>This seems really frustratingly hard, and it's baffling that I haven't yet seen this covered after a good hour of looking through YouTube/Googling.</p> <pre class="lang-cpp prettyprint-override"><code>auto testX = std::chrono::milliseconds(5); auto duration_s = std::chrono::duration_cast&lt;std::chrono::seconds&gt;(testX); Log(L&quot;%f\n&quot; duration_s.count()); // This just prints out 0.00000, probably because type mismatch Log(L&quot;%i\n&quot; duration_s.count()); // This just prints out 0, because there's not a whole number second yet </code></pre> <p>I tried to follow the solution here:</p> <p><a href="https://stackoverflow.com/questions/57538507/">How to convert std::chrono::duration to double (seconds)?</a></p> <pre class="lang-cpp prettyprint-override"><code>auto testX = std::chrono::milliseconds(5); float converted = std::chrono:duration&lt;double&gt;(testX).count(); Log(L&quot;%f\n&quot;, converted); </code></pre> <p>But this yields the following errors:</p> <pre class="lang-none prettyprint-override"><code>error C2882: 'chrono': illegal use of namespace identifier in expression error C2143: syntax error: missing ';' before ':' error C2059: syntax error: ':' </code></pre>
[ { "answer_id": 74198428, "author": "Pepijn Kramer", "author_id": 16649550, "author_profile": "https://Stackoverflow.com/users/16649550", "pm_score": 1, "selected": false, "text": "#include <chrono>\n#include <iostream>\n\nusing namespace std::chrono_literals;\n\nint main()\n{\n auto d...
2022/10/25
[ "https://Stackoverflow.com/questions/74198292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20327310/" ]
74,198,333
<p>I need to hold button (&quot;A&quot;) for few seconds. I tried lots of libs and methods, but nothing not works. Every exemples what I tried was identical(&quot;A&quot; pressed by one time, dont hold)</p> <p>This is my code:</p> <pre><code>import pyautogui as pag import time pag.keyDown(&quot;a&quot;) time.sleep(10) pag.keyUp(&quot;a&quot;) </code></pre> <p>But it does not work. &quot;A&quot; pressed only one time, but i need to hold it. I need not just one &quot;A&quot;, but something like this: &quot;AAAAAAAAAAAAAAAAAAAA&quot;</p> <p>Please help me anyone</p>
[ { "answer_id": 74198428, "author": "Pepijn Kramer", "author_id": 16649550, "author_profile": "https://Stackoverflow.com/users/16649550", "pm_score": 1, "selected": false, "text": "#include <chrono>\n#include <iostream>\n\nusing namespace std::chrono_literals;\n\nint main()\n{\n auto d...
2022/10/25
[ "https://Stackoverflow.com/questions/74198333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18692262/" ]
74,198,359
<p>I have a problem where I have a large number (~10,000) points (in 2-D) from which I need to repeatedly pick a small number (~100) and construct a Voronoi diagram.</p> <p>I can pre-compute the Voronoi diagram / Delaunay mesh for the 10000 points which always remain the same. Is there then a way to efficiently compute the Voronoi diagram for a small subset of these points? Or do I need to start from scratch every time?</p> <p>Many thanks!</p>
[ { "answer_id": 74198428, "author": "Pepijn Kramer", "author_id": 16649550, "author_profile": "https://Stackoverflow.com/users/16649550", "pm_score": 1, "selected": false, "text": "#include <chrono>\n#include <iostream>\n\nusing namespace std::chrono_literals;\n\nint main()\n{\n auto d...
2022/10/25
[ "https://Stackoverflow.com/questions/74198359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332991/" ]
74,198,362
<p>I want to create hyperlink in order to open new window. Is it possible to make hyperlink to open new window in tkinter? And if it's possible, how to create it? Below this are my codes.</p> <pre><code>guidelines = Label(self, text=&quot;You can check the guidelines here&quot;, fg=&quot;blue&quot;, cursor=&quot;hand2&quot;) guidelines.place(x=400,y=250) guidelines.bind(&quot;&lt;Button-1&gt;&quot;, lambda e: callback()) </code></pre> <p>Actually I've searched create hyperlink, but it's only for opening a web page. And there are no references to open new window in tkinter</p>
[ { "answer_id": 74198488, "author": "Ovski", "author_id": 8610346, "author_profile": "https://Stackoverflow.com/users/8610346", "pm_score": 2, "selected": true, "text": "import tkinter as tk\n\n\ndef show_guide_lines(root):\n window_guide_lines = tk.Toplevel(root)\n window_guide_lin...
2022/10/25
[ "https://Stackoverflow.com/questions/74198362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15504678/" ]
74,198,368
<p>I'm trying to add a circular profile picture to my react-bootstrap nav bar.</p> <p>Similar to this:</p> <p><a href="https://i.stack.imgur.com/56yGw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/56yGw.png" alt="enter image description here" /></a></p> <p>But I'm not sure where to add the div for the circular image.</p> <p>Here is my navbar code:</p> <pre><code>import { Link } from &quot;react-router-dom&quot;; import NavDropdown from 'react-bootstrap/NavDropdown'; import { Navbar, Nav, Container } from 'react-bootstrap'; const NavBar = (props) =&gt; { const user = 'Petrina.C' return ( &lt;&gt; &lt;Navbar expand=&quot;lg&quot;&gt; &lt;Container style={{maxWidth:'100%'}}&gt; &lt;Navbar.Brand href=&quot;#home&quot;&gt;Voter Outreach&lt;/Navbar.Brand&gt; &lt;Navbar.Toggle aria-controls=&quot;basic-navbar-nav&quot; /&gt; &lt;Navbar.Collapse id=&quot;basic-navbar-nav&quot;&gt; &lt;Nav className=&quot;me-auto&quot; id=&quot;navLinks&quot;&gt; &lt;Nav.Link href=&quot;/&quot;&gt;Home&lt;/Nav.Link&gt; &lt;Nav.Link href=&quot;/voters&quot;&gt;Voters&lt;/Nav.Link&gt; &lt;NavDropdown title={`${user}`} id=&quot;basic-nav-dropdown&quot;&gt; &lt;NavDropdown.Item href=&quot;#action/3.1&quot;&gt;Action&lt;/NavDropdown.Item&gt; &lt;NavDropdown.Item href=&quot;#action/3.2&quot;&gt; Another action &lt;/NavDropdown.Item&gt; &lt;NavDropdown.Item href=&quot;#action/3.3&quot;&gt;Something&lt;/NavDropdown.Item&gt; &lt;NavDropdown.Divider /&gt; &lt;NavDropdown.Item href=&quot;#action/3.4&quot;&gt; Separated link &lt;/NavDropdown.Item&gt; &lt;/NavDropdown&gt; &lt;/Nav&gt; &lt;/Navbar.Collapse&gt; &lt;/Container&gt; &lt;/Navbar&gt; {props.children} &lt;/&gt; ); } export default NavBar; </code></pre> <p>Any help is appreciated!</p>
[ { "answer_id": 74198488, "author": "Ovski", "author_id": 8610346, "author_profile": "https://Stackoverflow.com/users/8610346", "pm_score": 2, "selected": true, "text": "import tkinter as tk\n\n\ndef show_guide_lines(root):\n window_guide_lines = tk.Toplevel(root)\n window_guide_lin...
2022/10/25
[ "https://Stackoverflow.com/questions/74198368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19966841/" ]
74,198,375
<pre><code>#include &lt;stdio.h&gt; #define MAXLIMIT 1000 #define MINLIMIT 1 int main() {int number = 0, valid=0; do { printf(&quot;Player 1, enter a number between 1 and 1000:\n&quot;); scanf(&quot;%d&quot;, &amp;number); valid = number &gt;= MINLIMIT || number &lt;= MAXLIMIT; if (!valid) { printf(&quot;That number is out of range.\n&quot;); } } while (!valid); int guess = 0, chance = 10; // Allow player 2 to guess and check do { printf(&quot;Player 2, you have %d guesses remaining\n&quot;, chance); printf(&quot;Enter your guess:\n&quot;); scanf(&quot;%d&quot;, &amp;guess); if (guess &lt; number){ printf(&quot;Too low.\n&quot;); } else if (guess &gt; number) { printf(&quot;Too high.\n&quot;); } else if (guess == number){ printf(&quot;Player 2 wins.\n&quot;); } else if (guess != number &amp;&amp; chance == 0) printf(&quot;Player 1 wins.\n&quot;); } while (guess != number &amp;&amp; chance &gt; 0); } </code></pre> <p>This is currently my code. I'm stucked at the last where once the user has use up their 10 chances, Player 1 wins. Is there anyway for two while loop condition to happen?</p>
[ { "answer_id": 74198477, "author": "Vlad from Moscow", "author_id": 2877241, "author_profile": "https://Stackoverflow.com/users/2877241", "pm_score": 0, "selected": false, "text": "valid = number >= MINLIMIT || number <= MAXLIMIT;\n" }, { "answer_id": 74198534, "author": "pau...
2022/10/25
[ "https://Stackoverflow.com/questions/74198375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19965555/" ]
74,198,400
<p>having trouble when it trys comparing the input and the random integer</p> <pre><code>import random target = random.randint(1,100) counter = 0 print(target) print(int(input('Guess an integer between 1 and 100 '))) guess = input while guess != target(): if guess &gt; target(): print(&quot;Guess is to high&quot;) elif guess &lt; target(): print(&quot;Guess was to low&quot;) counter = counter + 1 print(int(input('Guess an integer between 1 and 100 '))) print(&quot;Correct it took you &quot; + str(counter) + &quot; guesses to get the correct number&quot;) </code></pre> <p>i tried changing the variable names starting from scratch several times googled tons of stuff but im lost and and confused and need an answer so please if you understand my problem id appreciate some advice</p>
[ { "answer_id": 74198512, "author": "Priya", "author_id": 10199456, "author_profile": "https://Stackoverflow.com/users/10199456", "pm_score": -1, "selected": false, "text": "import random\ntarget = random.randint(1,100)\ncounter = 0\nprint(target)\nguess = int(input('Guess an integer betw...
2022/10/25
[ "https://Stackoverflow.com/questions/74198400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332949/" ]
74,198,404
<p>I have a list of sentences and I am looking to extract contents between two items. If the start or end item does not exist, I want it to return a row with padding only. I already have the sentences tokenized and padded with 0 to a fixed length.</p> <p>I figured a way to do this using for loops, but it is extremely slow, so would like to know what is the best way to solve this, probably by using tensor operations.</p> <pre><code>import torch start_value, end_value = 4,9 data = torch.tensor([ [3,4,7,8,9,2,0,0,0,0], [1,5,3,4,7,2,8,9,10,0], [3,4,7,8,10,0,0,0,0,0], # does not contain end value [3,7,5,9,2,0,0,0,0,0], # does not contain start value ]) # expected output [ [7,8,0,0,0,0,0,0,0,0], [7,2,8,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], ] # or [ [0,0,7,8,0,0,0,0,0,0], [0,0,0,0,7,2,8,0,0,0], [0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0], ] </code></pre> <p>The current solution that I have, which uses a for loop. It does not produce a symmetric array like I want in the expected output.</p> <pre><code>def _get_part_from_tokens( self, data: torch.Tensor, s_id: int, e_id: int, ) -&gt; list[str]: input_ids = [] for row in data: try: s_index = (row == s_id).nonzero(as_tuple=True)[0][0] e_index = (row == e_id).nonzero(as_tuple=True)[0][0] except IndexError: input_ids.append(torch.tensor([])) continue if s_index is None or e_index is None or s_index &gt; e_index: input_ids.append(torch.tensor([])) continue ind = torch.arange(s_index + 1, e_index) input_ids.append(row.index_select(0, ind)) return input_ids </code></pre>
[ { "answer_id": 74198512, "author": "Priya", "author_id": 10199456, "author_profile": "https://Stackoverflow.com/users/10199456", "pm_score": -1, "selected": false, "text": "import random\ntarget = random.randint(1,100)\ncounter = 0\nprint(target)\nguess = int(input('Guess an integer betw...
2022/10/25
[ "https://Stackoverflow.com/questions/74198404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1888957/" ]
74,198,420
<p>I'm new to recursive methods. I am trying to create a simple JAVA program that creates a number of steps using this symbol |_ depending on the input. each recursion is supposed to print |_ then proceed to the next line and print |_ slightly further than the previous one creating a stair-like structure.</p> <pre><code> public static void main(String[] args) { makeStairs(4); // invoking the method } private static void makeStairs(int steps) { int numstp = 0; if (steps &gt; 0) { if (numstp != steps) { makeStairs(steps - 1); System.out.printf(&quot;|_\n&quot;); } } } </code></pre> <p>the output that I'm looking for:</p> <pre><code>|_ |_ |_ |_ </code></pre> <p>the output I have:</p> <pre><code>|_ |_ |_ |_ </code></pre> <p>Help would be highly appreciated.</p>
[ { "answer_id": 74198512, "author": "Priya", "author_id": 10199456, "author_profile": "https://Stackoverflow.com/users/10199456", "pm_score": -1, "selected": false, "text": "import random\ntarget = random.randint(1,100)\ncounter = 0\nprint(target)\nguess = int(input('Guess an integer betw...
2022/10/25
[ "https://Stackoverflow.com/questions/74198420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20201440/" ]
74,198,438
<p>I wanted to write a little calculator, which I have already done by using <code>cout</code> and <code>cin</code>, and I used <code>double</code> instead of <code>int</code> to not only get integers as an output.</p> <p>At school, I then saw that we're going to use <code>printf()</code> and <code>scanf()</code>. To practice the new commands, I wanted to rewrite my program, but when I run my program I only see a lot of zeros after the comma as an output. Does anybody know why?</p> <p>I wanted to rebuild a calculator with <code>double</code> instead of <code>int</code> to not only get integers as a result.</p> <p>This is the code:</p> <pre><code>#include &lt;stdio.h&gt; using namespace std; int main(){ printf (&quot;Taschenrechner\n\n&quot;); int zahl1, zahl2; char rechop; double erg; printf (&quot;Gib die Rechnung ein: &quot;); scanf (&quot;%d&quot;, &amp;zahl1); scanf (&quot;%c&quot;, &amp;rechop); scanf (&quot;%d&quot;, &amp;zahl2); if (rechop == '+'){ erg = zahl1+ zahl2; printf (&quot;Ergebnis: &quot;); printf (&quot;%f&quot;, erg); } else if (rechop == '-'){ erg = zahl1 - zahl2; printf (&quot;Ergebnis: &quot;); printf (&quot;%f&quot;, erg); } else if (rechop == '*'){ erg = zahl1 * zahl2; printf (&quot;Ergebnis: &quot;); printf (&quot;%f&quot;, erg); } else if (rechop == '/'){ erg = zahl1 / zahl2; printf (&quot;Ergebnis: &quot;); printf (&quot;%f&quot;, erg); } else { printf (&quot;Keine gültige Rechenoperation!&quot;); } return 0; } </code></pre>
[ { "answer_id": 74198512, "author": "Priya", "author_id": 10199456, "author_profile": "https://Stackoverflow.com/users/10199456", "pm_score": -1, "selected": false, "text": "import random\ntarget = random.randint(1,100)\ncounter = 0\nprint(target)\nguess = int(input('Guess an integer betw...
2022/10/25
[ "https://Stackoverflow.com/questions/74198438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332988/" ]
74,198,472
<p>I need to serialize a class in a custom inspector (using visually the Editor) like as doing in a Monobehaviour script like this:</p> <pre><code>[System.Serializable] public class CustomClass { int myInt } </code></pre> <pre><code>public class OtherClass : MonoBehaviour { [SerializeField] CustomClass customClass; } </code></pre> <p>which gives this result: <a href="https://i.stack.imgur.com/P81LE.png" rel="nofollow noreferrer">result wanted and given using the code above, where DamageEffect = CustomClass and Damage = myInt</a></p> <p>In my custom editor, I'd like something like this:</p> <pre><code> [CustomEditor(typeof(CardObject))] class AnotherClassEditor : Editor { public override void OnInspectorGUI() { [SerializeField] CustomClass customclass; } } </code></pre> <p>but, as expected, it points out an error.</p> <p>I also tried with <code>EditorGUILayout.ObjectField()</code> but I haven't been able to, I'm not so experienced so please try to keep the answers simple.</p> <p>Actually, I need this serialization to happen only when an enum is equal to a certain value, the overall script is something like this:</p> <pre><code>using System.Collections.Generic; using UnityEngine; #if UNITY_EDITOR using UnityEditor; #endif [CreateAssetMenu(fileName = &quot;Card&quot;, menuName = &quot;CardObject&quot;)] public class CardObject : ScriptableObject { public List&lt;CardEffectType&gt; effectsTypes; //other... [HideInInspector] public List&lt;CardEffect&gt; effects; //other... } #if UNITY_EDITOR [CustomEditor(typeof(CardObject))] class CardObjectEditor : Editor { public override void OnInspectorGUI() { base.OnInspectorGUI(); CardObject cardObject = (CardObject)target; foreach(CardEffectType effectType in cardObject.effectsTypes) { switch (effectType) { case CardEffectType.DamageEffect: { //!!! } } } } } #endif public enum CardEffectType { DamageEffect, //other... } </code></pre> <p>I found some workarounds but the result is not as when a class is serialized in a Monobehaviour.</p>
[ { "answer_id": 74198512, "author": "Priya", "author_id": 10199456, "author_profile": "https://Stackoverflow.com/users/10199456", "pm_score": -1, "selected": false, "text": "import random\ntarget = random.randint(1,100)\ncounter = 0\nprint(target)\nguess = int(input('Guess an integer betw...
2022/10/25
[ "https://Stackoverflow.com/questions/74198472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332970/" ]
74,198,538
<p>what are firebase lock mode and test mode my android app is already on google play <a href="https://i.stack.imgur.com/ASdBF.png" rel="nofollow noreferrer">enter image description here</a>store but what choose firebase mode?</p> <p><strong>Start in locked mode</strong> Your data is private by default. Client read/write access will only be granted as specified by your security rules.</p> <p><strong>Start in test mode</strong> Your data is open by default to enable quick setup. However, you must update your security rules within 30 days to enable long-term clients to read/write access.</p> <p>The default security rules for test mode allow anyone with your database reference to view, edit, and delete all data in your database for the next 30 days</p>
[ { "answer_id": 74198512, "author": "Priya", "author_id": 10199456, "author_profile": "https://Stackoverflow.com/users/10199456", "pm_score": -1, "selected": false, "text": "import random\ntarget = random.randint(1,100)\ncounter = 0\nprint(target)\nguess = int(input('Guess an integer betw...
2022/10/25
[ "https://Stackoverflow.com/questions/74198538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19701503/" ]
74,198,546
<p>Sorry for the vague title. I have 3 tables: User, Place and PlaceOwner. I want to write a scope in the &quot;PlaceOwner&quot; model to get all the &quot;Places&quot; that don't have an owner.</p> <pre><code>class User &lt; ApplicationRecord has_one :place_owner end </code></pre> <pre><code>class PlaceOwner &lt; ApplicationRecord belongs_to :user belongs_to :place #scope :places_without_owner, -&gt; {} </code></pre> <pre><code>class Place &lt; ApplicationRecord has_many :place_owners end </code></pre> <p>I tried checking for association in the rails console for each element and it worked. But I don't know how to implement this at scope. I've seen people solve similar problems by writing SQL but I don't have the knowledge to write it that way. I understand that I need to check all IDs from Place to see if they are in the PlaceOwner table or not. But I can't implement it.</p> <p><strong>For example:</strong></p> <p>There are 3 records in the &quot;Place&quot; table: <em>House13, House14, House15</em>.</p> <p>There are 2 records in the &quot;PlaceOwner&quot; table: <em>House13 - User1</em>, <em>House 14 - User2</em></p> <p>I want to get <em>House15</em></p> <p>I hope I explained clearly what I'm trying to do. Please help or at least tell me where to go. Thanks in advance!</p>
[ { "answer_id": 74198761, "author": "spickermann", "author_id": 2483313, "author_profile": "https://Stackoverflow.com/users/2483313", "pm_score": 3, "selected": true, "text": "ActiveRecord::QueryMethods::WhereChain#missing" }, { "answer_id": 74201435, "author": "mechnicov", ...
2022/10/25
[ "https://Stackoverflow.com/questions/74198546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17879955/" ]
74,198,556
<p>I would like to make a script in python that retrieves what I'm listening to in real time on Spotify and allow me to send the information to an Arduino, But the problem is that my script refuses to run when my Spotify is turned off, knowing that I have other information that passes between my PC and my Arduino and if the script does not run most of the functions I created on my Arduino does not work anymore So I would like my script to work also when I don't listen to music</p> <p>Error : `</p> <pre><code>Traceback (most recent call last): File &quot;C:\Users\horvik\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py&quot;, line 971, in json return complexjson.loads(self.text, **kwargs) File &quot;C:\Users\horvik\AppData\Local\Programs\Python\Python310\lib\json\__init__.py&quot;, line 346, in loads return _default_decoder.decode(s) File &quot;C:\Users\horvik\AppData\Local\Programs\Python\Python310\lib\json\decoder.py&quot;, line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File &quot;C:\Users\horvik\AppData\Local\Programs\Python\Python310\lib\json\decoder.py&quot;, line 355, in raw_decode raise JSONDecodeError(&quot;Expecting value&quot;, s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File &quot;C:\Users\horvik\Desktop\project.py&quot;, line 62, in &lt;module&gt; serialDataToEncode = finishcpu + finishmem + get_current_track(ACCESS_TOKEN) File &quot;C:\Users\horvik\Desktop\Deskcompanionv1.py&quot;, line 25, in get_current_track json_resp = response.json() File &quot;C:\Users\horvik\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py&quot;, line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) </code></pre> <p>`</p> <p>I tried to use other entries from the spotify api like 'is_active' or 'is_playing' by adding them in an if/else hoping that I could not go through &quot;response.json()&quot; but I understood that I had to go through this one there's probably something I'm missing that's why I'm making this post if someone can help me.</p> <p>code :</p> <pre><code>import psutil import serial import requests import time from pprint import pprint SPOTIFY_GET_CURRENT_TRACK_URL = 'https://api.spotify.com/v1/me/player/currently-playing' ACCESS_TOKEN = 'i use token' serial = serial.Serial() serial.baudrate = 9600 serial.port = &quot;COM5&quot; serial.open() # spotify section def get_current_track(access_token): response = requests.get( SPOTIFY_GET_CURRENT_TRACK_URL, headers={ &quot;Authorization&quot;: f&quot;Bearer {access_token}&quot; } ) json_resp = response.json() if json_resp['is_playing'] == True : track_name = json_resp['item']['name'] artists = [artist for artist in json_resp['item']['artists']] artist_names = ', '.join([artist['name'] for artist in artists]) spotifytracksplaying = track_name + &quot; By &quot; + artist_names else : spotifytracksplaying = &quot;you are not lisenting music&quot; return spotifytracksplaying while(1): # cpu and ram usage section cpu = psutil.cpu_percent(interval=1.2) mem = psutil.virtual_memory().percent if cpu &lt; 10: finishcpu = &quot; &quot; + str(cpu) elif cpu &lt; 100: finishcpu = &quot; &quot; + str(cpu) else: finishcpu = str(cpu) if mem &lt; 10: finishmem = &quot; &quot; + str(mem) elif mem &lt; 100: finishmem = &quot; &quot; + str(mem) else: finishmem = str(mem) # sending information serialDataToEncode = finishcpu + finishmem + get_current_track(ACCESS_TOKEN) serialDatatosend = serialDataToEncode.encode(&quot;UTF-8&quot;) serial.write(serialDatatosend) # Debugging #print(serialDatatosend) ##print(get_current_track(ACCESS_TOKEN)) serial.close() </code></pre>
[ { "answer_id": 74198737, "author": "necro", "author_id": 9563464, "author_profile": "https://Stackoverflow.com/users/9563464", "pm_score": 2, "selected": true, "text": "from json.decoder import JSONDecodeError\n\ntry:\n json_resp = response.json()\nexcept JSONDecodeError:\n # Not j...
2022/10/25
[ "https://Stackoverflow.com/questions/74198556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332941/" ]
74,198,569
<p><a href="https://i.stack.imgur.com/IFsPi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IFsPi.png" alt="enter image description here" /></a></p> <p>I have a table above and I want to convert it to a table as shown below</p> <p><a href="https://i.stack.imgur.com/oIXPQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oIXPQ.png" alt="enter image description here" /></a></p> <p>What methods can I use to do this?</p> <p>I tried using PIVOT but I don't know how to change the Score column</p> <h2>So I hope I can find a solution to the above problem</h2> <p><strong>I have done that</strong> But I want to use a table variable instead of a table. How to do it?</p> <p>I want to replace Table your_table_name with a variable @table.</p> <p>But SQL says Must declare the scalar variable &quot;@table&quot; but I have declared it before.</p> <p><a href="https://i.stack.imgur.com/YqUwn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YqUwn.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74198755, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 1, "selected": false, "text": "PIVOT" }, { "answer_id": 74198939, "author": "Ullas", "author_id": 2294978, "author_prof...
2022/10/25
[ "https://Stackoverflow.com/questions/74198569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18509903/" ]
74,198,571
<p>I am trying to create a layout for our teams channel tab app but when running the app locally and inspecting it as a mobile device, teams throws an error that the browser is not supported.</p> <p>Can anyone point me in the correct direction to develop my app for mobile use or how I can view the mobile app from the VS Code Teams Toolkit debugging tools?</p> <p><a href="https://i.stack.imgur.com/Hyrwe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hyrwe.png" alt="Chrome Error" /></a></p> <p>I have tried to run the app in chrome and in MS Edge browsers and use the inspector device emulators in both but get the same error. I have also tried connecting via my local machine's IP /the FE port 53000 and also have had no luck there.</p>
[ { "answer_id": 74198755, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 1, "selected": false, "text": "PIVOT" }, { "answer_id": 74198939, "author": "Ullas", "author_id": 2294978, "author_prof...
2022/10/25
[ "https://Stackoverflow.com/questions/74198571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20286997/" ]
74,198,585
<p>Got a problem with using the scene manager. Already had a <strong>using UnityEngine.SceneManagement</strong> still shows the error of both LoadScene and GetActiveScene. I don't have a class such as &quot;SceneManager&quot;. Here is the code.</p> <pre><code>using UnityEngine.SceneManagement; using UnityEngine; public class PlayerMovement : MonoBehaviour { bool alive = true; public float speed = 5f; public Rigidbody rb; float horizontalInput; float horizontalMultiplier = 1.7f; private void FixedUpdate() { if (!alive) return; Vector3 forwardMove = transform.forward * speed * Time.fixedDeltaTime; Vector3 horizontalMove = transform.right * horizontalInput * speed * Time.fixedDeltaTime * horizontalMultiplier; rb.MovePosition(rb.position + forwardMove + horizontalMove); } // Update is called once per frame void Update() { horizontalInput = Input.GetAxis(&quot;Horizontal&quot;); if (transform.position.y &lt; -5) { end(); } } public void end () { alive = false; SceneManager.LoadScene(SceneManager.GetActiveScene().name); } } </code></pre> <p>Here is the error I have.</p> <p><a href="https://i.stack.imgur.com/pBIO2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pBIO2.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74198755, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 1, "selected": false, "text": "PIVOT" }, { "answer_id": 74198939, "author": "Ullas", "author_id": 2294978, "author_prof...
2022/10/25
[ "https://Stackoverflow.com/questions/74198585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333150/" ]
74,198,586
<p>For a schoolproject i have to make a simple website where i have to search members based on what the user types and then display these members. I have 5 properties to look for (first and lastname, sex, level, club). They have to work together but some might be null.</p> <pre><code>public List&lt;Lid&gt; ZoekLeden(string deelVoornaam, string deelNaam, string geslacht, string niveau, string deelClubNaam) { var filteredleden = context.Leden.Include(lid =&gt; lid.ClubNrNavigation) .OrderBy(l =&gt; l.Naam) .Where(l =&gt; l.Voornaam.Contains(deelVoornaam)) .Where(l =&gt; l.Naam.Contains(deelNaam)) .Where(l =&gt; l.Geslacht.Equals(geslacht)) .Where(l =&gt; l.Niveau.Equals(niveau)) .Where(l =&gt; l.ClubNrNavigation.Naam.Contains(deelClubNaam)) .ToList(); return filteredleden; } </code></pre> <p>Sadly it keep returning 0 and i dont know why.</p> <p>I tested each individual property and they all return the proper members. But the moment i use multiple they always return 0. Does anyone know why this happends and how i can fix it?</p>
[ { "answer_id": 74198755, "author": "Stuck at 1337", "author_id": 20091109, "author_profile": "https://Stackoverflow.com/users/20091109", "pm_score": 1, "selected": false, "text": "PIVOT" }, { "answer_id": 74198939, "author": "Ullas", "author_id": 2294978, "author_prof...
2022/10/25
[ "https://Stackoverflow.com/questions/74198586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332978/" ]
74,198,594
<p>I get:</p> <pre><code>JMX is not enabled to receive remote connections. \ Please see cassandra-env.sh for more info. </code></pre> <p>and I am not familiar with cassandra-env.sh</p> <p>I tried nano /etc/cassandra/cassandra-env.sh in the terminal but from there I'm lost</p>
[ { "answer_id": 74198830, "author": "stevenlacerda", "author_id": 10918015, "author_profile": "https://Stackoverflow.com/users/10918015", "pm_score": 2, "selected": false, "text": "if [ \"$LOCAL_JMX\" = \"yes\" ]; then\n JVM_OPTS=\"$JVM_OPTS -Dcassandra.jmx.local.port=$JMX_PORT\"\n" },...
2022/10/25
[ "https://Stackoverflow.com/questions/74198594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9930727/" ]
74,198,615
<p>I have the following code which reads txt file.</p> <pre><code>def get_line(filepath): f = open(filepath, &quot;r&quot;) while True: line = f.readline() print(line) f.close() print (&quot;Start...&quot;) get_line(&quot;/path/to/file/textfile.txt&quot;) print (&quot;Stop...&quot;) </code></pre> <p>The code runs without the &quot;while&quot; loop. Once I add the while loop, the terminal just displays a black screen with no error messages and the program runs continiously. Why does this happen?</p>
[ { "answer_id": 74198667, "author": "JustLearning", "author_id": 19962393, "author_profile": "https://Stackoverflow.com/users/19962393", "pm_score": -1, "selected": false, "text": "True" }, { "answer_id": 74198672, "author": "BishwashK", "author_id": 10317949, "author_...
2022/10/25
[ "https://Stackoverflow.com/questions/74198615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6530860/" ]
74,198,637
<p>I cannot understand this unexpected C behavior where printing <code>argv[0]</code> prints <code>./a.out</code> instead of the actual content of <code>argv[0]</code> which should be a memory address because <code>argv</code> is an array of pointers.</p> <p>If I create an array called <code>char name[] = &quot;hello&quot;</code> then I would expect to see <code>h</code> at <code>name[0]</code> and if <code>char * argv[]</code> holds, for example 3 pointers <em>(memory addresses)</em> then logically <code>argv[0]</code> should be a memory address.</p> <p>My reasoning is that if I wanted to access the actual content of the memory address that <code>argv[0]</code> points to I should need to do <code>*(argv[0])</code>. What is happening here? Is C doing some kind of magic here?</p> <pre class="lang-none prettyprint-override"><code>+------+------+------+---+---+----+ | h | e | l | l | o | \0 | +------+------+------+---+---+----+ ^---- name[0] = h +------+------+------+ | 0xA7 | 0xCE | 0xC4 | +------+------+------+ ^---- argv[0] = should be 0XA7 (the value of `argv[0]`, not the value it points to </code></pre> <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt; int main(int argc, char * argv[]) { char name[] = &quot;hello&quot;; printf(&quot;%c \n&quot;, name[0]); // expected h printf(&quot;%s \n&quot;, argv[0]); // expected 0xA7 (but got ./a.out instead) } </code></pre> <pre class="lang-none prettyprint-override"><code>$ gcc main.c $ ./a.out arg1 arg2 arg3 </code></pre>
[ { "answer_id": 74198826, "author": "ikegami", "author_id": 589924, "author_profile": "https://Stackoverflow.com/users/589924", "pm_score": 2, "selected": true, "text": "printf" }, { "answer_id": 74198843, "author": "Vlad from Moscow", "author_id": 2877241, "author_pro...
2022/10/25
[ "https://Stackoverflow.com/questions/74198637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9008233/" ]
74,198,638
<p>I don't know If I'm checking for the value of the boolean correctly</p> <p>what this code does: the user creates a note for himself, his ID is on the note and it needs to belong to a category name that has to be in the category schema ( where my error happens )</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>exports.postAddNote = (req, res) =&gt; { const errors = validationResult(req); if (!errors.isEmpty()) { const error = new Error("validation failed, entered data is incorrect"); throw error; } const content = req.body.content; const tags = req.body.tags; const categoryName = req.body.categoryName; let creator; const note = new Note({ content: content, categoryName: categoryName, // work tags: tags, creator: req.userId, }); Category.find() .select("-_id") .select("-__v") .select("-notesId") .then((categories) =&gt; { console.log(categories); //stripping everything but names off categories const CategoryExists = categories.some( (category) =&gt; category.name === categoryName ); console.log(CategoryExists); // ~~~~~~~~~~ this logs correctly if (CategoryExists === -0) { // ~~~~~~~~~~ what i want: if the value is false return res.json({ Error: "The category you entered does not exist" }); } note // ~~~~~~~~~~ the code stops here :/ it doesn't save the note .save() .then((note) =&gt; { console.log("saved note"); User.findById(req.userId); }) .then((user) =&gt; { creator = user; user.notes.push(note); return user.save(); }) .then((result) =&gt; { res.status(201).json({ info: { dateCreated: new Date().toISOString(), status: "Note Created Successfully", creator: { _id: creator._id, email: creator.email }, }, }); }) .catch((err) =&gt; { if (!err.statusCode) { err.statusCode = 500; } }); }) .catch((err) =&gt; { console.log(err); next(); }); };</code></pre> </div> </div> </p>
[ { "answer_id": 74198708, "author": "dqhendricks", "author_id": 512922, "author_profile": "https://Stackoverflow.com/users/512922", "pm_score": 2, "selected": true, "text": "if (CategoryExists === -0)\n" }, { "answer_id": 74198710, "author": "Borna Pavlić", "author_id": 16...
2022/10/25
[ "https://Stackoverflow.com/questions/74198638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19577126/" ]
74,198,644
<p>I have a large data table containing details by date and across 3 independent criteria with around 12 discreet values for each criteria. That is, each criteria field in the table is defined as a 12 value ENUM. Users pull summary data by date and any filtering across the three criteria, including none at all. To make a single criteria lookup efficient, 3 separate indexes are required (date,CriteriaA), (date,CriteriaB), (date,CriteriaC). 4 indexes if you want to lookup against any of the 3 (date,A,B,C),(date,A,C),(date,B,C),(date,C).</p> <p>In an attempt to be more efficient in the lookup, I built a SET column containing all 36 values from the 3 criteria. All values across the criteria are unique and none are a subset of any other. I added an index to this set (date, set_col). Queries against this table using a set lookup fails to take advantage of the index, however. Neither <code>FIND_IN_SET('Value',set_col)</code>, <code>set_col LIKE '%Value%'</code>, nor <code>set_col &amp; [pos. in set]</code> triggers the index (according to explain and overall resultset return speed).</p> <p>Is there a trick to indexing SET columns?</p> <p>I tried queries like</p> <pre><code>Select Date, count(*) FROM tbl where DATE between [Start] and [End] and FIND_IN_SET('Value',set_col) group by Date </code></pre> <p>I would expect it to run nearly as fast as a lookup against the individual criteria column that has an index against it. But instead it runs as fast when just an index against DATE exists. Same number of rows processed according to Explain.</p>
[ { "answer_id": 74198708, "author": "dqhendricks", "author_id": 512922, "author_profile": "https://Stackoverflow.com/users/512922", "pm_score": 2, "selected": true, "text": "if (CategoryExists === -0)\n" }, { "answer_id": 74198710, "author": "Borna Pavlić", "author_id": 16...
2022/10/25
[ "https://Stackoverflow.com/questions/74198644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20332745/" ]
74,198,662
<p>I am trying to alphabetically sort each value in a column with Snowflake. For example I have:</p> <pre><code>| NAME | | ---- | | abc | | bca | | acb | </code></pre> <p>and want</p> <pre><code>| NAME | | ---- | | abc | | abc | | abc | </code></pre> <p>how would I go about doing that? I've tried using SPLIT and the ordering the rows, but that doesn't seem to work without a specific delimiter.</p>
[ { "answer_id": 74198827, "author": "Lukasz Szozda", "author_id": 5070879, "author_profile": "https://Stackoverflow.com/users/5070879", "pm_score": 3, "selected": true, "text": "REGEXP_REPLACE" }, { "answer_id": 74200570, "author": "Rajat", "author_id": 9947159, "autho...
2022/10/25
[ "https://Stackoverflow.com/questions/74198662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11967235/" ]
74,198,688
<p>** Problem **</p> <p>How to refence Numpy nested arrays by reference inside array elements? When the elements on not, NOT, as 3 dim array, but the results of a <code>list(map(lambda))</code> on elements to assign a rank, eg., <code>['g',e','f','a','b','c']</code>. Perhaps need to convert to structure and allows <code>[1][0][1]...[7][0][1]</code> refencing approach.</p> <p>** Goal Needed Report on rank ** Need to report on rank, eg., <code>['g',e','f','a','b','c']</code> But <code>array([1,2,3,4]), array([.4, .5, .6]) AKA [1][0]...[7][0]</code> works but NOT <code>[1][0][1]...[7][0][1]</code></p> <p>** Code effort try **</p> <p>started with np.array()::</p> <pre><code>array_things = np.array(data_head[;, 1-8]).sum(axis=1, float) </code></pre> <p>then next after a np.vectorized() AND and then a list(map) ::</p> <pre><code>np.vectorized(funA) list(map(lambda x: funB(x), array_things)) </code></pre> <p>This <code>list(map(labda x: funB(x), array_things))</code> assigns the ['g',e','f','a','b','c'] associated to the [1][0],...[1][1]...[7][0],...[7][1]. Something like a simple rank but not as a 3 dim array [1][0][1]...[7][0][1]</p> <p>** Effort **</p> <pre><code>array_data[1][0] array_data[1][1] </code></pre> <p>but need to reference the, say [1][0][1]</p> <p>** Logical Data ** If the np.array as the basic data output layout as such, eg:</p> <pre><code>array([1,2,3,4]), array([.4, .5, .6]), (['g','e','f']) </code></pre> <p>example data :</p> <pre><code>(array([1,2,3,4,5]), array([.55, .65, .76,.81,.79]),(['g',e','f','a','b','c']) </code></pre>
[ { "answer_id": 74199520, "author": "hpaulj", "author_id": 901925, "author_profile": "https://Stackoverflow.com/users/901925", "pm_score": 1, "selected": false, "text": "In [4]: np.array([1,2,3,4,5]), np.array([.55, .65, .76,.81,.79]),['g','e','f','a','b','c']\nOut[4]: \n(array([1, 2, 3, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74198688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1857373/" ]
74,198,696
<p>Let's say I have a really long string consists of 10^6 tokens (for simplicity, token is a space-separated word, so this string is splitted to list of tokens)</p> <p>now I need to find all possible duplicated sequences and the start of the duplication locations in the string. For example:</p> <p>(The brackets are not really in the string, they only to clarify the location)</p> <pre><code>this[0] string[1] is[2] test[3] to[4] check[5] duplication[6] test[7] to[8] check[9] duplication[10] this[11] string[12] ==&gt; at 0,11 - 2 tokens duplication ==&gt; at 3,7 - 4 tokens duplication </code></pre> <p>I've tried to build Python program with an algorithm based on dictionary that keeps a list of each token index and checks token matches from those indexes. That is far too slow, even when I used Numpy instead of list.</p> <p>Then I tried to use Suffix tree. But all methods tend to use letters rather than words. When I think of converting this algorithm to use tokens instead of letters, it could work if I used many small strings. The problem I have one huge string so it creates one long tree.</p> <p>All the answer in Stackoverflow and all over the internet are not considering one long string. Any Ideas for best CPU performance algorithm? (RAM performance is less important) Thanks</p>
[ { "answer_id": 74199520, "author": "hpaulj", "author_id": 901925, "author_profile": "https://Stackoverflow.com/users/901925", "pm_score": 1, "selected": false, "text": "In [4]: np.array([1,2,3,4,5]), np.array([.55, .65, .76,.81,.79]),['g','e','f','a','b','c']\nOut[4]: \n(array([1, 2, 3, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74198696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7758213/" ]
74,198,717
<p>This is my first project using HTML and CSS so I'm pretty much a newbie for this language. I think my dropdown menu is conflicting with the bottom-border because it won't show up. This is both my HTML and CSS code for it.</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>* { margin: 0; padding: 0; background-color: white; overflow-x: hidden; } body { font-family: Arial, Helvetica, sans-serif; } header { background-color: rgb(255, 255, 255); height: 600px; } .navbar { width: 85%; margin: auto; padding: 60px 0; display: flex; align-items: center; justify-content: space-between; } .logo { width: 160px; cursor: pointer; margin-right: auto; } .navbar .dropdown { display: none; } .navbar ul li:hover .dropdown { display: block; } .navbar ul li { list-style: none; display: inline-block; margin: 0 20px; position: relative; } .navbar ul li a { text-decoration: none; color: black; } .navbar ul li::after { content: ''; height: 3px; width: 0; background: teal; position: absolute; left: 0; bottom: 0px; transition: 0.5s; } .navbar ul li:hover::after { width: 100%; } button { list-style: none; border: none; background: teal; padding: 10px 20px; border-radius: 30px; color: white; font-size: 15px; transition: 0.4s; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;header&gt; &lt;div class="banner"&gt; &lt;div class="navbar"&gt; &lt;img src="icon.png" class="logo"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Products&lt;/a&gt;&lt;/li&gt; &lt;ul class="dropdown"&gt; &lt;li&gt;&lt;a href="#"&gt;Healthcare&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Cosmetic&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Misc.&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;li&gt;&lt;a href="#"&gt;About Us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Register&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;button type="button"&gt;&lt;a href="#"&gt;&lt;/a&gt;Login&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/header&gt;</code></pre> </div> </div> </p> <p>I already tried many options from various sources and It still won't work. I think the problem lays somewhere between the code for the border-bottom but I'm not sure.</p>
[ { "answer_id": 74199520, "author": "hpaulj", "author_id": 901925, "author_profile": "https://Stackoverflow.com/users/901925", "pm_score": 1, "selected": false, "text": "In [4]: np.array([1,2,3,4,5]), np.array([.55, .65, .76,.81,.79]),['g','e','f','a','b','c']\nOut[4]: \n(array([1, 2, 3, ...
2022/10/25
[ "https://Stackoverflow.com/questions/74198717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333204/" ]
74,198,718
<p>A common pattern I like to use in C# is one where instead of first checking whether something exists in a collection with <code>Any</code> then finding it again with <code>First</code>, I simply call <code>FirstOrDefault</code>, which both tells me whether it exists and if so, gives me a reference to it:</p> <pre><code>List&lt;Person&gt; people = ...; Person found; if ((found = people.FirstOrDefault(x =&gt; x.Age &gt; 10)) != null) { // Found person with age over 10, and we have them in 'found' //... } </code></pre> <p>This works when the thing being found is a reference type, and can be null. However, I was trying to do the same thing with a <code>Dictionary</code>'s entries:</p> <pre><code>Dictionary&lt;(int X, int Y), ITileData&lt;(int X, int Y)&gt;&gt; srchField = new(); KeyValuePair&lt;(int X, int Y), ITileData&lt;(int X, int Y)&gt;&gt; next; while ((next = srchField.FirstOrDefault(x =&gt; !x.Value.Reached)) != null) { // Found next, and we have it in 'next' //... } </code></pre> <p>This, however, doesn't work because <code>srchField.FirstOrDefault(...)</code> returns a <code>KeyValuePair&lt;TKey, TValue&gt;</code>, which is a struct. I can work around this by first calling <code>Any</code> on <code>srchField</code>, and then calling <code>First</code> with the same predicate if <code>Any</code> finds anything, but this is having to do the same search twice. Is there any way I can do the 2-in-1 check existence and store here, only carrying out one search of the dictionary in LINQ?</p>
[ { "answer_id": 74199029, "author": "n0rd", "author_id": 31782, "author_profile": "https://Stackoverflow.com/users/31782", "pm_score": 0, "selected": false, "text": "Values" }, { "answer_id": 74205845, "author": "Jez", "author_id": 178757, "author_profile": "https://St...
2022/10/25
[ "https://Stackoverflow.com/questions/74198718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/178757/" ]
74,198,720
<p>I have a string variable that contains the name of another variable</p> <pre><code>mystring = 'var1' </code></pre> <p>I seek to create a function that takes var1 as an input:</p> <pre><code>def myfun(var1): res = somefun(var1) return res </code></pre> <p>but instead of using the expression var1 directly, I want to use the string. So sth like this:</p> <pre><code>def myfun(eval(mystring)): res = somefun(eval(var1)) return res </code></pre> <p>I know, normally the name of the function argument is irrelevant but in my case, it is actually not. Also wrapping the eval around the entire function definition cannot be done. Why? Essentially because I am building on other code which comes with this requirement. I know, it sounds strange but it is what it is</p> <p>Any idea how to do this?</p> <p>I tried solving it with eval() or exec() for only some part of the code but these did not work.</p> <p><strong>EDIT</strong></p> <p>Clarification. I want to declare a bunch of functions (lets say 2) that look like this</p> <pre><code>def myfun1(var1): res1 = somefun(var1) return res1 def myfun2(var2): res2 = somefun(var2) return res2 </code></pre> <p>where the name of the arguments/outputs are important because the codes with which I want to use this use these names to connect these function in a graph (think that output of myfun2 shall be used in another function that uses res2 as input). I guess this has been implemented with inspect. It is probably not optimal but this is what it is. Now I want to avoid the c/p from above with a loop to generate these functions dynamically.</p> <p>Also I cannot use a dictionary because the code I am building on assumes that all variables here are np arrays.</p>
[ { "answer_id": 74199029, "author": "n0rd", "author_id": 31782, "author_profile": "https://Stackoverflow.com/users/31782", "pm_score": 0, "selected": false, "text": "Values" }, { "answer_id": 74205845, "author": "Jez", "author_id": 178757, "author_profile": "https://St...
2022/10/25
[ "https://Stackoverflow.com/questions/74198720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333193/" ]
74,198,766
<p>Like the title</p> <pre><code>&lt;test&gt; &lt;num&gt;1 5 7&lt;/num&gt; &lt;num&gt;4-2&lt;/num&gt; ..... &lt;/test&gt; </code></pre> <p>how to get the sum for each num tag</p> <p>i have tried to change the string like from {1 5 7} to {1+5+7} then use sum or number function but it did't work</p> <p>expected get</p> <pre><code>&lt;test&gt; &lt;num&gt;13&lt;/num&gt; &lt;num&gt;2&lt;/num&gt; ..... &lt;/test&gt; </code></pre> <p>or other format thx</p>
[ { "answer_id": 74199622, "author": "Martin Honnen", "author_id": 252228, "author_profile": "https://Stackoverflow.com/users/252228", "pm_score": 2, "selected": false, "text": "sum(tokenize(<num>1 5 7</num>)!xs:decimal(.))" }, { "answer_id": 74211649, "author": "line-o", "...
2022/10/25
[ "https://Stackoverflow.com/questions/74198766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333274/" ]
74,198,812
<p>i'm a begginer at phyton, and i am trying to create a function that indicates if is true or false if an even number is true or false.</p> <p>This function is already working, but now i am trying to pass the function with a value given through the input function.</p> <p>This is my code:</p> <pre><code>def isprime (value): value=int(input(&quot;Enter a number: &quot;)) if value &lt; 2: return False else: for count in range (2, value): if value % count == 0: return False return True isprime () </code></pre> <p>When i run isprime () i get the following error message</p> <p>TypeError: isprime() missing 1 required positional argument: 'value'</p> <p>Please, note that if i don't put the input part and i run the funcion like isprime (3) my output is TRUE.</p> <p>Can you please help me to let me know what i am doing wrong?</p>
[ { "answer_id": 74198869, "author": "Miron Barykin", "author_id": 17023658, "author_profile": "https://Stackoverflow.com/users/17023658", "pm_score": 0, "selected": false, "text": "def isprime(value):\n if value < 2:\n return False\n else:\n for count in range (2, valu...
2022/10/25
[ "https://Stackoverflow.com/questions/74198812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333293/" ]
74,198,834
<pre><code>import math # Constants for the minimum and maximum values MINIMUM_PIZZA_DIAMETER = 8 MAXIMUM_PIZZA_DIAMETER = 24 # Constants for the number of slices in different sized pizzas EXTRA_SMALL_PIZZA_SLICES = 6 SMALL_PIZZA_SLICES = 8 MEDIUM_PIZZA_SLICES = 10 LARGE_PIZZA_SLICES = 12 EXTRA_LARGE_PIZZA_SLICES = 16 # Constants for Diameter limits for each size of pizza EXTRA_SMALL_DIAMETER_LIMIT = 12 SMALL_DIAMETER_LIMIT = 14 MEDIUM_DIAMETER_LIMIT = 16 LARGE_DIAMETER_LIMIT = 20 EXTRA_LARGE_DIAMETER_LIMIT = 24 # List for the Total amount of slices TOTAL_SLICES = (6,8,10,12,16) continue_input = True is_valid = True # Float variable for the number of slices in the user's pizza user_diameter = 0.0 # Integer variable for the number of slices in the pizza pizza_slices = 0 # Integer variable for the radius of a pizza pizza_radius = 0 # Integer variable for the area of a pizza pizza_area = 0 # Integer variable for the area of a pizza slice pizza_slice_area = 0 # Integer variable for total possible number of slices slices_possible = 0 # Integer for slices slices = 0 while continue_input: is_valid = True while is_valid: try: user_diameter = float(input(&quot;Please enter the diameter of the pizza in inches or Enter 0 to end the program\t&quot;)) if MINIMUM_PIZZA_DIAMETER &lt;= user_diameter &lt;= MAXIMUM_PIZZA_DIAMETER: if user_diameter &lt;= EXTRA_SMALL_DIAMETER_LIMIT: pizza_slices = EXTRA_SMALL_PIZZA_SLICES slices_possible = (6) pizza_radius = user_diameter/2 pizza_area = (3.14*pizza_radius*pizza_radius) pizza_slice_area = pizza_area/pizza_slices pizza_slice_area = round(pizza_slice_area,2) print(f&quot;This Cuts {slices_possible} slices and gives an area of {pizza_slice_area} for each slice.&quot;) elif user_diameter &lt;= SMALL_DIAMETER_LIMIT: pizza_slices = SMALL_PIZZA_SLICES slices_possible = (6,8) pizza_radius = user_diameter/2 pizza_area = (3.14*pizza_radius*pizza_radius) pizza_slice_area = pizza_area/pizza_slices pizza_slice_area = round(pizza_slice_area,2) print(f&quot;This Cuts {slices_possible} slices and gives an area of {pizza_slice_area} for each slice.&quot;) elif user_diameter &lt;= MEDIUM_DIAMETER_LIMIT: pizza_slices = MEDIUM_PIZZA_SLICES slices_possible = (6,8,10) pizza_radius = user_diameter/2 pizza_area = (3.14*pizza_radius*pizza_radius) pizza_slice_area = pizza_area/pizza_slices pizza_slice_area = round(pizza_slice_area,2) print(f&quot;This Cuts {slices_possible} slices and gives an area of {pizza_slice_area} for each slice.&quot;) elif user_diameter &lt;= LARGE_DIAMETER_LIMIT: pizza_slices = LARGE_PIZZA_SLICES slices_possible = (6,8,10,12) pizza_radius = user_diameter/2 pizza_area = (3.14*pizza_radius*pizza_radius) pizza_slice_area = pizza_area/pizza_slices pizza_slice_area = round(pizza_slice_area,2) print(f&quot;This Cuts {slices_possible} slices and gives an area of {pizza_slice_area} for each slice.&quot;) else: user_diameter &lt;= EXTRA_LARGE_DIAMETER_LIMIT pizza_slices = EXTRA_LARGE_PIZZA_SLICES slices_possible = (6,8,10,12,16) pizza_radius = user_diameter/2 pizza_area = (3.14*pizza_radius*pizza_radius) pizza_slice_area = pizza_area/pizza_slices pizza_slice_area = round(pizza_slice_area,2) print(f&quot;This Cuts {slices_possible} slices and gives an area of {pizza_slice_area} for each slice.&quot;) continue_input = False else: print(f&quot;You must enter a number between 8\&quot; and 24\&quot;. You enter {user_diameter} &quot;) except: print(f&quot;You didn't enter a number &quot;) </code></pre> <p>I am trying have this program tell me the area of each slice of pizza. The problem is that I need it to calculate the area of each slice of pizza from the possible amount slices and have it looping until I enter 0 by itself. For Extra Small its easy as it is only one number my problem is when there are multiple numbers. I don't know how to have it show the area of each slice there where 6,8,10,12,16 possible slices. I also don't know how to make the program end when I enter 0. I am new to coding so this is giving me a lot of trouble. I don't even know if I did the calculation correct.</p> <p>I have tried what you see in the code above but what it should result in is this:</p> <p>If I were to input 23.5&quot; it should look like this.</p> <pre><code>Pizza Diameter: 23.5” Cut in 6 slices results in an area of 72.29” per slice. Cut in 8 slices results in an area of 54.22” per slice. Cut in 10 slices results in an area of 43.37” per slice. Cut in 12 slices results in an area of 36.14” per slice. Cut in 16 slices results in an area of 27.11” per slice. </code></pre> <p>But what I get is this:</p> <pre><code>Cut in (6, 8, 10, 12, 16) slices results in an area of 27.09 for each slice. </code></pre> <p>I know I am missing something but my brain isn't working very well for this.</p>
[ { "answer_id": 74198869, "author": "Miron Barykin", "author_id": 17023658, "author_profile": "https://Stackoverflow.com/users/17023658", "pm_score": 0, "selected": false, "text": "def isprime(value):\n if value < 2:\n return False\n else:\n for count in range (2, valu...
2022/10/25
[ "https://Stackoverflow.com/questions/74198834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20316573/" ]
74,198,853
<p>I have the following bash script:</p> <pre><code>#!/bin/bash js=&quot;{\&quot;fizz\&quot;:\&quot;buzz\&quot;,\&quot;foo\&quot;:\&quot;baz\&quot;}&quot; echo $js json=$(echo &quot;$js&quot; | jq -r &quot;to_entries|map(\&quot;\(.key)=\(.value|tostring)\&quot;)|.[]&quot;) echo &quot;fetching secret json:&quot; echo $json </code></pre> <p>When I run it I get this:</p> <pre><code>myuser@mymachine myapp % bash myscript.sh {&quot;fizz&quot;:&quot;buzz&quot;,&quot;foo&quot;:&quot;baz&quot;} fetching secret json: fizz=buzz foo=baz </code></pre> <p>In reality the JSON will be a <strong>lot</strong> larger than just 2 properties, but it <em>will</em> be a flat mapping of key-value pairs (no object nesting).</p> <p>I actually need these map entries in comma-delimited key-value pairs. So instead of:</p> <pre><code>fizz=buzz foo=baz </code></pre> <p>I need:</p> <pre><code>fizz=buzz,foo=baz </code></pre> <p>What can I do to my <code>jq</code> filters (or elsewhere) to get a comma inserted in between the key-value pairs? To be clear I'm <strong>not</strong> looking for valid JSON output, nor CSV format. I need comma-delimited KV pairs. Thanks in advance!</p>
[ { "answer_id": 74199035, "author": "oguz ismail", "author_id": 10248678, "author_profile": "https://Stackoverflow.com/users/10248678", "pm_score": 3, "selected": true, "text": "jq -r 'to_entries | map(\"\\(.key)=\\(.value)\") | join(\",\")'\n" }, { "answer_id": 74199609, "aut...
2022/10/25
[ "https://Stackoverflow.com/questions/74198853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5235665/" ]
74,198,918
<p>I am trying to implement <a href="https://web.archive.org/web/20160119141816/http://www.fastcgi.com/drupal/node/6?q=node%2F22" rel="nofollow noreferrer">FastCGI</a> protocol in rust. And when I had a problem I asked a question here on stackoverflow (<a href="https://stackoverflow.com/questions/73930911/how-to-get-the-output-of-programs-with-fastcgi/73932340">the question is this</a>). And as you can see the <a href="https://stackoverflow.com/questions/73930911/how-to-get-the-output-of-programs-with-fastcgi/73932340#73932340">answer to my question</a> says this:</p> <blockquote> <p>Then use <a href="https://doc.rust-lang.org/1.54.0/std/io/trait.Read.html#method.read_exact" rel="nofollow noreferrer">read_exact</a> to read the header of the response, extract its content length and read_exact again to get contents of the response:</p> </blockquote> <p>And I really had no problem with that. But since then, I've come across people (both online and in real life) who say something pretty similar to this:):</p> <blockquote> <p>Avoid the &quot;exact&quot; functions as they might silently swallow some stream content, see the docs.</p> </blockquote> <p>So my question is. Should I use <code>read_exact</code> for my specific case? Are the people who said not to use <code>read_exact</code> right? Why should I occupy it or why should I <strong>NOT</strong> occupy it? If you need more context about my case in particular, everything is in my question that I passed at the beginning of this post</p>
[ { "answer_id": 74200285, "author": "Locke", "author_id": 5987669, "author_profile": "https://Stackoverflow.com/users/5987669", "pm_score": 3, "selected": true, "text": "read_exact" }, { "answer_id": 74204013, "author": "Jmb", "author_id": 5397009, "author_profile": "h...
2022/10/25
[ "https://Stackoverflow.com/questions/74198918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15204291/" ]
74,198,930
<p>I have a MacBook M1 and installed WebStorm 2022.2.3 and installed Docker plugin. Then I installed Docker Desktop for Apple Silicon.</p> <p>The Docker Desktop is working fine but in my WebStorm I got an error when I try to build a <code>.yaml</code> file. The error is that WebStorm cannot connect to the Docker daemon.</p> <p>I’ve searched for a solution for this error online but had no luck. I installed Brew and Rosetta 2 and the issue is the same.</p> <p>Has anyone had this kind of issue? Oh, I did not mention that on my Windows laptop this feature works normally :-)</p> <p><a href="https://i.stack.imgur.com/nGsjO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nGsjO.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74206581, "author": "rtstorm", "author_id": 5495471, "author_profile": "https://Stackoverflow.com/users/5495471", "pm_score": 0, "selected": false, "text": "brew install docker-machine docker\n" }, { "answer_id": 74244119, "author": "Martin M", "author_id":...
2022/10/25
[ "https://Stackoverflow.com/questions/74198930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5495471/" ]
74,198,948
<p>I am trying to write a sed command to do the following.</p> <p>I have a line in my file, something like this</p> <pre><code>*.info;mail.none;authpriv.none;cron.none /var/log/messages </code></pre> <p>This has to be replaced with,</p> <pre><code>*.info;mail.none;authpriv.none;cron.none;local2.none;local5.none /var/log/messages </code></pre> <p>Conditions</p> <ol> <li>There is no fixed spacing between cron.none and /var/log/messages, the spacing might vary from file to file. original *.info;mail.none;authpriv.none;cron.none /var/log/messages desired *.info;mail.none;authpriv.none;cron.none;local2.none;local5.none /var/log/messages</li> </ol> <p>or</p> <p>original</p> <pre><code>*.info;mail.none;authpriv.none;cron.none /var/log/messages desired *.info;mail.none;authpriv.none;cron.none;local2.none;local5.none /var/log/messages </code></pre> <p>just append ;local2.none;local5.none</p> <ol start="2"> <li>Sometime the file might have already ;local2.none;local5.none, in this case ignore the append. ex</li> </ol> <pre><code>*.info;mail.none;authpriv.none;cron.none;local2.none;local5.none /var/log/messages *.info;mail.none;authpriv.none;cron.none;local2.none;local5.none /var/log/messages </code></pre> <ol start="3"> <li>sometimes the file might have local6.none, but no local2.none;local5.none, in this case append ;local2.none;local5 ex</li> </ol> <pre><code>*.info;mail.none;authpriv.none;cron.none;local6.none /var/log/messages *.info;mail.none;authpriv.none;cron.none;local2.none;local5.none;local6.none /var/log/messages </code></pre> <p>Below are the few things I tried.</p> <p>1)</p> <pre><code>sed -i -e &quot;/*.info;mail.none;authpriv.none;cron.none;local2.none;local5.none.*\+\/var\/log\/messages/! /*.info;mail.none;authpriv.none;cron.none.*\+\/var\/log\/messages/ s/cron.none/cron.none;local2.none;local5.none/g&quot; $SYSLOGCONFFILE </code></pre> <ol start="2"> <li></li> </ol> <pre><code>sed -i -e &quot;/*.info;mail.none;authpriv.none;cron.none.*\+\/var\/log\/messages/.*local2.none;local5.none.*/!s/cron.none/cron.none;local2.none;local5.none/g&quot; $SYSLOGCONFFILE </code></pre> <ol start="3"> <li></li> </ol> <pre><code>sed -i -e &quot;/*.info;mail.none;authpriv.none;cron.none;local2.none;local5.none.*\+\/var\/log\/messages/! /*.info;mail.none;authpriv.none;cron.none.*\+\/var\/log\/messages/ s/cron.none/cron.none;local2.none;local5.none/g&quot; $SYSLOGCONFFILE </code></pre> <p>nothing seems working. TIA</p>
[ { "answer_id": 74200033, "author": "Eric Marceau", "author_id": 9716110, "author_profile": "https://Stackoverflow.com/users/9716110", "pm_score": 0, "selected": false, "text": "#!/bin/sh\n\nawk -v inject=\";local2.none;local5.none\" -v postfix=\";local6.none\" '{\n exist=index( $1, in...
2022/10/25
[ "https://Stackoverflow.com/questions/74198948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20270570/" ]
74,198,958
<p>Can't build up my project on my new laptop (macbook m1). It was built great on my previous machine with Intel.</p> <p>Here's the part of my Dockerfile</p> <pre class="lang-bash prettyprint-override"><code>FROM php:7.4-apache ENV COMPOSER_ALLOW_SUPERUSER 1 ARG GOLANG_VERSION=1.16.5 RUN apt-get update &amp;&amp; apt-get install -y \ cron \ curl \ wget \ git \ libfreetype6-dev \ libzip-dev \ libonig-dev \ libxslt-dev \ libicu-dev \ libmcrypt-dev \ libxml2-dev \ libsodium-dev \ libpq-dev \ zlib1g-dev \ libpcre3-dev \ libcurl4-openssl-dev \ libmagickwand-dev --no-install-recommends \ pkg-config \ libssl-dev \ &amp;&amp; a2enmod \ rewrite \ &amp;&amp; pecl install \ imagick \ RUN docker-php-ext-configure \ gd \ pgsql -with-pgsql=/usr/local/pgsql \ exif \ &amp;&amp; docker-php-ext-install \ gd \ mysqli \ pdo \ pdo_pgsql \ pgsql \ sockets \ zip \ mbstring \ xml \ intl \ curl \ exif \ &amp;&amp; docker-php-ext-enable \ imagick \ exif </code></pre> <p>Here's the part of docker-compose.yaml</p> <pre class="lang-yaml prettyprint-override"><code>version: '3.1' services: web: build: ./docker/web env_file: - .env environment: - APACHE_RUN_USER=#1000 volumes: - ${WEB_ROOT_PATH}:/var/www/html/ ports: - ${WEB_PORT}:80 working_dir: ${WEB_WORKING_DIR} restart: unless-stopped </code></pre> <p>Then I do <code>docker-compose up --build -d</code> and after 400 seconds of waiting here's what I got:</p> <pre><code>#0 106.6 Processing triggers for mailcap (3.69) ... #0 106.6 Processing triggers for libglib2.0-0:arm64 (2.66.8-1) ... #0 106.6 No schema files found: doing nothing. #0 106.6 Processing triggers for libc-bin (2.31-13+deb11u4) ... #0 106.6 Setting up libcairo2-dev:arm64 (1.16.0-5) ... #0 106.7 Setting up libgdk-pixbuf-2.0-dev:arm64 (2.42.2+dfsg-1+deb11u1) ... #0 106.7 Setting up librsvg2-dev:arm64 (2.50.3+dfsg-1) ... #0 106.7 Setting up libmagickcore-6.q16-dev:arm64 (8:6.9.11.60+dfsg-1.3) ... #0 106.7 Setting up libmagickwand-6.q16-dev:arm64 (8:6.9.11.60+dfsg-1.3) ... #0 106.7 Setting up libmagickwand-dev (8:6.9.11.60+dfsg-1.3) ... #0 106.7 Processing triggers for libgdk-pixbuf-2.0-0:arm64 (2.42.2+dfsg-1+deb11u1) ... #0 106.8 Enabling module rewrite. #0 106.8 To activate the new configuration, you need to run: #0 106.8 service apache2 restart #0 169.3 No releases available for package &quot;pecl.php.net/imagick&quot; #0 229.3 No releases available for package &quot;pecl.php.net/RUN&quot; #0 289.4 No releases available for package &quot;pecl.php.net/gd&quot; #0 349.5 No releases available for package &quot;pecl.php.net/pgsql&quot; #0 409.6 No releases available for package &quot;pecl.php.net/exif&quot; #0 409.6 parsePackageName(): only one version/state delimiter &quot;-&quot; is allowed in &quot;docker-php-ext-configure&quot; #0 409.6 invalid package name/package file &quot;docker-php-ext-configure&quot; #0 409.6 Attempting to discover channel &quot;-with-pgsql=/usr/local&quot;... #0 409.6 Attempting fallback to https instead of http on channel &quot;-with-pgsql=/usr/local&quot;... #0 409.6 unknown channel &quot;-with-pgsql=/usr/local&quot; in &quot;-with-pgsql=/usr/local/pgsql&quot; #0 409.6 invalid package name/package file &quot;-with-pgsql=/usr/local/pgsql&quot; #0 409.6 install failed ------ failed to solve: executor failed running [/bin/sh -c apt-get update &amp;&amp; apt-get install -y cron curl wget git libfreetype6-dev libzip-dev libonig-dev libxslt-dev libicu-dev libmcrypt-dev libxml2-dev libsodium-dev libpq-dev zlib1g-dev libpcre3-dev libcurl4-openssl-dev libmagickwand-dev --no-install-recommends pkg-config libssl-dev &amp;&amp; a2enmod rewrite &amp;&amp; pecl install imagick RUN docker-php-ext-configure gd pgsql -with-pgsql=/usr/local/pgsql exif &amp;&amp; docker-php-ext-install gd mysqli pdo pdo_pgsql pgsql sockets zip mbstring xml intl curl exif &amp;&amp; docker-php-ext-enable imagick exif]: exit code: 1 </code></pre> <p>I don't really know what's wrong here, I just tried to do the same on my previous machine and it was built fine.</p>
[ { "answer_id": 74200033, "author": "Eric Marceau", "author_id": 9716110, "author_profile": "https://Stackoverflow.com/users/9716110", "pm_score": 0, "selected": false, "text": "#!/bin/sh\n\nawk -v inject=\";local2.none;local5.none\" -v postfix=\";local6.none\" '{\n exist=index( $1, in...
2022/10/25
[ "https://Stackoverflow.com/questions/74198958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14481072/" ]
74,198,963
<p>` Unhandled Runtime Error Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.</p> <p>Check the render method of DashboardCards.</p> <p>`</p> <p>Im trying to have icons and labels in a common file constants/drawer</p> <pre class="lang-js prettyprint-override"><code>import DashboardIcon from &quot;@mui/icons-material/Dashboard&quot;; export const MainMenuItems = [ { label: &quot;Dashboard&quot;, icon: &lt;DashboardIcon /&gt;, redirectLink: &quot;/&quot;, }, ]; </code></pre> <p>and in the <code>main.js</code> file importing them and trying to map them.</p> <p>Here i want to pass some props to Icon like <code>&lt;Icon size=&quot;small&quot;/&gt;</code>.</p> <pre class="lang-js prettyprint-override"><code>import { MainMenuItems } from &quot;../constants/drawer.js&quot;; const MainContainer=()=&gt;{ return ( &lt;&gt; {MainMenuItems.map(({label,icon:Icon}) =&gt; { return ( &lt;div&gt; &lt;Icon size=&quot;small&quot;/&gt; &lt;/div&gt; ) ); })} &lt;/&gt; ) } </code></pre>
[ { "answer_id": 74199025, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 2, "selected": true, "text": "Icon" }, { "answer_id": 74199138, "author": "Deepansh Khurana", "author_id": 20333197, "author_pro...
2022/10/25
[ "https://Stackoverflow.com/questions/74198963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11847196/" ]
74,198,968
<p>I have a string that contains a series of dates and other information. I want to identify the most recent date in the string and return the value for &quot;Type of Check&quot; associated with that date.</p> <p>For the below example, the ideal output would be &quot;Type of Check: Balance&quot; since that is the most recent date in the string.</p> <pre><code>var myString = &quot;Date: 04/08/2020, Type of Check: Large, Investors: ABC -- Date: 01/22/2021, Type of Check: Debt, Investors: ABC -- Date: 01/01/2022, Type of Check: Balance, Investors: ABC&quot; </code></pre> <p>I have figured out how to identify the most recent date using the below code, but I have no idea how to return the &quot;Type of Check&quot; value associated with that date.</p> <pre><code>var dates = myString.match(/(\d{1,4}([.\-/])\d{1,2}([.\-/])\d{1,4})/g); const descendingDateOrder = dates.sort((a, b) =&gt; { return new Date(b).getTime() - new Date(a).getTim </code></pre>
[ { "answer_id": 74199025, "author": "Mina", "author_id": 11887902, "author_profile": "https://Stackoverflow.com/users/11887902", "pm_score": 2, "selected": true, "text": "Icon" }, { "answer_id": 74199138, "author": "Deepansh Khurana", "author_id": 20333197, "author_pro...
2022/10/25
[ "https://Stackoverflow.com/questions/74198968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20333236/" ]
74,198,975
<p>I have a stream like this,</p> <pre><code>List&lt;String&gt; test = Arrays.asList(&quot;1&quot;, &quot;2,&quot;, &quot;3&quot;); test.stream().map(t -&gt; { try { validate(t); } catch (Exception e) { throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage(), e); } return true; }) </code></pre> <p>In case of an exception, I would like to store it somewhere, process the next element and then show all exceptions at once. Is this possible?</p>
[ { "answer_id": 74199231, "author": "Gus", "author_id": 535515, "author_profile": "https://Stackoverflow.com/users/535515", "pm_score": 0, "selected": false, "text": "invalidInputs" }, { "answer_id": 74199290, "author": "IamGroot", "author_id": 8327330, "author_profile...
2022/10/25
[ "https://Stackoverflow.com/questions/74198975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20160624/" ]