qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,240,182
<p>Currently the whole thing is red.</p> <p>How would I make this gradient, half the left side red, half blue?</p> <p>That is all I am trying to do in the code.</p> <p><a href="https://i.stack.imgur.com/InPHQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/InPHQ.png" alt="enter image description here" /></a></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>div { width: 640px; height: 340px; background: linear-gradient(45deg, transparent, transparent 7px, red 7px, red 7.5px, transparent 7.5px, transparent 10px), linear-gradient(-45deg, transparent, transparent 7px, red 7px, red 7.5px, transparent 7.5px, transparent 10px); background-size: 10px 10px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;&lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74240428, "author": "Andrei Fedorov", "author_id": 6641198, "author_profile": "https://Stackoverflow.com/users/6641198", "pm_score": 0, "selected": false, "text": "backdrop-filter: hue-rotate(240deg)" }, { "answer_id": 74240685, "author": "G-Cyrillus", "aut...
2022/10/28
[ "https://Stackoverflow.com/questions/74240182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17631451/" ]
74,240,190
<p><strong>Problem:</strong></p> <p>Let's say we have the following list of strings <code>{&quot;Test1.txt&quot;, &quot;Test2.txt&quot;, &quot;Test11.txt&quot;, &quot;Test22.txt&quot;}</code>, sorting them using <code>String::compareTo</code> or <code>Collator::compare</code> would result in following order:</p> <pre><code>Test1.txt Test2.txt Test22.txt Test3.txt </code></pre> <p>Which is inconvenient(arguably), while a more human-friendly outcome is:</p> <pre><code>Test1.txt Test2.txt Test3.txt Test22.txt </code></pre> <p>To resolve this issues we can write our own compare method which is numeric sensitive. But what if we want numeric sensitive sort as well as the benefit of using existing implementation of <code>Collator</code> (or to avoid implementing one) for internationalization?</p> <p>Is there a right way to handle this? or maybe a reliable library that addresses this problem?</p> <p><strong>Other Languages:</strong></p> <p>In Javascript world the <code>Intl.Collator</code>'s constructors accepts a <code>CollatorOption</code> which allows you to set configs to achieve such functionality and more:</p> <pre><code>const usCollator = Intl.Collator(&quot;us&quot;, { numeric: true }); const list = [&quot;Test1.txt&quot;, &quot;Test2.txt&quot;, &quot;Test3.txt&quot;, &quot;Test22.txt&quot;]; list.sort(usCollator.compare); console.log(list); </code></pre>
[ { "answer_id": 74302867, "author": "mrkachariker", "author_id": 7296372, "author_profile": "https://Stackoverflow.com/users/7296372", "pm_score": 0, "selected": false, "text": "RuleBasedCollator" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74240190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8490378/" ]
74,240,196
<p><strong>What i need to do:</strong></p> <pre><code>// Return an array containing the second half of an array // Exclude middle index on odd length arr </code></pre> <p><strong>My code:</strong></p> <pre><code>function secondHalf(arr) { let newArr = []; for (let i = Math.floor(arr.length / 2); i &gt;= 0; i--) { newArr.push(arr[i]); } return newArr; } secondHalf([1, 2]); secondHalf([1]); </code></pre> <p><strong>The output i'm getting:</strong></p> <pre><code>1) Problems secondHalf should return only the second half the array: AssertionError: expected [ 2, 1 ] to deeply equal [ 2 ] + expected - actual [ 2 - 1 ] at Context.&lt;anonymous&gt; (test/problems-specs.js:72:48) at processImmediate (node:internal/timers:466:21) 2) Problems secondHalf should be the exclusive first half: AssertionError: expected [ 1 ] to deeply equal [] + expected - actual -[ - 1 -] +[] at Context.&lt;anonymous&gt; (test/problems-specs.js:75:45) at processImmediate (node:internal/timers:466:21) </code></pre> <p>I've tried so many times, and came across methods like <code>.splice()</code> and <code>.slice()</code> but didn't use them because i need to solve it using only loops. What am i doing wrong?</p>
[ { "answer_id": 74302867, "author": "mrkachariker", "author_id": 7296372, "author_profile": "https://Stackoverflow.com/users/7296372", "pm_score": 0, "selected": false, "text": "RuleBasedCollator" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74240196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16400935/" ]
74,240,253
<p>I have a function that opens a text file and return me a <em>x</em> nested list of strings, I want to convert all elements to integers, but inside <em>x</em> there is another nested list:</p> <p>This is <code>x</code>:</p> <pre><code>[ ['7', '1'], ['1', '6', '4', '1'], ['2', '1', '0', '0'], [ ['1', '0', '4', '5'], ['9', '3', '0', '7'], ['0', '1', '2', '0'] ], [ ['8', '0', '2', '6'], ['6', '3', '8', '8'], ['3', '0', '0', '1'] ] ] </code></pre> <p>I've tried to use the <code>map</code> function:</p> <pre><code>for elems in x: converted = list(map(int, n) for n in elems) </code></pre> <p>Output:</p> <pre><code>[&lt;map object at 0x000002466CC00D60&gt;, &lt;map object at 0x000002466CC010F0&gt;, &lt;map object at 0x000002466CC01180&gt;] </code></pre> <p>Also tried:</p> <pre><code>for elems in x: converted = list(map(int, elems)) </code></pre> <p>Which gave me this error:</p> <pre><code>TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list' </code></pre> <p>Expected output:</p> <pre><code>[ [7, 1], [1, 6, 4, 1], [2, 1, 0, 0], [ [1, 0, 4, 5], [9, 3, 0, 7], [0, 1, 2, 0] ], [ [8, 0, 2, 6], [6, 3, 8, 8], [3, 0, 0, 1] ] ] </code></pre> <p>How can I do this conversion? Thanks in advance for any help.</p>
[ { "answer_id": 74302867, "author": "mrkachariker", "author_id": 7296372, "author_profile": "https://Stackoverflow.com/users/7296372", "pm_score": 0, "selected": false, "text": "RuleBasedCollator" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74240253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20124236/" ]
74,240,256
<p>I am planning to use Cucumber Test with Junit 5 in Maven. So I followed <a href="https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-junit-platform-engine" rel="nofollow noreferrer">cucumber</a> to install different maven dependency. I added a runner class to execute my cucumber tests<br><br></p> <pre><code>package pirate; import org.junit.platform.suite.api.ConfigurationParameter; import org.junit.platform.suite.api.IncludeEngines; import org.junit.platform.suite.api.SelectClasspathResource; import org.junit.platform.suite.api.Suite; import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; @Suite @IncludeEngines(&quot;cucumber&quot;) @SelectClasspathResource(&quot;pirate&quot;) @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = &quot;pirate&quot;) public class Runner {} </code></pre> <p>I also created a new folder name <code>pirate</code> under <code>resources</code> folder and move all <code>.feature</code> files into that new folder. But when I execute <code>mvn clean install</code>, the command fails at testCompile: <a href="https://i.stack.imgur.com/g4p75.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g4p75.png" alt="enter image description here" /></a> It seems like the compiler can't read the package name? Below is my pom.xml</p> <pre><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;org.example&lt;/groupId&gt; &lt;artifactId&gt;onetwothree&lt;/artifactId&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;packaging&gt;jar&lt;/packaging&gt; &lt;name&gt;onetwothree&lt;/name&gt; &lt;url&gt;http://maven.apache.org&lt;/url&gt; &lt;properties&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;/properties&gt; &lt;build&gt; &lt;testSourceDirectory&gt;src/test/java&lt;/testSourceDirectory&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;3.8.1&lt;/version&gt; &lt;configuration&gt; &lt;source&gt;11&lt;/source&gt; &lt;target&gt;11&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;3.0.0-M5&lt;/version&gt; &lt;configuration&gt; &lt;properties&gt; &lt;configurationParameters&gt; cucumber.junit-platform.naming-strategy=long &lt;/configurationParameters&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt; &lt;artifactId&gt;junit-jupiter&lt;/artifactId&gt; &lt;version&gt;5.9.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.cucumber&lt;/groupId&gt; &lt;artifactId&gt;cucumber-java&lt;/artifactId&gt; &lt;version&gt;7.8.1&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;io.cucumber&lt;/groupId&gt; &lt;artifactId&gt;cucumber-junit-platform-engine&lt;/artifactId&gt; &lt;version&gt;7.8.1&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.junit.platform&lt;/groupId&gt; &lt;artifactId&gt;junit-platform-suite&lt;/artifactId&gt; &lt;version&gt;1.9.0&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/project&gt; </code></pre> <p>My project structure is:</p> <p><a href="https://i.stack.imgur.com/ANPh6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ANPh6.png" alt="enter image description here" /></a></p> <p>but if I comment out <code>cucumber-junit-platform-engine</code> dependency in <code>pom.xml</code>, the error is gone but it won't run the cucumber tests. Did I miss something here? <br><br></p> <p>Not sure if it's related, but one of the error messages is like:</p> <pre><code>[ERROR] error reading /Users/xx/.m2/repository/org/junit/platform/junit-platform-engine/1.9.1/junit-platform-engine-1.9.1.jar; zip file is empty [ERROR] /Users/xx/Desktop/zz/src/test/java/pirate/Runner.java:[1,1] cannot access pirate ZipException opening &quot;junit-platform-engine-1.9.1.jar&quot;: zip END header not found </code></pre>
[ { "answer_id": 74302867, "author": "mrkachariker", "author_id": 7296372, "author_profile": "https://Stackoverflow.com/users/7296372", "pm_score": 0, "selected": false, "text": "RuleBasedCollator" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74240256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13062745/" ]
74,240,261
<p><strong>disclaimer</strong> this is not my code and this code is from <a href="https://www.javatpoint.com/remove-duplicate-elements-from-an-array-in-c" rel="nofollow noreferrer">Remove Duplicate Elements from an Array in C - Javatpoint</a></p> <p>What I want to know is in the Example 2 coding part. (I edit code a bit for me or you can see the code clearly.)</p> <pre><code>/* program to delete the duplicate elements from sorted array in C. */ #include &lt;stdio.h&gt; int duplicate_element ( int arr[], int num) { // check num is equal to 0 and num == 1 if (num == 0 || num == 1) { return num; } // create temp array to store same number int temp [num]; // declare variable int i, j = 0; // use for loop to check duplicate element for (i = 0; i &lt; num - 1; i++) { // check the element of i is not equal to (i + 1) next element if (arr [i] != arr[i + 1]) { temp[j++] = arr[i]; } } temp[j++] = arr[ num - 1]; // check the original array's elements with temporary array's elements for (i = 0; i &lt; j; i++) { arr[i] = temp[i]; } return j; } int main () { int num; printf (&quot; Define the no. of elements of the array: &quot;); scanf (&quot; %d&quot;, &amp;num); int arr[num], i; printf (&quot; Enter the elements: &quot;); // use loop to read elements one by one for ( i = 0; i &lt; num; i++) { scanf (&quot; %d&quot;, &amp;arr[i]); } printf (&quot; \n Elements before removing duplicates: &quot;); for ( i = 0; i &lt; num; i++) { printf (&quot; %d&quot;, arr[i]); } num = duplicate_element (arr, num); // print array after removing duplicates elements printf (&quot; \n Display array's elements after removing duplicates: &quot;); for ( i = 0; i &lt; num; i++) { printf (&quot; %d&quot;, arr[i]); } return 0; } </code></pre> <p>Here's the question, what does all j++ in function duplicate_element do? (If possible I would like to know what the code is doing since line // use for loop to check duplicate element until before return too. This part I'm just curious if I know it correctly or not.)</p> <p>This is my understanding (<strong>j is the final size of arr[]</strong>). In the first question, when executed</p> <p>j right now is 0</p> <p>temp[j++]</p> <p>is it plus the value of j by 1 first then assign value arr[i] to temp[1]. (Does this right?)</p> <p>The second question, in the first for loop checks when the value in arr[i] is not equal to the value in arr[i + 1] then assign value in temp[j++] with value in arr[i] until for loop is over then assign temp[j++] with arr[num - 1]</p> <p>(j++ right now is dependent on the if condition for example when all value is not equal to the value of j++ == value of num - 1 and num - 1 is equal to the last value of arr)</p> <p>and in the last for loop, it assigns every value in Array arr with Array temp. (Does this right?)</p>
[ { "answer_id": 74240340, "author": "Some programmer dude", "author_id": 440558, "author_profile": "https://Stackoverflow.com/users/440558", "pm_score": 2, "selected": false, "text": "temp[j++] = arr[i];\n" }, { "answer_id": 74240917, "author": "Vlad from Moscow", "author_...
2022/10/28
[ "https://Stackoverflow.com/questions/74240261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20079730/" ]
74,240,319
<p>I am trying to set my machines javac version to 11 from 18.0.2 and I'm doing the following steps</p> <ol> <li>open ~/.zshenv</li> <li>export JAVA_HOME=$(/usr/libexec/java_home -v11)</li> <li>source ~/.zshenv</li> </ol> <p>When I check the version, I still get it as 18.0.2. Not sure what I am doing wrong here. Could someone please help me with this? Been stuck on this forever.</p>
[ { "answer_id": 74241474, "author": "harry-potter", "author_id": 4592796, "author_profile": "https://Stackoverflow.com/users/4592796", "pm_score": 0, "selected": false, "text": "export JAVA_HOME=`/usr/libexec/java_home -v 11` \n" }, { "answer_id": 74245647, "author": "Andreas ...
2022/10/28
[ "https://Stackoverflow.com/questions/74240319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6466023/" ]
74,240,336
<p>I want to remove all digits, except if the digits make up one of the special substrings. In the example below, my special substring that should skip the digit removal are 1s, 2s, s4, 3s. I think I need to use a negative lookahead</p> <pre><code>s = &quot;a61s8sa92s3s3as4s4af3s&quot; pattern = r&quot;(?!1s|2s|s4|3s)[0-9\.]&quot; re.sub(pattern, ' ', s) </code></pre> <p>To my understanding, the pattern above is:</p> <ul> <li>starting from the end ([]) match all digits including decimals</li> <li>only do that if we have not matched the patter after ?!</li> <li>which are 1s, 2s, s4, OR 3s (| = OR)</li> </ul> <p>It all makes sense until you try it. The sample <code>s</code> above returns <code>a 1s sa 2s3s as s af3s</code>, which suggests that all the exclusion patterns are working except if the digit is at the end of the special substring, in which case it still gets matched?!</p> <p>I believe this operation should return <code>a 1s sa 2s3s as4s4af3s</code>, how to fix my pattern?</p>
[ { "answer_id": 74240377, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "import re\ns = \"a61s8sa92s3s3as4s4af3s\"\npattern = r\"(1s|2s|s4|3s)|[\\d.]\"\nprint( re.sub(pattern, lambd...
2022/10/28
[ "https://Stackoverflow.com/questions/74240336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11748395/" ]
74,240,351
<p>I am trying to click the log in button from <a href="https://search.connectourkids.org" rel="nofollow noreferrer">https://search.connectourkids.org</a></p> <pre><code>driver = webdriver.Chrome(&quot;/Users/nicknavarro/Documents/DVS/chromedriver&quot;) url = 'https://search.connectourkids.org' driver.get(url) print (&quot;Opened Website&quot;) sleep(30) login = driver.find_element_by_css_selector(&quot;body &gt; app-root &gt; div &gt; router-outlet &gt; div &gt; app-home &gt; div &gt; div &gt; div &gt; app-header &gt; div &gt; div &gt; div &gt; div &gt; a.button &quot;).click() </code></pre> <p>but I keep getting this error:</p> <pre class="lang-none prettyprint-override"><code>NoSuchElementException: no such element: Unable to locate element: {&quot;method&quot;:&quot;css selector&quot;,&quot;selector&quot;:&quot;body &gt; app-root &gt; div &gt; router-outlet &gt; div &gt; app-home &gt; div &gt; div &gt; div &gt; app-header &gt; div &gt; div &gt; div &gt; div &gt; a.button &quot;} (Session info: chrome=107.0.5304.87) </code></pre> <p>I am expecting to log in, input a password and username and search for names.</p>
[ { "answer_id": 74240377, "author": "Wiktor Stribiżew", "author_id": 3832970, "author_profile": "https://Stackoverflow.com/users/3832970", "pm_score": 3, "selected": true, "text": "import re\ns = \"a61s8sa92s3s3as4s4af3s\"\npattern = r\"(1s|2s|s4|3s)|[\\d.]\"\nprint( re.sub(pattern, lambd...
2022/10/28
[ "https://Stackoverflow.com/questions/74240351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19522869/" ]
74,240,360
<p>Suppose we have the following code. It displays a button, and when the user clicks on it, the button disappears.</p> <pre><code>@Composable fun ButtonThatDisappearsOnClick() { var showButton by remember { mutableStateOf(true) } if (showButton) { Button(onClick = { check(showButton) { &quot;onClick shouldn't be called for a hidden button&quot; } // !!! showButton = false }) { Text(&quot;My button&quot;) } } } </code></pre> <p>I suspect that the <code>check</code> call above may fail if the user clicks the button <em>twice</em> really quickly:</p> <ul> <li>The user clicks the button, <code>shouldShowButton</code> is set to <code>false</code>. Since the value in a mutable state was updated, a recomposition is scheduled.</li> <li>The user clicks the button very quickly again <strong>before</strong> the views have been recomposed. Thus, the <code>onClick</code> function will fire the second time, and the <code>check</code> call will fail.</li> </ul> <p>I have not been able to reproduce this in practice, so I am wondering if such a behavior is indeed possible.</p>
[ { "answer_id": 74242627, "author": "Thracian", "author_id": 5457853, "author_profile": "https://Stackoverflow.com/users/5457853", "pm_score": 3, "selected": true, "text": "SideEffect" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74240360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6120487/" ]
74,240,386
<p>This is the program I need to make,</p> <p>Make a class that represents a file. This class will have the ability to calculate the number of lines in that file and the ability to search through the file. The getNumLinesThatContain method will take a bit of text and determine how many lines contain that text. Make the comparison not care about case. Example: if the user is searching for hello and a line contains the text hello hello hello then this counts as one. Use the contains method defined on Strings to help with this. Class Name FileStats Fields</p> <ul> <li>filename : String Methods</li> </ul> <ul> <li>FileStats(filename : String)</li> <li>getNumLinesThatContain(key : String) : int</li> <li>getNumLines() : int</li> </ul> <p>This is what I have so far,</p> <pre><code>import java.io.File; import java.io.FileNotFoundException; import java.util.Objects; import java.util.Scanner; public class FileStats { private String filename; Scanner inputFile; public FileStats(String f) { filename = f; } public int getNumLines() throws FileNotFoundException { //make a variable to hold the filename File fileObj = new File(filename); inputFile = new Scanner(fileObj); //keep track of the number lines int numLines = 0; //while there's more stuff to read... while (inputFile.hasNext()) { //read a line String line = inputFile.nextLine(); //keep track of that line numLines++; } //close the file inputFile.close(); //return the result return numLines; } public int getNumLinesThatContain(String key){ // variable to keep track of file name File fileObj = new File(filename); inputFile = new Scanner(filename); //keep track of the number lines int numLines = 0; //while there is more stuff to read while (inputFile.hasNext()){ //read a line String line = inputFile.nextLine(); //keep track of the line if word //this is where I think the problem is if(line.toUpperCase().contains(key.toUpperCase())) { numLines++; } } inputFile.close(); return numLines; } } </code></pre> <p>For the method getNumLinesThatContain I just get 1s and 0s when I run the file. I have tried changing the if statement to one that compares line and key, to one that sees if they are equal, and the one shown checks to see if the line contains the key. I can't seem to figure out how to get the counter to count the lines that contain the key correctly. Please help.</p>
[ { "answer_id": 74240456, "author": "Roh", "author_id": 19461429, "author_profile": "https://Stackoverflow.com/users/19461429", "pm_score": 2, "selected": false, "text": "inputFile = new Scanner(filename);\n" }, { "answer_id": 74240526, "author": "oleg.cherednik", "author_...
2022/10/28
[ "https://Stackoverflow.com/questions/74240386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20344740/" ]
74,240,388
<p>I am working on a basic JavaScript program that plays sounds when I click buttons. I am using a switch to be able to tell which sound should be played. I am also using event listeners on each button to respond to clicks.</p> <p>When I do something like:</p> <pre><code>currentButton.addEventListener(&quot;click&quot;, function() { // code here }) </code></pre> <p>It works fine. However, I want to try defining the function outside of the event listener, and then passing it to the event listener.</p> <p>I have a simplified example here:</p> <pre><code>function setPathAndPlay(currentButton) { let audioPath; switch (currentButton.innerHTML) { case &quot;w&quot;: { audioPath = &quot;./sounds/crash.mp3&quot;; break; } } const audio = new Audio(audioPath); audio.play(); } for (let currentButton of drumArray) { currentButton.addEventListener(&quot;click&quot;, setPathAndPlay(currentButton)) } </code></pre> <p>This does not work. I believe what is happening is <code>setPathAndPlay(currentButton)</code> is directly running as it is a function call, which is causing problems. How can I pass the <code>currentButton</code> to <code>setPathAndPlay</code> though? Since that function needs access to the button.</p> <p>I'm not sure what to try to fix this. I believe something with an arrow function or some sort of wrapper function may work. I am looking to find a solution as simple as possible to help me understand. Thank you!</p>
[ { "answer_id": 74240456, "author": "Roh", "author_id": 19461429, "author_profile": "https://Stackoverflow.com/users/19461429", "pm_score": 2, "selected": false, "text": "inputFile = new Scanner(filename);\n" }, { "answer_id": 74240526, "author": "oleg.cherednik", "author_...
2022/10/28
[ "https://Stackoverflow.com/questions/74240388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19996942/" ]
74,240,394
<p>I need to write a recursive function that applies the following operations:</p> <ol> <li>If <em>a = 0 or b = 0</em>, return <em>[a, b]</em>. Otherwise, go to step (2);</li> <li>If <em>a &gt;= 2b</em>, set <em>a = a - 2b</em>, and repeat step (1). Otherwise, go to step (3);</li> <li>If <em>b &gt;= 2a</em>, set <em>b = b - 2a</em>, and repeat step (1). Otherwise, return <em>[a, b]</em>.</li> </ol> <p>Some examples of what I want to achieve:</p> <ul> <li>input(6, 19) returns [6, 7]</li> <li>input(2, 1) returns [0, 1]</li> <li>input(22, 5) also returns [0, 1]</li> <li>input (8796203,7556) returns [1019,1442]</li> </ul> <p>I can't get 3rd and 4th examples correct. The problem is, since the function must be recursive, I cannot use a for a loop.</p> <p>My code so far:</p> <pre><code>if a == 0 or b == 0: return[a, b] if a &gt;= 2 * b: a -= 2 * b if a == 0 or b == 0: return [a, b] if b &gt;= 2 * a: b -= 2 * a if a == 0 or b == 0: return [a, b] return [a, b] </code></pre>
[ { "answer_id": 74240477, "author": "lmiguelvargasf", "author_id": 3705840, "author_profile": "https://Stackoverflow.com/users/3705840", "pm_score": 3, "selected": true, "text": "def f(a, b):\n if a == 0 or b == 0: # step 1\n return [a, b]\n\n if a >= 2 * b: # step 2\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74240394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20234241/" ]
74,240,396
<p>I'm trying to extract the text between the headings in a markdown file. The markdown file will look something like this:</p> <pre><code>### Description This is a description ### Changelog This is my changelog ### Automated Tests added - Test 1 - Test 2 ### Acceptance Tests performed ### Blurb Concise summary of what this PR is. </code></pre> <p>Is there anyway I can return all of the groups so that:</p> <ul> <li>group 1 = &quot;This is a description&quot;</li> <li>group 2 = &quot;This is my changelog&quot;</li> </ul> <p>...and so on</p>
[ { "answer_id": 74240609, "author": "Reza Saadati", "author_id": 4641680, "author_profile": "https://Stackoverflow.com/users/4641680", "pm_score": 3, "selected": true, "text": "^[^#]+" }, { "answer_id": 74240620, "author": "mohsyn", "author_id": 5647103, "author_profil...
2022/10/28
[ "https://Stackoverflow.com/questions/74240396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3456446/" ]
74,240,402
<p>I have a problem about sending any request to the relevant service through api gateway.</p> <p>I have an issue after adding auth service.</p> <p>What I really want to do is to send any request to other service after authentication.</p> <p>I think there can be problem in api gateway but I couldn't solve it?</p> <p>Before starting to run all services, run zipkin and redis on docker. Here are their commands as shown belowed.</p> <pre><code>docker run -d -p 9411:9411 openzipkin/zipkin docker run -d --name redis -p 6379:6379 redis </code></pre> <p>Here is the error message shown below.</p> <pre><code>An expected CSRF token cannot be found (403 Forbidden) </code></pre> <p>How can I do that?</p> <p>Here is the link of example : <a href="https://github.com/Rapter1990/microservicecoursedailybuffer" rel="nofollow noreferrer">Link</a></p> <p>Here is the screenshots : <a href="https://drive.google.com/drive/folders/1BCMSj9STszd-GaHWJZE4a0IuLpUcXBxj?usp=sharing" rel="nofollow noreferrer">Link</a></p>
[ { "answer_id": 74240609, "author": "Reza Saadati", "author_id": 4641680, "author_profile": "https://Stackoverflow.com/users/4641680", "pm_score": 3, "selected": true, "text": "^[^#]+" }, { "answer_id": 74240620, "author": "mohsyn", "author_id": 5647103, "author_profil...
2022/10/28
[ "https://Stackoverflow.com/questions/74240402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5719229/" ]
74,240,414
<p>here is my code</p> <pre><code>typedef struct{ double x; double y; } point; typedef struct{ int hour; int minute; int second; } time; typedef struct{ point position; time interval;} record; </code></pre> <pre><code>record r[3] = {{{{1},{1}}, {{1},{1},{0}}}, {{{2},{1}}, {{1},{1},{1}}}, {{{2},{2}}, {{1},{1},{2}}}}; </code></pre> <p>I think I used the correct syntax, but I tried removing the outer brackets too</p>
[ { "answer_id": 74240609, "author": "Reza Saadati", "author_id": 4641680, "author_profile": "https://Stackoverflow.com/users/4641680", "pm_score": 3, "selected": true, "text": "^[^#]+" }, { "answer_id": 74240620, "author": "mohsyn", "author_id": 5647103, "author_profil...
2022/10/28
[ "https://Stackoverflow.com/questions/74240414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361377/" ]
74,240,448
<p>I want to return two widgets when one condition is <code>true</code>. Something like this:</p> <pre><code>Row( children: [ ... if (session.server.autoVenta) SizedBox( width: size.width * 0.16, child: const TextPrimary( text: &quot;N° Doc:&quot;, ), ), if (session.server.autoVenta) SizedBox( width: size.width * 0.24, child: Text(order.documento), ), ] ) </code></pre> <p>But using only one <code>if</code>.</p> <p>I've searched on google but I couldn't find anything.</p>
[ { "answer_id": 74240480, "author": "Mostafa Soliman", "author_id": 11044929, "author_profile": "https://Stackoverflow.com/users/11044929", "pm_score": 3, "selected": true, "text": "Row(\n children: [\n if (true) ...[\n Widget(),\n Widget(),\n ],\n Widget(),\n ],\n)\n...
2022/10/28
[ "https://Stackoverflow.com/questions/74240448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13542764/" ]
74,240,457
<p>I've been searching for this problem on Google for a while now and can't seem to understand the issue. I am using ejs. It does work when I manually type it on the address bar <code>localhost:3000/home</code> this works, but using passport.js and setting home as my successRedirect, just gives me an error including the failureRedirect.</p> <pre><code>app.set(&quot;view engine&quot;, &quot;ejs&quot;) app.use(express.static(&quot;views&quot;)) app.use(express.urlencoded({ extended: false })) app.get(&quot;/home&quot;, (_, res) =&gt; res.render(&quot;home&quot;)) app.get(&quot;/login&quot;, (_, res) =&gt; res.render(&quot;login&quot;)) app.post(&quot;/login&quot;, passport.authenticate(&quot;local&quot;, { successRedirect: &quot;/home&quot;, failureRedirect: &quot;/login&quot;, failureFlash: true, })) </code></pre> <pre><code>const response = await fetch(&quot;/login&quot;, { method: &quot;POST&quot;, body: { [username.id]: usernameValue, [password.id]: passwordValue, }, }) const result = await response.json() if (result.id) localStorage.setItem(&quot;loginId&quot;, result.id) if (result.href) window.location.href = result.href </code></pre> <p>I expected it to show the home page.</p>
[ { "answer_id": 74240522, "author": "Farhan khan", "author_id": 20361000, "author_profile": "https://Stackoverflow.com/users/20361000", "pm_score": -1, "selected": false, "text": "app.post('/login', \n passport.authenticate('local', passport.authenticate(\"local\", {\n successRedirect...
2022/10/28
[ "https://Stackoverflow.com/questions/74240457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17060044/" ]
74,240,463
<p>I need to create a Panda Data frame for Pokémon's using a dictionary which needs to contain the attribute name (Ex: such as &quot;height&quot; of Chameleon and Charmander) as the key and the respective value (Ex: Height value of Chameleon and Charmander as 11 and 6) as the value.</p> <p>To start with, my code needs to have multiple lists for each attribute I need: Name, height, and Type. These lists should be added as keys and values to the dictionary in order to create a data frame.</p> <pre><code>import requests import json import pandas as pd pokemons = [&quot;charmeleon&quot;,&quot;charmander&quot;] name, height, weight, types_l = [],[],[],[] for pokemon in pokemons: res = requests.get(f&quot;https://pokeapi.co/api/v2/pokemon/{pokemon.lower()}&quot;) data = json.loads(res.text) name.append(pokemon) height.append(data[&quot;height&quot;]) types = (data[&quot;types&quot;]) for type in types: types_l.append(type['type']['name']) poke_dictionary = { &quot;Name&quot; : name, &quot;Height&quot; : height, &quot;Weight&quot; : weight, &quot;Type&quot; : types_l } print(poke_dictionary) df_pokedata = pd.DataFrame(poke_dictionary) print(df_pokedata) </code></pre> <p>With the Pokémon's - Chameleon and Charmander, the output of the dictionary is as below. Notice that the length of the values in the dictionary is the same</p> <pre><code>{'Name': ['charmeleon', 'charmander'], 'Height': [11, 6], 'Type': ['fire', 'fire']} </code></pre> <p>However, some Pokémons have multiple types (For example: Bulbasaur which is Grass and Poison). Hence the dictionary with bulbasaur and charmander becomes the below. Notice different length of values as seen in type</p> <pre><code>{'Name': ['bulbasaur', 'charmander'], 'Height': [7, 6], 'Type': ['grass', 'poison', 'fire']} </code></pre> <p>In order for me to get this into the data frame, the length of values needs to be identical, and hence I will need to create multiple lists inside a list such that each list inside this list is taken as a value as shown below:</p> <pre><code>{'Name': ['bulbasaur', 'charmander'], 'Height': [7, 6], 'Type': [['grass', 'poison'], ['fire']]} </code></pre>
[ { "answer_id": 74240522, "author": "Farhan khan", "author_id": 20361000, "author_profile": "https://Stackoverflow.com/users/20361000", "pm_score": -1, "selected": false, "text": "app.post('/login', \n passport.authenticate('local', passport.authenticate(\"local\", {\n successRedirect...
2022/10/28
[ "https://Stackoverflow.com/questions/74240463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361312/" ]
74,240,487
<p>I am using the new swift charts framework to display some data. In seeking to manually control the frequency of the x-axis AxisValueLabels, as well as adjust the color, I implemented the following:</p> <pre><code>AxisMarks(values: .automatic(desiredCount: 11, roundLowerBound: true, roundUpperBound: true)) { _ in AxisGridLine(stroke: .init(lineWidth: 1)).foregroundStyle(Color.orange) AxisValueLabel().foregroundStyle(Color.orange).font(.subheadline).offset(x: -10) } } </code></pre> <p>I would like to show on value for each x-axis value (there are 11 points and it is only showing 10). I have tried countless things and can not get it to show as it should by adjusting the desiredCount parameter. Would appreciate any help in this matter..</p> <pre><code>import SwiftUI import Foundation import Charts struct FakeData: Codable { var questionAndAnswers: [Int: Int] var timePerQuestion: [Double] var date: Date = .now } extension FakeData { static let oneFakeInstance = FakeData(questionAndAnswers: [1875: 1875, 1890: 1890, 1980: 1980, 2112: 2112, 2726: 2726, 4088: 4088, 4284: 4284, 4784: 4784, 4800: 4800, 663: 663, 1098:1098], timePerQuestion: [ 28.700000000000138, 11.600000000000165, 12.00000000000017, 25.599999999999376, 11.999999999999318, 19.19999999999891, 12.799999999999272, 7.199999999999605, 11.699999999999335, 39.299999999997766,19.299999999997766 ]) } struct CH1: View { func convertToShowable(_ QuizquestionAnswers: [Int: Int] = FakeData.oneFakeInstance.questionAndAnswers, _ quizTimes: [Double] = FakeData.oneFakeInstance.timePerQuestion) -&gt; [Int: Double] { var time_per_question: [Int: Double] = [:] for (index, key_value) in QuizquestionAnswers.enumerated() { if key_value.value == key_value.key { time_per_question[index] = quizTimes[index] } } return time_per_question } var body: some View { ZStack { Color.black.edgesIgnoringSafeArea(.all) VStack { Chart { ForEach(convertToShowable().sorted(by: {$0.key &lt; $1.key}), id: \.key) { key, value in BarMark(x: .value(&quot;Question&quot;, key), y: .value(&quot;Time&quot;, value)) .foregroundStyle(Color.white) } } .chartYAxis { AxisMarks(values: .automatic) { _ in AxisValueLabel().foregroundStyle(Color.orange).offset(x: 10).font(.subheadline) } } .chartXAxis { AxisMarks(values: .automatic(desiredCount: 11, roundLowerBound: true, roundUpperBound: true)) { _ in AxisGridLine(stroke: .init(lineWidth: 1)).foregroundStyle(Color.orange) AxisValueLabel().foregroundStyle(Color.orange).font(.subheadline).offset(x: -10) } } .frame(width: 350, height: 250)}}}} ```[![You can see there should be a 10 here, but there is nothing][1]][1] [1]: https://i.stack.imgur.com/sYfXa.png </code></pre>
[ { "answer_id": 74240522, "author": "Farhan khan", "author_id": 20361000, "author_profile": "https://Stackoverflow.com/users/20361000", "pm_score": -1, "selected": false, "text": "app.post('/login', \n passport.authenticate('local', passport.authenticate(\"local\", {\n successRedirect...
2022/10/28
[ "https://Stackoverflow.com/questions/74240487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17935882/" ]
74,240,495
<p>I have an array of dates and values and want to calculate in a formula at what date a certain value will be reached or be bigger.</p> <p>Example:</p> <pre><code>1/1/2022 10 1/10/2022 13 1/20/2022 16 1/30/2022 19 </code></pre> <p>At what date will 50 be reached?</p> <p>GS has formulas to forecast the value for a date, but I know the value - I need the date.</p> <p>Any help appriciated.</p>
[ { "answer_id": 74240522, "author": "Farhan khan", "author_id": 20361000, "author_profile": "https://Stackoverflow.com/users/20361000", "pm_score": -1, "selected": false, "text": "app.post('/login', \n passport.authenticate('local', passport.authenticate(\"local\", {\n successRedirect...
2022/10/28
[ "https://Stackoverflow.com/questions/74240495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19862779/" ]
74,240,498
<p>I'm writing a Job class, and to ensure that this job can only be executed once, I have introduced a custom &quot;Locking&quot; mechanism.</p> <p>The function looks like this:</p> <pre><code>public async Task StartAsync(CancellationToken cancellationToken) { if (this.@lock.IsLocked()) { return; } this.@lock.Lock(); await this.ExecuteAsync(new JobExecutionContext(cancellationToken)) .ConfigureAwait(false); this.@lock.Unlock(); } </code></pre> <p>Now, when I write tests, I should test the external observable behavior, rather than testing implementation details, so I have the following tests at the moment:</p> <pre><code>[Theory(DisplayName = &quot;Starting a `Job` (when the lock is locked), does NOT execute it.&quot;)] [AutoDomainData] public async Task StartingWithLockedLockDoesLockNotExecuteIt([Frozen] Mock&lt;ILock&gt; lockMock, [Frozen] Mock&lt;Job&gt; jobMock) { // VALIDATION. ILock @lock = lockMock?.Object ?? throw new ArgumentNullException(nameof(lockMock)); Job job = jobMock?.Object ?? throw new ArgumentNullException(nameof(jobMock)); // MOCK SETUP. _ = lockMock.Setup(x =&gt; x.IsLocked()) .Returns(true); // ACT. await job.StartAsync(new CancellationToken()) .ConfigureAwait(false); // ASSERT. jobMock.Verify(job =&gt; job.ExecuteAsync(It.IsAny&lt;IExecutionContext&gt;()), Times.Never); } [Theory(DisplayName = &quot;Starting a `Job` (when the lock is NOT locked), does lock the lock.&quot;)] [AutoDomainData] public async Task StartingWithNotLockedLockDoesExecuteIt([Frozen] Mock&lt;ILock&gt; lockMock, [Frozen] Mock&lt;Job&gt; jobMock) { // VALIDATION. ILock @lock = lockMock?.Object ?? throw new ArgumentNullException(nameof(lockMock)); Job job = jobMock?.Object ?? throw new ArgumentNullException(nameof(jobMock)); // MOCK SETUP. _ = lockMock.Setup(x =&gt; x.IsLocked()) .Returns(false); // ACT. await job.StartAsync(new CancellationToken()) .ConfigureAwait(false); // ASSERT. jobMock.Verify(job =&gt; job.ExecuteAsync(It.IsAny&lt;IExecutionContext&gt;()), Times.Once); } </code></pre> <p><em>Note: I'm using <code>AutoFixture</code>, but I left the boilerplate code out.</em></p> <p>Now, I have the following cases covered:</p> <ul> <li>When the lock is locked, the job is NOT executed.</li> <li>When the lock is NOT locked, the job is executed.</li> </ul> <p>But I'm missing the following important case:</p> <ul> <li>Guarantee, that during the duration of the exceution, the lock is active.</li> </ul> <p>How can I properly test this? I have the feeling that the design should be updated, but I don't exactly know how.</p> <p>Any advice?</p>
[ { "answer_id": 74240522, "author": "Farhan khan", "author_id": 20361000, "author_profile": "https://Stackoverflow.com/users/20361000", "pm_score": -1, "selected": false, "text": "app.post('/login', \n passport.authenticate('local', passport.authenticate(\"local\", {\n successRedirect...
2022/10/28
[ "https://Stackoverflow.com/questions/74240498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2585090/" ]
74,240,527
<p>I'm trying to build a flutter view that loads a list of items ('cost codes' in the code snippet) from a database call. This code works elsewhere in my project where I already have data in the database, but it fails when it tries to read data from an empty node. I can provide dummy data or sample data for my users on first run, but they might delete the data before adding their own, which would cause the app to crash the next time this view loads.</p> <p>What's the proper way to deal with a potentially empty list in a StreamBuilder?</p> <pre><code> @override Widget build(BuildContext context) { return StreamBuilder( stream: dbPathRef.onValue, builder: (context, snapshot) { final costCodes = &lt;CostCode&gt;[]; if (!snapshot.hasData) { return Center( child: Column( children: const [ Text( 'No Data', style: TextStyle( color: Colors.white, ), ) ], ), ); } else { final costCodeData = // code fails on the following line with the error // 'type &quot;Null&quot; is not a subtype of type &quot;Map&lt;Object?, dynamic&gt;&quot; in type cast' (snapshot.data!).snapshot.value as Map&lt;Object?, dynamic&gt;; costCodeData.forEach( (key, value) { final dataLast = Map&lt;String, dynamic&gt;.from(value); final account = CostCode( id: dataLast['id'], name: dataLast['name'], ); costCodes.add(account); }, ); return ListView.builder( shrinkWrap: false, itemCount: costCodes.length, itemBuilder: (BuildContext context, int index) { return ListTile( title: Text( costCodes[index].name, style: const TextStyle(color: Colors.white), ), subtitle: Text( costCodes[index].id, style: const TextStyle(color: Colors.white), ), ); }, ); } }, ); } </code></pre>
[ { "answer_id": 74240522, "author": "Farhan khan", "author_id": 20361000, "author_profile": "https://Stackoverflow.com/users/20361000", "pm_score": -1, "selected": false, "text": "app.post('/login', \n passport.authenticate('local', passport.authenticate(\"local\", {\n successRedirect...
2022/10/28
[ "https://Stackoverflow.com/questions/74240527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302999/" ]
74,240,531
<p>I have a dataframe in the following format:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Category</th> <th>Date</th> <th>Count</th> <th>Comment</th> </tr> </thead> <tbody> <tr> <td>Blue</td> <td>10/24</td> <td>7</td> <td>None</td> </tr> <tr> <td>Red</td> <td>10/25</td> <td>10</td> <td>None</td> </tr> <tr> <td>Green</td> <td>10/23</td> <td>5</td> <td>None</td> </tr> <tr> <td>Red</td> <td>10/24</td> <td>2</td> <td>None</td> </tr> <tr> <td>Blue</td> <td>10/23</td> <td>3</td> <td>None</td> </tr> <tr> <td>Red</td> <td>10/26</td> <td>11</td> <td>None</td> </tr> <tr> <td>Green</td> <td>10/26</td> <td>3</td> <td>None</td> </tr> </tbody> </table> </div> <p>I want to take the data out of that dataframe and convert it to a dataframe like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Category</th> <th>10/23</th> <th>10/24</th> <th>10/25</th> <th>10/26</th> </tr> </thead> <tbody> <tr> <td>Blue</td> <td>3</td> <td>7</td> <td></td> <td></td> </tr> <tr> <td>Red</td> <td></td> <td>2</td> <td>10</td> <td>11</td> </tr> <tr> <td>Green</td> <td>5</td> <td></td> <td></td> <td>3</td> </tr> </tbody> </table> </div> <p>It's not just a matter of transposing my data. I think I have to convert some of my columns back into dicts/lists and then take those arrays and put them back into a dataframe. I'm thinking something like making a list of objects formatted like this</p> <p>{Date : {category : count } }</p> <p>I'm just not sure if that's the most efficient and I'm also not sure what the best way to turn that back into a dataframe would be.</p> <p>Looking for some advice. I'm trying to display these tables in a Flask app so it's also possible I dont convert it back into a dataframe but display it using HTML table constructions, but I haven't been able to figure out the correct Jinja syntax.</p> <p>My last option would be to take my data collection functions and output them into both table layouts so I dont have to do any transformations at all, but storing that data in two formats seems like it would be inefficient.</p> <p>Any advice would be appreciated.</p>
[ { "answer_id": 74240817, "author": "Mengxiao Li", "author_id": 11629858, "author_profile": "https://Stackoverflow.com/users/11629858", "pm_score": 2, "selected": false, "text": "df = pd.DataFrame(\n {\n 'Category': ['blue', 'red', 'green', 'red', 'blue', 'red', 'green'],\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74240531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5588062/" ]
74,240,536
<p>I have a simple dataframe like the following:</p> <pre><code>ID, Type, a, b, c, d, e, f, etc. ob1, 1, 1, 2, 3, 4, 5, 6, etc. ob1, 2, 3, 4, 5, 6, 7, 1, etc. </code></pre> <p>I need to add the values of every 3 columns together, to produce new columns with the summed values. This would produce the following output:</p> <pre><code>ID, Type, sum1, sum2, etc. ob1, 1, 6, 15, etc. ob1, 2, 12, 14, etc. </code></pre> <p>Using sequencing, I can do this manually for individual columns, but because I have many columns, how can I perform this summation automatically for every 3 columns (after a set starting point)?</p>
[ { "answer_id": 74240669, "author": "wesleysc352", "author_id": 14212922, "author_profile": "https://Stackoverflow.com/users/14212922", "pm_score": 1, "selected": false, "text": "df" }, { "answer_id": 74240859, "author": "M--", "author_id": 6461462, "author_profile": "...
2022/10/28
[ "https://Stackoverflow.com/questions/74240536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18574641/" ]
74,240,549
<p>In my program I get a list that contains an indefinite number of lists, each of these having 4 elements.</p> <p>Example:</p> <pre><code>List=[[70,70,70,70],[1,1,1,1],[2,2,2,2],[4,4,4,4]] </code></pre> <p>I would like by means of a function to be able to subtract the values and have the result instead. Resulting:</p> <pre><code>Result_List=[[70,70,70,70],[69,69,69,69],[67,67,67,67],[63,63,63,63]] </code></pre> <p>The idea would be that the result of the first row is the same, in the second row the subtraction of the first row minus the second is done, in the third row the values of the second row are done minus the third and so on regardless the number of rows. The number of columns is constant. How could I do it?</p>
[ { "answer_id": 74240632, "author": "lmiguelvargasf", "author_id": 3705840, "author_profile": "https://Stackoverflow.com/users/3705840", "pm_score": 2, "selected": false, "text": "List = [[70,70,70,70],[1,1,1,1],[2,2,2,2],[4,4,4,4]]\nresult = [List[0]] # add the first element since it doe...
2022/10/28
[ "https://Stackoverflow.com/questions/74240549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18655289/" ]
74,240,565
<p>I am reading a notepad text and inserting line per line in sLinge. I want to be able to invert the letters (for example: &quot;Hi how are you&quot; --&gt; &quot;uoy era woh iH&quot;)</p> <p>i keep getting this error code: Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.</p> <p>this is the notepad content :</p> <p>Anders Hejlsberg, né en décembre 1960, est un programmeur danois. En 1980, il a commencé à écrire des programmes pour le micro-ordinateur Nascom durant sa scolarité à l'Université technique du Danemark d'où il sortit non diplômé; il a en particulier écrit un compilateur Pascal qui a été vendu sous le nom de Blue Label Pascal compiler pour le Nascom-2. Il l'a rapidement réécrit pour CP/M et MS-DOS, et distribué sous le nom de Compass Pascal puis de Poly Pascal. Après avoir été acquis par Borland, il a été distribué sous le nom Turbo Pascal.</p> <p>Le rachat par Borland de son logiciel a amené Hejlsberg à être un des fondateurs de la société Borland dans laquelle il est resté jusqu'en 1996. Il a continué le développement du Turbo Pascal et est devenu chef de projet lors de l'élaboration du langage Delphi, successeur du Turbo Pascal.</p> <p>En 1996, il a quitté Borland pour rejoindre Microsoft où il a travaillé sur le langage J++ et les Windows Foundation Classes. Il est le concepteur du Framework .NET.</p> <p>Il travaille aujourd'hui chez Microsoft comme un chef de projet et architecte logiciel du projet C#, ainsi que du projet TypeScript</p> <p>Source: <a href="https://fr.wikipedia.org/wiki/Anders_Hejlsberg" rel="nofollow noreferrer">https://fr.wikipedia.org/wiki/Anders_Hejlsberg</a></p> <pre><code> while (!fichier.EndOfStream) { sLigne = fichier.ReadLine(); iIndex = sLigne.Length; while (iIndex &gt;= sLigne.Length) { cChar = sLigne[iIndex]; sInverse += cChar; iIndex--; } Console.WriteLine(sInverse); } Console.WriteLine(PAUSE); Console.ReadKey(); </code></pre>
[ { "answer_id": 74240632, "author": "lmiguelvargasf", "author_id": 3705840, "author_profile": "https://Stackoverflow.com/users/3705840", "pm_score": 2, "selected": false, "text": "List = [[70,70,70,70],[1,1,1,1],[2,2,2,2],[4,4,4,4]]\nresult = [List[0]] # add the first element since it doe...
2022/10/28
[ "https://Stackoverflow.com/questions/74240565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361496/" ]
74,240,594
<p>How to get resource from folder resources/key?</p> <p>I did like this:</p> <pre><code>String Key = new String(Files.readAllBytes(Paths.get(ClassLoader.getSystemResource(&quot;key/private.pem&quot;).toURI()))); </code></pre> <p>And it doesn't work when I build the project into a jar. So I'm looking for another way to do this. Can you please tell me how to get the resource?</p> <pre><code> private PublicKey getPublicKey() throws NoSuchAlgorithmException, InvalidKeySpecException, IOException { String key = getPublicKeyContent().replaceAll(&quot;\\n&quot;, &quot;&quot;) .replace(&quot;-----BEGIN PUBLIC KEY-----&quot;, &quot;&quot;).replace(&quot;-----END PUBLIC KEY-----&quot;, &quot;&quot;); X509EncodedKeySpec keySpec = new X509EncodedKeySpec(Base64.getDecoder().decode(key)); KeyFactory kf = KeyFactory.getInstance(&quot;RSA&quot;); return kf.generatePublic(keySpec); } private PrivateKey getPrivateKey() throws NoSuchAlgorithmException, InvalidKeySpecException { String key = getPrivateKeyContent().replaceAll(&quot;\\n&quot;, &quot;&quot;) .replace(&quot;-----BEGIN PRIVATE KEY-----&quot;, &quot;&quot;).replace(&quot;-----END PRIVATE KEY-----&quot;, &quot;&quot;); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.getDecoder().decode(key)); KeyFactory kf = KeyFactory.getInstance(&quot;RSA&quot;); return kf.generatePrivate(keySpec); } </code></pre>
[ { "answer_id": 74240632, "author": "lmiguelvargasf", "author_id": 3705840, "author_profile": "https://Stackoverflow.com/users/3705840", "pm_score": 2, "selected": false, "text": "List = [[70,70,70,70],[1,1,1,1],[2,2,2,2],[4,4,4,4]]\nresult = [List[0]] # add the first element since it doe...
2022/10/28
[ "https://Stackoverflow.com/questions/74240594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20217706/" ]
74,240,611
<p>I am currently learning python and i cant seen to figure out how to get a if - then statement for a dice to work (randomint).</p> <p>I tried</p> <pre><code>if roll_dice &lt; 10: print (&quot;dang, you got a low roll, try again&quot;) else: roll_dice &gt; 10 print (&quot;nice! you got a high roll&quot;) roll_dice = 10 print (&quot;10!&quot;) </code></pre> <p>It says &quot;ValueError: don't know how to compare 'function' and 'int' &quot;</p>
[ { "answer_id": 74240659, "author": "8088", "author_id": 19960057, "author_profile": "https://Stackoverflow.com/users/19960057", "pm_score": 2, "selected": false, "text": "if roll_dice < 10:\n print (\"dang, you got a low roll, try again\")\nelif roll_dice > 10:\n print (\"nice! you got...
2022/10/28
[ "https://Stackoverflow.com/questions/74240611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361528/" ]
74,240,622
<p>I have an entity with an ExternalSystemName value object and a Deployment parent type which is another entity. The important part of the model looks like this :</p> <pre><code>public sealed class ExternalSystem : Entity { public ExternalSystemName Name { get; private set; } public Deployment Deployment { get; private set; } } </code></pre> <p>The uniqueness of this entity is determined by a combination of the deployment ID (stored in the deployment entity class) and the name (which is the value of the ExternalSystemName value object). In other words, a deployment cannot have 2 external systems with the same name.</p> <p>I am facing an issue when trying to setup this combined unique index with an IEntityTypeConfiguration implementation :</p> <pre><code>internal sealed class ExternalSystemsConfiguration : IEntityTypeConfiguration&lt;ExternalSystem&gt; { public void Configure(EntityTypeBuilder&lt;ExternalSystem&gt; builder) { builder.ToTable(&quot;TblExternalSystems&quot;); builder.OwnsOne(e =&gt; e.Name, navigationBuilder =&gt; { navigationBuilder.Property(e =&gt; e.Value) .HasColumnName(&quot;Name&quot;); }); builder.HasIndex(e =&gt; new { e.Name, e.Deployment }).IsUnique(); } } </code></pre> <p>I am getting this exception when running my API :</p> <pre><code>System.InvalidOperationException: ''Name' cannot be used as a property on entity type 'ExternalSystem' because it is configured as a navigation.' </code></pre> <p>I tried pointing the index to e.Name.Value instead and I am getting this error :</p> <pre><code>System.ArgumentException: 'The expression 'e =&gt; new &lt;&gt;f__AnonymousType0`2(Value = e.Name.Value, Deployment = e.Deployment)' is not a valid member access expression. The expression should represent a simple property or field access: 't =&gt; t.MyProperty'. When specifying multiple properties or fields, use an anonymous type: 't =&gt; new { t.MyProperty, t.MyField }'. (Parameter 'memberAccessExpression')' </code></pre> <p>I also tried a unique index on just one of these properties and I get the navigation error regardless. I fear I know the answer already but does this mean EF Core only supports indexes on columns that are not a non-entity, non-valueObject type? Does that mean my model needs to have a Guid property representing the Deployment ID instead of having the Deployment itself?</p> <p><strong><strong><strong>UPDATE</strong></strong></strong></p> <p>I learned that EF Core can deal with reference / primitive pairs just fine. With that in mind, my ExternalSystem entity can now have BOTH these properties :</p> <pre><code>public Deployment Deployment { get; private set; } public Guid DeploymentId { get; private set; } </code></pre> <p>That Guid property is not part of the constructor and because they ultimately get the same column name everything works fine. I can now just add this to my configuration for this entity and the index is created properly :</p> <pre><code>builder.HasIndex(e =&gt; new { e.DeploymentId}).IsUnique(); </code></pre> <p>My issue is now with the value object. Using the same approach, I suppose I could do something like this ?</p> <pre><code>public ExternalSystemName NameV { get; private set; } public string Name { get; private set; } </code></pre> <p>I have to rename the value object property since they obviously can't share the same name. This is not something I had to do with the entity type since EF Core knew to add &quot;Id&quot; to the column name in the first place. With this setup, EF Core is duplicating the columns. One has the name &quot;Name&quot; and the other one has &quot;ExternalSystem_Name&quot;. Obviously everthing else fails from there since that column doesn't accept null values. Why is this happening?</p>
[ { "answer_id": 74312008, "author": "Fitri Halim", "author_id": 13218799, "author_profile": "https://Stackoverflow.com/users/13218799", "pm_score": -1, "selected": false, "text": "protected override void OnModelCreating(ModelBuilder modelBuilder)\n{\n modelBuilder.Entity<ExternalSystem...
2022/10/28
[ "https://Stackoverflow.com/questions/74240622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8780684/" ]
74,240,624
<p>Android still seems to scale emojis in a Bizzar way.</p> <p>I've seen that this is an issue in other Android development platoforms, up to Android 11, and it still seems to exist now in Android 12. <a href="https://i.stack.imgur.com/dVUJc.png" rel="nofollow noreferrer">Android discussion</a></p> <p>Perhaps Flutter has some way around it? Like a zoom function, or convert to an image before scaling or something? InteractiveViewer doesn't work (if anything, wrapping the column widget with InteractiveViewer is a great way to demonstrate the actual issue).</p> <p>I use a Fitted box to scale up an Emoji in Flutter to whatever the size is in a parent container. It works just fine on most platforms, however, in Android, going above about 90px does weird things to the final render.</p> <p>This is what it looks like in dart-pad:</p> <p><a href="https://i.stack.imgur.com/dVUJc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dVUJc.png" alt="DartPad example" /></a></p> <p>And now in Android (either real phone, or the emulator): you can clearly see a scaling issue. The large yellow curve is the emoji that is supposed to be 90x90:</p> <p>[edit] On the emulator, there is no large yellow curve, but the emojis are still missing.</p> <p><a href="https://i.stack.imgur.com/VnNRM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VnNRM.png" alt="Android screenshot" /></a></p> <p>Here is the code to try yourself.</p> <pre><code>import 'package:flutter/material.dart'; const Color darkBlue = Color.fromARGB(255, 18, 32, 47); void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.dark().copyWith( scaffoldBackgroundColor: darkBlue, ), debugShowCheckedModeBanner: false, home: Scaffold( body: Center( child: MyWidget(), ), ), ); } } class MyWidget extends StatelessWidget { @override Widget build(BuildContext context) { const String emoji = &quot;&quot;; return InteractiveViewer( child: Column(children: [ Container( color: Colors.green, width: 70, height: 70, child: const FittedBox(fit: BoxFit.contain, child: Text(emoji))), Container( color: Colors.green, width: 80, height: 80, child: const FittedBox(fit: BoxFit.contain, child: Text(emoji))), Container( color: Colors.red, width: 90, height: 90, child: const FittedBox(fit: BoxFit.contain, child: Text(emoji))), Container( color: Colors.red, width: 100, height: 100, child: const FittedBox(fit: BoxFit.contain, child: Text(emoji))), Container( color: Colors.red, width: 180, height: 180, child: const FittedBox(fit: BoxFit.contain, child: Text(emoji))), ]), ); } } </code></pre> <p>[EDIT] @Marcel Dz is onto something in their comment &quot;try your code using flutter version 2.10.5&quot; ... The investigation continues.</p> <p><a href="https://i.stack.imgur.com/m5bO2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m5bO2.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74312008, "author": "Fitri Halim", "author_id": 13218799, "author_profile": "https://Stackoverflow.com/users/13218799", "pm_score": -1, "selected": false, "text": "protected override void OnModelCreating(ModelBuilder modelBuilder)\n{\n modelBuilder.Entity<ExternalSystem...
2022/10/28
[ "https://Stackoverflow.com/questions/74240624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493272/" ]
74,240,629
<p>I have a specific EF Core 6.x question.</p> <p>If the SQL table has a column removed. Then EF Core will throw a SqlException saying that it's an invalid column name unless I also update the C# model.</p> <p>For example,</p> <pre><code>Create Table User ( FirstName varchar(200) ,MiddleName varchar(200) null -- tried to remove this column after table is created ,LastName varchar(200) ) </code></pre> <p>I tried deleting the MiddleName column from the SQL Table. When I run a simple read call using EF Core 6, I get the error.</p> <p>c# model</p> <pre><code>public class User { public virtual string FirstName { get; set; } public virtual string? MiddleName { get; set; } public virtual string LastName { get; set; } } var db = new EFDbContext(connectionString); var data = db.Users.ToList(); // SqlException here after column removal </code></pre> <p>Is there any way to remove columns from the table without needing to update the c# class as well?</p> <p>Tried making the C# property MiddleName not virtual.</p> <p><strong>Update:</strong></p> <p>In the event that I have an existing application. I would need to modify the c# model even if the codebase doesn't refer to the removed column anywhere. Alternatively, I can decorate the property with [NotMapped] or use the Ignore() method in the modelbuilder.</p> <p>Both approaches means a rebuild of the assembly is needed and downtime during deployment.</p> <p>NHibernate's mapping can be done using an XML file and thus all it takes would be a simple config file update.</p> <p>I can't seem to find anything in EF Core that will reduce the headache of maintaining older codebases when schema changes occur.</p>
[ { "answer_id": 74312008, "author": "Fitri Halim", "author_id": 13218799, "author_profile": "https://Stackoverflow.com/users/13218799", "pm_score": -1, "selected": false, "text": "protected override void OnModelCreating(ModelBuilder modelBuilder)\n{\n modelBuilder.Entity<ExternalSystem...
2022/10/28
[ "https://Stackoverflow.com/questions/74240629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361518/" ]
74,240,638
<p>The output of the function I run is in format int. I should replace the number in json file</p> <pre><code> &quot;x&quot;:{..}, &quot;y&quot;:{..}, &quot;z&quot;:{ &quot;zz&quot;:{ &quot;test1&quot;: &quot;2010-11&quot;, &quot;test2&quot;: &quot;somestring&quot;, }, </code></pre> <p>how do i search and replace the test1 part with the output of the result i get?</p>
[ { "answer_id": 74241091, "author": "D.L", "author_id": 7318120, "author_profile": "https://Stackoverflow.com/users/7318120", "pm_score": 1, "selected": false, "text": "import json\n\ndef some_function():\n return 'hello world'\n\n# create a dict\nd = { \"x\":{'a':'b'},\n \"y\...
2022/10/28
[ "https://Stackoverflow.com/questions/74240638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8599906/" ]
74,240,692
<p>Is there a way to combine these three lines to be shorter? I use these lines multiple times for different column indexes, so it is a lot of repeating. I am wondering if there is a better way to approach this method. For <code>sysnum</code> it is defined in code that I did not include because it did not seem relevant, but it is a text string of numbers.</p> <p>Here is my code:</p> <pre><code>Dim lastrow As Long, sysnum as String lastrow = wb.Worksheets(sysnum).Cells(Rows.Count, 1).End(xlUp).row wb.Worksheets(sysnum).Rows(lastrow + 1).Insert wb.Worksheets(sysnum).Cells(lastrow + 1, 2).Value = sysnum wb.Worksheets(sysnum).Cells(lastrow + 1, 2).Font.Bold = True wb.Worksheets(sysnum).Cells(lastrow + 1, 3).Value = &quot;Passed&quot; wb.Worksheets(sysnum).Cells(lastrow + 1, 3).Font.Bold = True wb.Worksheets(sysnum).Cells(lastrow + 1, 3).Interior.Color = vbGreen End If </code></pre>
[ { "answer_id": 74240822, "author": "Jon vB", "author_id": 1815270, "author_profile": "https://Stackoverflow.com/users/1815270", "pm_score": 2, "selected": true, "text": " Dim lastrow As Long, sysnum As String\n \n\n With wb.Worksheets(sysnum)\n lastrow = .Cells(Rows.Count, 1).End...
2022/10/28
[ "https://Stackoverflow.com/questions/74240692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20114520/" ]
74,240,719
<p>In PostgreSQL 11, I am trying to get a weekend time range. From 17:00 Friday to Sunday 17:00.</p> <p>So far I am able to get a working day by doing</p> <pre><code>select * from generate_series(date '2021-01-01',date '2021-12-31',interval '1' day) as t(dt) where extract (dow from dt) between 1 and 5; </code></pre> <p>However, I am have trouble creating 2 columns from start (17:00 Friday) to finish (17:00 Sunday).</p> <p>Expected output should be something like this:</p> <pre><code>start stop 2022-10-07 17:00 2022-10-09 17:00 2022-10-14 17:00 2022-10-16 17:00 2022-10-21 17:00 2022-10-23 17:00 </code></pre>
[ { "answer_id": 74241086, "author": "Adrian Klaver", "author_id": 7070613, "author_profile": "https://Stackoverflow.com/users/7070613", "pm_score": 2, "selected": true, "text": "17:00" }, { "answer_id": 74243386, "author": "jian", "author_id": 15603477, "author_profile...
2022/10/28
[ "https://Stackoverflow.com/questions/74240719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3589054/" ]
74,240,730
<p>I have a Pandas dataframe that looks like this:</p> <pre><code>import pandas as pd df = pd.DataFrame({ 'city': ['New York','New York','New York','Los Angeles','Los Angeles','Houston','Houston','Houston'], 'airport': ['LGA', 'EWR', 'JFK', 'LAX', 'BUR', 'IAH', 'HOU', 'EFD'], 'distance': [38, 50, 32, 8, 50, 90, 78, 120] } df city airport distance 0 New York LGA 38 1 New York EWR 50 2 New York JFK 32 3 Los Angeles LAX 8 4 Los Angeles BUR 50 5 Houston IAH 90 6 Houston HOU 78 7 Houston EFD 120 </code></pre> <p>I would like to output a separate dataframe based on the following logic:</p> <ol> <li>if the value in the <code>distance</code> column is 40 <strong>or less</strong> between a given city and associated airport, than keep the row</li> <li>if, within a given city, there is no distance below 40, then show only the shortest (lowest) distance</li> </ol> <p>The desired dataframe would look like this:</p> <pre><code> city airport distance 0 New York LGA 38 1 New York JFK 32 3 Los Angeles LAX 8 4 Houston HOU 78 &lt;-- this is returned, even though it's more than 40 </code></pre> <p>How would I do this?</p> <p>Thanks!</p>
[ { "answer_id": 74240951, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 3, "selected": true, "text": "drop_duplicates" }, { "answer_id": 74241933, "author": "PaulS", "author_id": 11564487, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74240730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18908491/" ]
74,240,761
<p>I am moving a query from SQL Server to Snowflake. Part of the query creates a pivot table. The pivot table part works fine (I have run it in isolation, and it pulls numbers I expect).</p> <p>However, the following parts of the query rely on the pivot table- and those parts fail. Some of the fields return as a string-type. I believe that the problem is Snowflake is having issues converting string data to numeric data. I have tried CAST, TRY_TO_DOUBLE/NUMBER, but these just pull up 0.</p> <p>I will put the code down below, and I appreciate any insight as to what I can do!</p> <pre><code>CREATE OR REPLACE TEMP TABLE ATTR_PIVOT_MONTHLY_RATES AS ( SELECT Market, Coverage_Mo, ZEROIFNULL(TRY_TO_DOUBLE('Starting Membership')) AS Starting_Membership, ZEROIFNULL(TRY_TO_DOUBLE('Member Adds')) AS Member_Adds, ZEROIFNULL(TRY_TO_DOUBLE('Member Attrition')) AS Member_Attrition, ((ZEROIFNULL(CAST('Starting Membership' AS FLOAT)) + ZEROIFNULL(CAST('Member Adds' AS FLOAT)) + ZEROIFNULL(CAST('Member Attrition' AS FLOAT)))-ZEROIFNULL(CAST('Starting Membership' AS FLOAT))) /ZEROIFNULL(CAST('Starting Membership' AS FLOAT)) AS &quot;% Change&quot; FROM (SELECT * FROM ATTR_PIVOT WHERE 'Starting Membership' IS NOT NULL) PT) </code></pre> <p>I realize this is a VERY big question with a lot of moving parts... So my main question is: How can I successfully change the data type to numeric value, so that hopefully the formulas work in the second half of the query?</p> <p>Thank you so much for reading through it all!</p> <p>EDITED FOR SHORTENING THE QUERY WITH UNNEEDED SYNTAX</p> <p>CAST(), TRY_TO_DOUBLE(), TRY_TO_NUMBER(). I have also put the fields (Starting Membership, Member Adds) in single and double quotation marks.</p>
[ { "answer_id": 74240951, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 3, "selected": true, "text": "drop_duplicates" }, { "answer_id": 74241933, "author": "PaulS", "author_id": 11564487, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74240761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361501/" ]
74,240,771
<p>i would like to save in a string multiple lines from reading file, eg: I am reading one file.txt with the following content:</p> <pre><code>def var x as int. def var y as char. procedure something: //here some content end. </code></pre> <p>I would like to catch content between &quot;procedure&quot; and &quot;end&quot;.</p> <pre><code>public static void main(String[] args) { String piContent = &quot;&quot;; try (BufferedReader br = new BufferedReader(new FileReader(&quot;file.txt&quot;))) { String line; while ((line = br.readLine()) != null) { if(line.contains(&quot;procedure&quot;)){ piContent = line; } } } catch (IOException e) { throw new RuntimeException(e); } } </code></pre> <p>I appreciate any help.</p>
[ { "answer_id": 74240951, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 3, "selected": true, "text": "drop_duplicates" }, { "answer_id": 74241933, "author": "PaulS", "author_id": 11564487, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74240771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7915012/" ]
74,240,790
<p>Is there an easier way to do this without bringing in a bunch of mathematics? Perhaps maybe a switch statement?</p> <pre><code> if (myChoice == &quot;Rock&quot; &amp;&amp; compChoice == &quot;Scissors&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Rock&quot; &amp;&amp; compChoice == &quot;Lizard&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Paper&quot; &amp;&amp; compChoice == &quot;Rock&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Paper&quot; &amp;&amp; compChoice == &quot;Spock&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Scissors&quot; &amp;&amp; compChoice == &quot;Paper&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Scissors&quot; &amp;&amp; compChoice == &quot;Lizard&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Lizard&quot; &amp;&amp; compChoice == &quot;Spock&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Lizard&quot; &amp;&amp; compChoice == &quot;Paper&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Spock&quot; &amp;&amp; compChoice == &quot;Scissors&quot;) { winner = &quot;player&quot;; win++; } else if (myChoice == &quot;Spock&quot; &amp;&amp; compChoice == &quot;Rock&quot;) { winner = &quot;player&quot;; win++; } else if (compChoice == &quot;Rock&quot; &amp;&amp; myChoice == &quot;Scissors&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Rock&quot; &amp;&amp; myChoice == &quot;Lizard&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Paper&quot; &amp;&amp; myChoice == &quot;Rock&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Paper&quot; &amp;&amp; myChoice == &quot;Spock&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Scissors&quot; &amp;&amp; myChoice == &quot;Paper&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Scissors&quot; &amp;&amp; myChoice == &quot;Lizard&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Lizard&quot; &amp;&amp; myChoice == &quot;Spock&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Lizard&quot; &amp;&amp; myChoice == &quot;Paper&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Spock&quot; &amp;&amp; myChoice == &quot;Scissors&quot;) { winner = &quot;computer&quot;; lose++; } else if (compChoice == &quot;Spock&quot; &amp;&amp; myChoice == &quot;Rock&quot;) { winner = &quot;computer&quot;; lose++; } else { winner = &quot;none&quot;; tie++; } </code></pre> <p>I played around with this for a little while but looking for an easier way to show some friends that are learning c#. I'm quite the beginner myself so I wasn't able to offer anymore assistance. I'm hoping that someone on here can point us in the right direction. Thanks in advance for any advice you can offer.</p>
[ { "answer_id": 74240951, "author": "BENY", "author_id": 7964527, "author_profile": "https://Stackoverflow.com/users/7964527", "pm_score": 3, "selected": true, "text": "drop_duplicates" }, { "answer_id": 74241933, "author": "PaulS", "author_id": 11564487, "author_profi...
2022/10/28
[ "https://Stackoverflow.com/questions/74240790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19292346/" ]
74,240,875
<p>I have a table A and in it I have a column of type json that receives an array of dates. I need to fetch all female records from table A. I need to return a specific date from each record in table A.</p> <pre><code>----------------------------------------------------------------------------------- table A ----------------------------------------------------------------------------------- gender (string) date (json) ----------------------------------------------------------------------------------- feminine {&quot;2022-01-01&quot;: &quot;A1&quot;, &quot;2022-01-02&quot;: &quot;A2&quot;, &quot;2022-01-03&quot;: &quot;A3&quot; } masculine {&quot;2022-01-01&quot;: &quot;B1&quot;, &quot;2022-01-02&quot;: &quot;B2&quot;, &quot;2022-01-03&quot;: &quot;B3&quot; } feminine {&quot;2022-01-01&quot;: &quot;C1&quot;, &quot;2022-01-02&quot;: &quot;C2&quot;, &quot;2022-01-03&quot;: &quot;C3&quot; } masculine {&quot;2022-01-01&quot;: &quot;D1&quot;, &quot;2022-01-02&quot;: &quot;D2&quot;, &quot;2022-01-03&quot;: &quot;D3&quot; } ----------------------------------------------------------------------------------- </code></pre> <p>I need a query that returns me:</p> <pre><code>feminine &quot;2022-01-01&quot;: &quot;A1&quot; feminine &quot;2022-01-01&quot;: &quot;C1&quot; </code></pre> <p>only female lines and only date 2022-01-01</p>
[ { "answer_id": 74241014, "author": "Edouard", "author_id": 8060017, "author_profile": "https://Stackoverflow.com/users/8060017", "pm_score": 2, "selected": true, "text": "SELECT gender, '\"2022-01-01\": ' || date->'2022-01-01'\n FROM A\n WHERE gender = 'feminine'\n" }, { "answer...
2022/10/28
[ "https://Stackoverflow.com/questions/74240875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6831623/" ]
74,240,883
<p>I have a word list contains in a text file; below I show an example:</p> <pre><code>place lime nest land </code></pre> <p>I want to get an other file with the content below:</p> <pre><code>pl@ce lim3 n3st l@nd </code></pre> <p>This mean that:</p> <ul> <li>the letter <code>a</code> must be transform in in the char <code>@</code> but in a word must be only 1 change so <code>apart</code> becomes <code>ap@rt</code> and not <code>@p@rt</code>.</li> <li>the letter <code>e</code> must be transform in in the number <code>3</code></li> </ul> <p>This is first time that I use stackoverflow so sorry for my writing and for my English.</p> <p>I'm also new to coding (python) so I might not understand all the code very well.</p>
[ { "answer_id": 74241006, "author": "grifway", "author_id": 10376499, "author_profile": "https://Stackoverflow.com/users/10376499", "pm_score": -1, "selected": false, "text": "def updt_text(s):\n # assumptions, string of text is seperated by spaces and there are no odd characters\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74240883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361633/" ]
74,240,934
<p>I am using beautiful soup to parse HTML as follows:</p> <pre><code>html_content2 =&quot;&quot;&quot; &lt;h3 style=&quot;cear: both;&quot;&gt; &lt;abbr title=&quot;European Union&quot;&gt;EU&lt;/abbr&gt;Investment&lt;/h3&gt; &lt;div class=&quot;conditions&quot;&gt; &lt;p&gt;bla bla bla &lt;/p&gt; &lt;/div&gt; &lt;p style=&quot;margin-bottom: 0;&quot;&gt; &lt;span class=&quot;amount&quot;&gt;66000 €&lt;/span&gt; &lt;/p&gt;&quot;&quot;&quot; </code></pre> <p>I would like to extract the amount of money and the code I have is:</p> <pre><code>from bs4 import BeautifulSoup html_content=html_content1 soup = BeautifulSoup(html_content, &quot;lxml&quot;) t3 = soup.find(lambda tag:tag.name==&quot;h3&quot; and &quot;: Investment&quot;).find_next_sibling().find_next_sibling(&quot;p&quot;).find(&quot;span&quot;).contents print(t3) </code></pre> <p>The intention here is the following: get h3 tag WITH text Investment and from there get next sibling and another next sibling with tag p then span and get the contents</p> <p>In this previous code I dont how to include the word &quot;Investiment&quot; in the lambda function. I tried:</p> <pre><code>tag.name==&quot;h3&quot; and tag.contents==&quot;: Investment&quot; </code></pre> <p>this does not work.</p>
[ { "answer_id": 74241006, "author": "grifway", "author_id": 10376499, "author_profile": "https://Stackoverflow.com/users/10376499", "pm_score": -1, "selected": false, "text": "def updt_text(s):\n # assumptions, string of text is seperated by spaces and there are no odd characters\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74240934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7168098/" ]
74,240,957
<p>I want to deleted all the files in the temp folder... any .zip files , .txt files and any folder files including whatever is inside each of those folders (everything). I thought this would be simple but so far my script keeps getting the confirmation pop-up asking if I want to delete all these child items. I tried using <code>-confirm:$false</code> but that doesn't seem to work. I appreciate any suggestions. Thank you.</p> <pre class="lang-bash prettyprint-override"><code>$list = Get-ChildItem -directory &quot;C:\temp\*&quot; -Include * -Name get-childitem c:\temp -Include @(get-content $list) | Remove-Item -Force -whatif </code></pre> <p>I tried using the <code>-confirm:$false</code> argument as well as the <code>-force</code> with no luck.</p>
[ { "answer_id": 74241006, "author": "grifway", "author_id": 10376499, "author_profile": "https://Stackoverflow.com/users/10376499", "pm_score": -1, "selected": false, "text": "def updt_text(s):\n # assumptions, string of text is seperated by spaces and there are no odd characters\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74240957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17109549/" ]
74,240,961
<p>I developed VSTO Excel Add-In and usually I do installers with Advanced Installer, but my current client insist on VS Installer, which is dreadful... I target x64 Office, and have .NET 4.8 prerequisite and VSTO 2010 Runtime prerequisite. So, the questions are:</p> <ol> <li>How do I create a single .MSI (without setup.exe bootstrap)</li> <li>Do I really need to search for presence of prerequisites?</li> <li>I have Launch condition:</li> </ol> <p><a href="https://i.stack.imgur.com/Gw6Rm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gw6Rm.png" alt="enter image description here" /></a></p> <p>But then, I also defined the following in Setup &gt; Properties &gt; Prerequisites:</p> <p><a href="https://i.stack.imgur.com/q0C9k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q0C9k.png" alt="enter image description here" /></a></p> <p>So how do they co-exist together? It's been at least 10 years since I touched VS Installer, and it is still the same cryptic creature...</p>
[ { "answer_id": 74241006, "author": "grifway", "author_id": 10376499, "author_profile": "https://Stackoverflow.com/users/10376499", "pm_score": -1, "selected": false, "text": "def updt_text(s):\n # assumptions, string of text is seperated by spaces and there are no odd characters\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74240961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8407516/" ]
74,241,008
<pre><code> #define size 4 #include &lt;iostream&gt; using namespace std; class queue { int array[size]; int rear; int front; public: queue() { front = 0; rear = 0; } void enqueue(int val); void dequeue(); }; void queue :: enqueue(int val) { if (rear = size) { cout &lt;&lt; &quot;sorry our queue is full &quot; &lt;&lt; endl; } else { array[rear] = val; rear++; } } void queue :: dequeue() { if (front = rear) { cout &lt;&lt; &quot;the stack is empty&quot; &lt;&lt; endl; } else { cout &lt;&lt; &quot;our queued element is that&quot; &lt;&lt; array[front] &lt;&lt; endl; front++; }} int main() { queue bro; bro.enqueue(4); bro.enqueue(5); bro.enqueue(3); bro.enqueue(6); bro.dequeue(); bro.dequeue(); bro.dequeue(); } </code></pre> <p>I was writing the code and got a bunch of errors on this queue enqueue and dequeue array. The errors say corecrt_wio.h. Some of the errors say error on line that I didn't even write so it is really confusing.</p>
[ { "answer_id": 74241120, "author": "xingharvey", "author_id": 16168636, "author_profile": "https://Stackoverflow.com/users/16168636", "pm_score": 0, "selected": false, "text": "#define size 4" }, { "answer_id": 74241148, "author": "Useless", "author_id": 212858, "auth...
2022/10/28
[ "https://Stackoverflow.com/questions/74241008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20139201/" ]
74,241,054
<p>Below you can see my SQL query</p> <pre><code>select c.email_address,o.order_id as &quot;Number of Orders&quot;, ((oi.item_price-oi.discount_amount)*oi.quantity) as &quot;Total amount&quot; from customers c inner join orders o on c.customer_id=o.customer_id inner join order_items oi on o.order_id=oi.order_id </code></pre> <p>From that, I can get output like below</p> <pre><code>Email Orders_id Amount allan@yahoo.com 1 839.3 barryz@gmail.com 2 303.79 allan@yahoo.com 3 1208.16 allan@yahoo.com 3 253.15 chrisb@gmail.com 4 1678.6 david@hotmail.com 5 299 erinv@gmail.com 6 299 frank@gmail.com 7 489.3 frank@gmail.com 7 559.9 frank@gmail.com 7 489.99 garyz@yahoo.com 8 679.99 david@hotmail.com 9 489.3 </code></pre> <p>But I want to customize it like below</p> <pre><code>Email Number of Orders Total Amount allan@yahoo.com 3 2300.61 barryz@gmail.com 1 303.79 chrisb@gmail.com 1 1678.6 david@hotmail.com 2 788.3 erinv@gmail.com 1 299 frank@gmail.com 3 1539.19 garyz@yahoo.com 1 679.99 </code></pre> <p>Can anyone help me to do this?</p>
[ { "answer_id": 74241138, "author": "bernie", "author_id": 19693788, "author_profile": "https://Stackoverflow.com/users/19693788", "pm_score": 2, "selected": false, "text": "select email_address, count(\"Number of Orders\") as number_of_orders, sum(\"Total Amount\") as amount\nfrom (\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74241054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12721555/" ]
74,241,068
<p>How to select all rows in datagrid for uwp/winui? Similar to dataGrid.SelectAl(); from WPF.</p> <p>I didn't find anything about this in uwp/winUI</p>
[ { "answer_id": 74241138, "author": "bernie", "author_id": 19693788, "author_profile": "https://Stackoverflow.com/users/19693788", "pm_score": 2, "selected": false, "text": "select email_address, count(\"Number of Orders\") as number_of_orders, sum(\"Total Amount\") as amount\nfrom (\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74241068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361785/" ]
74,241,088
<p>I'm struggling with the following problem, I have the follwing data in a table:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Param ID</th> <th>Param Val</th> <th>Other Cols</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>15</td> <td>XXX</td> </tr> <tr> <td>1</td> <td>15</td> <td>XXX</td> </tr> <tr> <td>1</td> <td>16</td> <td>XXX</td> </tr> <tr> <td>1</td> <td>16</td> <td>XXX</td> </tr> <tr> <td>2</td> <td>21</td> <td>XXX</td> </tr> <tr> <td>2</td> <td>21</td> <td>XXX</td> </tr> <tr> <td>2</td> <td>22</td> <td>XXX</td> </tr> <tr> <td>2</td> <td>22</td> <td>XXX</td> </tr> </tbody> </table> </div> <p>I would like to select a new colum in order to create 4 sets of data to have all the possible combination between the values of parameter 1 and 2; so I would like to obtain something like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Set</th> <th>Param ID</th> <th>Param Val</th> <th>Other Cols</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>15</td> <td>XXX</td> </tr> <tr> <td>2</td> <td>1</td> <td>15</td> <td>XXX</td> </tr> <tr> <td>3</td> <td>1</td> <td>16</td> <td>XXX</td> </tr> <tr> <td>4</td> <td>1</td> <td>16</td> <td>XXX</td> </tr> <tr> <td>1</td> <td>2</td> <td>21</td> <td>XXX</td> </tr> <tr> <td>3</td> <td>2</td> <td>21</td> <td>XXX</td> </tr> <tr> <td>2</td> <td>2</td> <td>22</td> <td>XXX</td> </tr> <tr> <td>4</td> <td>2</td> <td>22</td> <td>XXX</td> </tr> </tbody> </table> </div> <p>So for example for the Set 1 I will have the Couple of values 15 and 21, for the set 2 the values 15 and 22 etc etc.</p> <p>I tried using different analytic functions, but I was not able to have what I need. Thanks in advance.</p>
[ { "answer_id": 74241138, "author": "bernie", "author_id": 19693788, "author_profile": "https://Stackoverflow.com/users/19693788", "pm_score": 2, "selected": false, "text": "select email_address, count(\"Number of Orders\") as number_of_orders, sum(\"Total Amount\") as amount\nfrom (\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74241088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7520180/" ]
74,241,125
<p>This is the code I have written so far:</p> <p><strong>Here is my Controller that contains the edit and update function:</strong></p> <pre><code>public function edit($id){ $post = Posts::find($id); return view('edit', compact('post')); } public function update(Request $request, $id){ $post = Posts::find($id); $validatedRequests = $request-&gt;validate([ 'title' =&gt; 'required|max:255|string|integer', 'description' =&gt; 'required|max:255|string|integer', 'price' =&gt; 'required|integer|max:255|' ]); $post-&gt;create($validatedRequests); return redirect('/Post/{{$post-&gt;id}}')-&gt;with('mssg', 'updates successfully'); } </code></pre> <p>Here are my <code>Web.php</code> routes:</p> <pre><code>Route::get('/post/{id}/edit', [PostController::class, 'edit']); Route::put('/post/{id}/update', [PostController::class, 'update']); </code></pre> <p><strong>Here is my blade(view) file</strong></p> <pre><code>&lt;form method=&quot;POST&quot; action=&quot;/post/{{$post-&gt;id}}/update&quot;&gt; @csrf @method('PUT') &lt;label class=&quot;underline&quot; for=&quot;title&quot;&gt;change title:&lt;/label&gt;&lt;/br&gt; &lt;input type=&quot;text&quot; name=&quot;title&quot; value=&quot;{{$post-&gt;title}}&quot;&gt;&lt;/input&gt;&lt;/br&gt; &lt;label class=&quot;underline&quot; for=&quot;decsription&quot;&gt;change description:&lt;/label&gt;&lt;/br&gt; &lt;input type=&quot;text&quot; name=&quot;description&quot; value=&quot;{{$post-&gt;description}}&quot;&gt;&lt;/input&gt;&lt;/br&gt; &lt;label class=&quot;underline&quot; for=&quot;price&quot;&gt;change price:&lt;/label&gt;&lt;/br&gt; &lt;input type=&quot;text&quot; name=&quot;price&quot; value=&quot;{{$post-&gt;price}}&quot;&gt;&lt;/input&gt;&lt;/br&gt; &lt;input type=&quot;submit&quot; value=&quot;submit&quot;&gt; &lt;/form&gt; </code></pre>
[ { "answer_id": 74241138, "author": "bernie", "author_id": 19693788, "author_profile": "https://Stackoverflow.com/users/19693788", "pm_score": 2, "selected": false, "text": "select email_address, count(\"Number of Orders\") as number_of_orders, sum(\"Total Amount\") as amount\nfrom (\n ...
2022/10/28
[ "https://Stackoverflow.com/questions/74241125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19425282/" ]
74,241,127
<p>I have an Ansible project that involves the following task:</p> <pre><code>- name: Perform a git init in source folder ansible.builtin.command: cmd: git init chdir: ~/Projects/kernel/src creates: ~/kernel/src/.git </code></pre> <p>However ansible-lint does not like this:</p> <pre><code>WARNING Listing 1 violation(s) that are fatal command-instead-of-module: git used in place of git module (warning) </code></pre> <p>I have tried using the ansible.builtin.git module but I can't seem to find a way to make it just do an init.</p> <p>Any suggestions?</p> <p>Stephen</p> <p>I was trying to write an Ansible task that essentially performs a <code>git init</code> in a folder without ansible-lint complaining. But I can't seen to find an ansible-lint clean way of doing this.</p>
[ { "answer_id": 74241319, "author": "franklinsijo", "author_id": 7303447, "author_profile": "https://Stackoverflow.com/users/7303447", "pm_score": 1, "selected": false, "text": "- name: Perform git init\n git: \n repo: https://github.com/username/repo.git\n dest: /home/user/Project...
2022/10/28
[ "https://Stackoverflow.com/questions/74241127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20304923/" ]
74,241,151
<p>I'm trying to make some of my hyperlinks look like buttons, but for some reason it simply ignores the padding and margin I give it, making it look bad.</p> <p><a href="https://i.stack.imgur.com/4Fmdc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Fmdc.png" alt="picture for reference" /></a></p> <p>How can I prevent the margin of the button from being ignored? This would move the button down some more and have the background go fully behind it.</p> <p>This is the code I'm using:</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>.bg-div { background-color : #b4d4e7; padding : 0rem 1rem; } p{ line-height: 2rem; margin: 0rem 0 1rem 3px; } .hyperlink-button { border-radius : 14px; background-color : transparent; border : 2px solid #157ea1; padding : 1rem; color : #157ea1; transition-duration : 0.3s; margin : 1rem 0rem; width : fit-content; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="bg-div"&gt; &lt;h2&gt;text&lt;/h2&gt; &lt;p&gt;more text&lt;br&gt; &lt;a href="www.stackoverflow.com"&gt;this is a hyperlink&lt;/a&gt; &lt;br&gt; yet more text &lt;/p&gt; &lt;a class="hyperlink-button" href="www.stackoverflow.com"&gt;hyperlink button&lt;/a&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>Using the inspect feature I played around with the margin and padding of several objects, and everything but that specific button works fine. Putting a around the hyperlink button results in exactly the same look. I looked into margin collapsing, but even if the margin of my hyperlink button is a lot bigger than the one from the text, the text one is used and the hyperlink button's is ignored. Besides, the padding is also ignored, which shouldn't occur with normal margin collapsing.</p>
[ { "answer_id": 74241319, "author": "franklinsijo", "author_id": 7303447, "author_profile": "https://Stackoverflow.com/users/7303447", "pm_score": 1, "selected": false, "text": "- name: Perform git init\n git: \n repo: https://github.com/username/repo.git\n dest: /home/user/Project...
2022/10/28
[ "https://Stackoverflow.com/questions/74241151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361715/" ]
74,241,161
<p>I need to update the SKU of a WooCommerce product but nothing I tried works.</p> <p>I'm trying to update the SKU of a product. I build a new select custom field (´´id=&gt;'_leadlovers_integration_product'´´ on the code below) on the inventory settings with options I import by API from another plataform). This works fine. I can save the code, print it. But I can´t simply make the update of the SKU with this code.</p> <p>I've tried a lot of snipets but nothing works...</p> <pre class="lang-php prettyprint-override"><code> add_action( 'woocommerce_process_product_meta', 'save_leadlovers_custom_fields'); function save_leadlovers_custom_fields( $post_id ) { //These two guys works perfectly update_post_meta( $post_id, '_leadlovers_integration_check', esc_attr( $_POST['_leadlovers_integration_check'] ) ); update_post_meta( $post_id, '_leadlovers_integration_product', esc_attr( $_POST['_leadlovers_integration_product'] ) ); //First, I tried this... no success //update_post_meta( $post_id, '_sku', esc_attr( $_POST['_leadlovers_integration_product'] ) ); //Then I tried this, with no changes, forcing by hand the //update_post_meta( $post_id, '_sku', '30445' ); //I tried using the function set_sku() too... nothing happens //$product = wc_get_product( $post_id ); //$product-&gt;set_sku( get_post_meta( $post-&gt;ID, '_leadlovers_integration_product', true ) ); //nothing too with this... $product = wc_get_product( $post_id ); $product-&gt;set_sku( '30445' ) ; ///i tried even make the procedure on other function... } </code></pre> <p>Well, someone have an idea what happens, or... not happens??</p> <p>Thanks,</p>
[ { "answer_id": 74241319, "author": "franklinsijo", "author_id": 7303447, "author_profile": "https://Stackoverflow.com/users/7303447", "pm_score": 1, "selected": false, "text": "- name: Perform git init\n git: \n repo: https://github.com/username/repo.git\n dest: /home/user/Project...
2022/10/28
[ "https://Stackoverflow.com/questions/74241161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20349967/" ]
74,241,172
<p>Sorry if this is a duplicate, but I didn't find it anywhere. I need to get all the products belonging to a certain vendor via a <strong>raw SQL query</strong>. I know both the vendor slug or id, but I couldn't figure out exactly the relationship between the products and a vendor.</p> <p>Can anyone share a complete SQL to do that or at least what is that relationship between tables. Thanks for any advice!</p>
[ { "answer_id": 74241876, "author": "Vinay Jain", "author_id": 17995563, "author_profile": "https://Stackoverflow.com/users/17995563", "pm_score": 1, "selected": false, "text": "$vendor_products_list = $WCFM->wcfm_vendor_support->wcfm_get_products_by_vendor($vendor_id, 'publish', array('...
2022/10/28
[ "https://Stackoverflow.com/questions/74241172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12347413/" ]
74,241,182
<p>Im trying to do a highscore system for my python game using a txt file and writing and reading the highscore from/to it. When i try the code under i get this error message: ValueError: invalid literal for int() with base 10: '\x003'</p> <pre><code>highscorefileR = open(r&quot;highscore.txt&quot;,&quot;r+&quot;) score = int(score) highscore = highscorefileR.read(3) for line in highscore: for i in line: # Checking for the digit in # the string if i.isdigit() == True: score = int(score) highscore.rstrip(&quot;\x003&quot;) highscore.rstrip(&quot;\x00&quot;) highscore.rstrip(&quot; \t\r\n\0&quot;) highscore = int(highscore) if score &gt;= highscore+1: score = str(score) score.rstrip(' \t\r\n\0') highscorefileW = open(r&quot;highscore.txt&quot;,&quot;w&quot;) highscore = score highscorefileR.write(score) print(highscore) </code></pre>
[ { "answer_id": 74241876, "author": "Vinay Jain", "author_id": 17995563, "author_profile": "https://Stackoverflow.com/users/17995563", "pm_score": 1, "selected": false, "text": "$vendor_products_list = $WCFM->wcfm_vendor_support->wcfm_get_products_by_vendor($vendor_id, 'publish', array('...
2022/10/28
[ "https://Stackoverflow.com/questions/74241182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361858/" ]
74,241,190
<p>Helo!</p> <p>How I make the following syntax of postgresql in SQL server without create subquery</p> <p>PGSQL:</p> <pre><code>SELECT COUNT(*) AS &quot;QUANTIDADE TOTAL&quot;, COUNT(*) FILTER(WHERE SEXO = 'Masculino') AS &quot;MASCULINO&quot; FROM FUNCIONARIOS; </code></pre> <p>I tried but got an error:<br /> Message 156, Level 15, State 1, Line 4</p> <p>Incorrect syntax next to 'WHERE' keyword.</p>
[ { "answer_id": 74241876, "author": "Vinay Jain", "author_id": 17995563, "author_profile": "https://Stackoverflow.com/users/17995563", "pm_score": 1, "selected": false, "text": "$vendor_products_list = $WCFM->wcfm_vendor_support->wcfm_get_products_by_vendor($vendor_id, 'publish', array('...
2022/10/28
[ "https://Stackoverflow.com/questions/74241190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9590785/" ]
74,241,203
<p>The data I retrieved from Mixpanel has the format:</p> <pre><code>&quot;{&quot;event&quot;:&quot;info1xxxxx&quot;,&quot;Id&quot;:&quot;0001&quot;} {&quot;event&quot;:&quot;info2xxxxx&quot;,&quot;Id&quot;:&quot;0002&quot;} {&quot;event&quot;:&quot;info3xxxxx&quot;,&quot;Id&quot;:&quot;0003&quot;} {&quot;event&quot;:&quot;info3xxxxx&quot;,&quot;Id&quot;:&quot;0003&quot;,&quot;other_key&quot;:&quot;value&quot;}...&quot; </code></pre> <p>It's a string of list of JSON which are separated by '\n'. And each JSON may have a different structure.</p> <p>I expect to convert it to list of JSON like:</p> <pre><code>[{&quot;event&quot;:&quot;info1xxxxx&quot;,&quot;Id&quot;:&quot;0001&quot;}, {&quot;event&quot;:&quot;info2xxxxx&quot;,&quot;Id&quot;:&quot;0002&quot;}, {&quot;event&quot;:&quot;info3xxxxx&quot;,&quot;Id&quot;:&quot;0003&quot;}, {&quot;event&quot;:&quot;info3xxxxx&quot;,&quot;Id&quot;:&quot;0003&quot;,&quot;other_key&quot;:&quot;value&quot;},...] </code></pre> <p>How could I do this? Looking for the help, thank you!</p>
[ { "answer_id": 74241876, "author": "Vinay Jain", "author_id": 17995563, "author_profile": "https://Stackoverflow.com/users/17995563", "pm_score": 1, "selected": false, "text": "$vendor_products_list = $WCFM->wcfm_vendor_support->wcfm_get_products_by_vendor($vendor_id, 'publish', array('...
2022/10/28
[ "https://Stackoverflow.com/questions/74241203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20094033/" ]
74,241,234
<p>I am writing a script to install packages from .deb files, but first, I would like to check if each package is already installed. I have a config file that contains the information for the packages as hashmaps, like this:</p> <pre><code>declare -A package_a=( [name]=&quot;utility-blah&quot; [ver]=&quot;1.2&quot; [arch]=&quot;amd64&quot; ) declare -A package_b=( [name]=&quot;tool-bleh&quot; [ver]=&quot;3.4&quot; [arch]=&quot;all&quot; ) #and so on and so forth </code></pre> <p>My install script sources the config file, and I would like it to iterate over the packages, checking if they are installed, and installing them if they are not, like this:</p> <pre><code>source packages.config declare -a packageList=(&quot;package_a&quot; &quot;package_b&quot; &quot;package_d&quot;) for package in ${packageList[@]}; do # Check if the specific version is installed already if apt show ${package[name]}=${package[ver]}; then echo ${package[name]} ${package[ver]} is already installed. else echo Installing ${package[name]} sudo apt install path/to/files/${package[name]}_${package[ver]}_${package[arch]}.deb fi done </code></pre> <p>How can I have <code>package</code> point to the hashmap containing the information about the package and use it in the following commands?</p> <p>I'm using Bash 4.4.20 on Ubuntu 18.04</p>
[ { "answer_id": 74241385, "author": "markp-fuso", "author_id": 7366100, "author_profile": "https://Stackoverflow.com/users/7366100", "pm_score": 3, "selected": true, "text": "source packages.config\ndeclare -a packageList=(\"package_a\" \"package_b\" \"package_d\")\n\nfor pkg in \"${packa...
2022/10/28
[ "https://Stackoverflow.com/questions/74241234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872505/" ]
74,241,261
<p>I have a problem adding scores to an object with a for loop.</p> <p>what I'm trying to achieve is this:</p> <p>enter test num: 1</p> <p>enter test score: 58</p> <p>enter test num: 2</p> <p>etc...</p> <p>and then print out the three test numbers and the average, but I can't seem to get it to set the test num nor the score.</p> <p>this is the error I get after tring to add test 1 and test 1 score:</p> <pre><code>Traceback (most recent call last): File &quot;d:\pyproj\Lecture 5\Main.py&quot;, line 27, in &lt;module&gt; studentArray() File &quot;d:\pyproj\Lecture 5\Main.py&quot;, line 25, in studentArray s = student.setTestScore(test,score) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: student.setTestScore() missing 1 required positional argument: 'result' </code></pre> <p>Main.py</p> <pre><code>from student import student def studentArray(): classSize = int(input(&quot;how big is the class? &quot;)) classList = [] num=0 while not(num == classSize): firstName = input(&quot;\nWhat's the students first name? &quot;); lastName = input(&quot;\nWhat's the students last name? &quot;); homeAddress = input(&quot;\nWhat's the students home address? &quot;); schoolAddress = input(&quot;\nWhat's the students school address? &quot;); courseName = input(&quot;\nWhat course is the students taking? &quot;); courseCode = input(&quot;\nWhat's the course code? &quot;); classList.append(student(firstName,lastName,homeAddress,schoolAddress,courseName,courseCode)); num+=1 for s in classList: for i in range(len(classList)): test = int(input(&quot;enter test number: &quot;)) score = int(input(&quot;enter test score: &quot;)) s.setTestScore(test,score) print(&quot;\n&quot;,s) studentArray() </code></pre> <p>studentclass.py:</p> <pre><code>from Course import Course class student: def __init__(self,first, last, home, school,courseName,courseCode): self.firstName = first self.lastName = last self.homeAddress = home self.schoolAddress = school self.courseName = courseName self.courseCode = courseCode Course(courseName,courseCode) self.testResults = [] def setTestScore(self,test,result): if test &lt; 1 | result &lt; 0 | test &gt; 100: print(&quot;Error: Wrong test results.&quot;) else: self.testResults.append(result) def average(self): average = 0; total = 0; for result in self.testResults: total += result average = total / 3.0; return average; def __str__(self): testAString = &quot;&quot; for testResult in self.testResults: testAString += str(testResult) + &quot; &quot; result = &quot;Student name:\n&quot;+self.firstName + &quot; &quot; + self.lastName+&quot;\n&quot;; result += &quot;Course name:\n&quot;+self.courseName+&quot;\n&quot;; result += &quot;Course Code: &quot;+ self.courseCode+&quot;\n&quot;; result += &quot;Test results:\n&quot;+testAString+&quot;\n&quot;; result += &quot;Average:\n&quot;, str(self.average()), &quot;\n&quot;; result += &quot;Home Address:\n&quot;+self.homeAddress+&quot;\n&quot;; result += &quot;School Address:\n&quot;+ self.schoolAddress; return result; </code></pre> <p>Courseclass.py:</p> <pre><code>class Course: def __init__(self,course,code): self.course = course self.code = code def setCourseName(self,name): self.course = name def setCourseCode(self, code): self.course = code </code></pre>
[ { "answer_id": 74241335, "author": "Alexander", "author_id": 17829451, "author_profile": "https://Stackoverflow.com/users/17829451", "pm_score": 0, "selected": false, "text": "|" }, { "answer_id": 74241373, "author": "drx", "author_id": 20353137, "author_profile": "ht...
2022/10/28
[ "https://Stackoverflow.com/questions/74241261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20248393/" ]
74,241,286
<p>Suppose I have a dataset:</p> <p>Have:</p> <pre><code>example1 example2 11-2001-6 st3829s 11-2001-6 s8290s 11-201-6 sts39 </code></pre> <p>Want:</p> <pre><code>example1 example2 2001 3829 2001 8290 NA NA </code></pre> <p>I want to output the numbers that are 4 contiguous numbers or n numbers (specify length). If no group of 4 numbers occurs together return NA.</p>
[ { "answer_id": 74241407, "author": "abdul rahman souda", "author_id": 17082032, "author_profile": "https://Stackoverflow.com/users/17082032", "pm_score": -1, "selected": false, "text": "preg_match_all('/[0-9][0-9][0-9][0-9]/', '11-2001-6 st3829s', $output_array);\n" }, { "answer_...
2022/10/28
[ "https://Stackoverflow.com/questions/74241286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9074261/" ]
74,241,306
<p>I have monthly data, and I would like to add another column for the period. The column would say M01 for January, M02 for February, M03 for March, and so on. Is there a way to do this?</p> <p>This is what I have:</p> <pre><code>unemployment = data.frame(Month = c(&quot;Sept 2002&quot;, &quot;Oct 2002&quot;, &quot;Nov 2002&quot;, &quot;Dec 2002&quot;, &quot;Jan 2003&quot;, &quot;Feb 2003&quot;), Total = c(5.7, 5.7, 5.9, 6, 5.8, 5.9)) &gt; unemployment Month Total 1 Sept 2002 5.7 2 Oct 2002 5.7 3 Nov 2002 5.9 4 Dec 2002 6.0 5 Jan 2003 5.8 6 Feb 2003 5.9 </code></pre> <p>This is what I want:</p> <pre><code> Month Period Total 1 Sept 2002 M09 5.7 2 Oct 2002 M10 5.7 3 Nov 2002 M11 5.9 4 Dec 2002 M12 6.0 5 Jan 2003 M01 5.8 6 Feb 2003 M02 5.9 </code></pre> <p><strong>EDIT</strong> Updated code to show all 12 months</p> <pre><code>structure(list(Month = c(&quot;Jan&quot;, &quot;Feb&quot;, &quot;Mar&quot;, &quot;Apr&quot;, &quot;May&quot;, &quot;June&quot; ), Year = c(&quot;2003&quot;, &quot;2003&quot;, &quot;2003&quot;, &quot;2003&quot;, &quot;2003&quot;, &quot;2003&quot;), Unemp_percent = c(5.8, 5.9, 5.9, 6, 6.1, 6.3)), row.names = 5:10, class = &quot;data.frame&quot;) </code></pre>
[ { "answer_id": 74241403, "author": "dcsuka", "author_id": 19512611, "author_profile": "https://Stackoverflow.com/users/19512611", "pm_score": 0, "selected": false, "text": "left_join" }, { "answer_id": 74241475, "author": "Just James", "author_id": 19730031, "author_p...
2022/10/28
[ "https://Stackoverflow.com/questions/74241306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15858688/" ]
74,241,311
<p>Following snippet gives my intention of unzipping <code>t1, t2, t3</code> or <code>t1, t2</code> depending upon the task. I know such <code>if-else</code> on <code>for</code> statement doesn't exist but I am wondering is there a workaround for this. Any help or clarification questions are welcome.</p> <pre><code>def func(task, t1, t2, t3): if task == 'abc': # t3=None for this case for t1, t2 in zip(t1, t2): // do something else: for t1, t2, t3 in zip(t1, t2, t3): // do something if task == 'abc': t3 = None func(task, t1, t2, t3) </code></pre> <p>Is there a way we can write a single for loop statement and then unzip the parameters inside of the for loop depending upon the <code>task</code> value. The problem is that when the third parameters is <code>None</code>, it throws the error: <code>TypeError: zip argument #3 must support iteration when </code>task==abc<code>. I want to have a common of </code>do something`.</p>
[ { "answer_id": 74241403, "author": "dcsuka", "author_id": 19512611, "author_profile": "https://Stackoverflow.com/users/19512611", "pm_score": 0, "selected": false, "text": "left_join" }, { "answer_id": 74241475, "author": "Just James", "author_id": 19730031, "author_p...
2022/10/28
[ "https://Stackoverflow.com/questions/74241311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3306097/" ]
74,241,325
<p>I realized today that some users where calling the endpoints of my application through a script. Ideally, I would want to prevent them from doing that but there doesn't seem to be any absolute way of doing it.</p> <p>To give you more context, my app is built with React and communicates with the backend through a REST API. To authenticate, users need to send their email and password to get a token that gets stored in a cookie.</p> <p>Do any of you have ever had the need to do so ? Am I thinking too far ? What solutions can be used ?</p> <p>I made a bit of research to see if other people were facing the same problem and I found little content. The answers given to similar questions made it clear that it's not possible but I would like get other people's experience around the question. And see what they did to make it harder to call a public API from outside the client app.</p>
[ { "answer_id": 74241403, "author": "dcsuka", "author_id": 19512611, "author_profile": "https://Stackoverflow.com/users/19512611", "pm_score": 0, "selected": false, "text": "left_join" }, { "answer_id": 74241475, "author": "Just James", "author_id": 19730031, "author_p...
2022/10/28
[ "https://Stackoverflow.com/questions/74241325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20361920/" ]
74,241,359
<p>I've spent already 4h on trying to solve this one, but I just give up. I'm trying to make an responsive menu, but when I press on hamburger menu, I would like my menu to drop down under the navbar, not on top of it, as you can see on the snippet.</p> <pre><code>&lt;body&gt; &lt;nav class=&quot;nav&quot;&gt; &lt;img src=&quot;./img/logo.png&quot; class=&quot;nav__logo&quot; alt=&quot; logo.&quot; /&gt; &lt;ul class=&quot;nav__menu&quot;&gt; &lt;li class=&quot;nav__item&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;nav__link&quot;&gt;link1&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;nav__item&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;nav__link&quot;&gt;link2&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;nav__item&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;nav__link&quot;&gt;link3&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;nav__item&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;nav__link&quot;&gt;link4&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;nav__item&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;nav__link&quot;&gt;link5&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;nav__item&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;nav__link&quot;&gt;link6&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;nav__item&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;nav__link&quot;&gt;link7&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class=&quot;hamburger__menu&quot;&gt; &lt;span class=&quot;bar&quot;&gt;&lt;/span&gt; &lt;span class=&quot;bar&quot;&gt;&lt;/span&gt; &lt;span class=&quot;bar&quot;&gt;&lt;/span&gt; &lt;/div&gt; &lt;/nav&gt; &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt; &lt;/body&gt; </code></pre> <pre><code>.nav { width: 100%; display: flex; max-height: 10vh; border: 1px solid red; background-color: #fff; justify-content: space-between; align-content: center; box-shadow: rgba(0, 0, 0, 0.04) 0px 3px 5px; z-index: 5; } .nav__logo { width: 100px; height: 100px; align-self: center; margin-left: 1rem; } .nav__menu { display: flex; list-style: none; align-self: center; gap: 2rem; margin-right: 1rem; align-items: center; } li { list-style: none; } ul { padding-left: 0; } a { color: black; text-decoration: none; } .hamburger__menu { display: none; cursor: pointer; align-self: center; margin-right: 1em; } .bar { display: block; width: 25px; height: 3px; margin: 5px auto; -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; background-color: black; } @media (max-width: 768px) { .hamburger__menu { display: block; } .hamburger__menu.active .bar:nth-child(2) { opacity: 0; } .hamburger__menu.active .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); } .hamburger__menu.active .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); } .nav__menu { position: fixed; left: 0%; top: -100%; gap: 0; flex-direction: column; width: 100%; text-align: center; transition: 1s ease-in-out; background-color: #fff; box-shadow: rgba(33, 35, 38, 0.1) 0px 10px 10px -10px; border: 1px solid green; z-index: 1; } .nav__item { margin: 16px 0; } .nav__menu.active { top: 7.5%; transition: top 1s; } } </code></pre> <pre><code>const hamburger = document.querySelector(&quot;.hamburger__menu&quot;); const navMenu = document.querySelector(&quot;.nav__menu&quot;); hamburger.addEventListener(&quot;click&quot;, function () { hamburger.classList.toggle(&quot;active&quot;); navMenu.classList.toggle(&quot;active&quot;); }); document.querySelectorAll(&quot;.nav__link&quot;).forEach((n) =&gt; n.addEventListener(&quot;click&quot;, () =&gt; { hamburger.classList.remove(&quot;active&quot;); navMenu.classList.remove(&quot;active&quot;); }) ); </code></pre> <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>"use strict"; const hamburger = document.querySelector(".hamburger__menu"); const navMenu = document.querySelector(".nav__menu"); hamburger.addEventListener("click", function() { hamburger.classList.toggle("active"); navMenu.classList.toggle("active"); }); document.querySelectorAll(".nav__link").forEach((n) =&gt; n.addEventListener("click", () =&gt; { hamburger.classList.remove("active"); navMenu.classList.remove("active"); }) );</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>.nav { width: 100%; display: flex; max-height: 10vh; border: 1px solid red; background-color: #fff; justify-content: space-between; align-content: center; box-shadow: rgba(0, 0, 0, 0.04) 0px 3px 5px; z-index: 5; } .nav__logo { width: 100px; height: 100px; align-self: center; margin-left: 1rem; } .nav__menu { display: flex; list-style: none; align-self: center; gap: 2rem; margin-right: 1rem; align-items: center; } li { list-style: none; } ul { padding-left: 0; } a { color: black; text-decoration: none; } .hamburger__menu { display: none; cursor: pointer; align-self: center; margin-right: 1em; } .bar { display: block; width: 25px; height: 3px; margin: 5px auto; -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; background-color: black; } @media (max-width: 768px) { .hamburger__menu { display: block; } .hamburger__menu.active .bar:nth-child(2) { opacity: 0; } .hamburger__menu.active .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); } .hamburger__menu.active .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); } .nav__menu { position: fixed; left: 0%; top: -100%; gap: 0; flex-direction: column; width: 100%; text-align: center; transition: 1s ease-in-out; background-color: #fff; box-shadow: rgba(33, 35, 38, 0.1) 0px 10px 10px -10px; border: 1px solid green; z-index: 1; } .nav__item { margin: 16px 0; } .nav__menu.active { top: 7.5%; transition: top 1s; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt; &lt;nav class="nav"&gt; &lt;img src="./img/logo.png" class="nav__logo" alt="logo." /&gt; &lt;ul class="nav__menu"&gt; &lt;li class="nav__item"&gt;&lt;a href="#" class="nav__link"&gt;link1&lt;/a&gt;&lt;/li&gt; &lt;li class="nav__item"&gt;&lt;a href="#" class="nav__link"&gt;link2&lt;/a&gt;&lt;/li&gt; &lt;li class="nav__item"&gt;&lt;a href="#" class="nav__link"&gt;link3&lt;/a&gt;&lt;/li&gt; &lt;li class="nav__item"&gt;&lt;a href="#" class="nav__link"&gt;link4&lt;/a&gt;&lt;/li&gt; &lt;li class="nav__item"&gt;&lt;a href="#" class="nav__link"&gt;link5&lt;/a&gt;&lt;/li&gt; &lt;li class="nav__item"&gt;&lt;a href="#" class="nav__link"&gt;link6&lt;/a&gt;&lt;/li&gt; &lt;li class="nav__item"&gt;&lt;a href="#" class="nav__link"&gt;link7&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class="hamburger__menu"&gt; &lt;span class="bar"&gt;&lt;/span&gt; &lt;span class="bar"&gt;&lt;/span&gt; &lt;span class="bar"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/nav&gt; &lt;/body&gt;</code></pre> </div> </div> </p> <p>I've tried to do it with z-index, but if i'll add a negative z-index on the menu, then I can't click the links.</p>
[ { "answer_id": 74241550, "author": "Ndaw_Kunda", "author_id": 17432264, "author_profile": "https://Stackoverflow.com/users/17432264", "pm_score": 0, "selected": false, "text": "@media (max-width: 768px) {\n ...\n \n .nav__menu {\n ...\n z-index: -1;\n }\n \n ...\n}" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74241359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19055230/" ]
74,241,399
<p>I would like to know how to loop through things in Selenium. Basically, I just want to make a for-loop to find all the &quot;panel titles&quot; that have earlier than a certain time and then an if statement that says if it has 4 golfers then I will click the book button.</p> <p>I'm just not sure how you iterate through the xpaths to these things in HTML. All I have been able to do so far is just click on the correct Day with my code below, however I can't figure out</p> <pre><code> ### Gets Edge driver and doesnt need extension update driver = webdriver.Edge(service=EdgeService(EdgeChromiumDriverManager().install())) driver.get( 'https://teewire.net/granada/' ) driver.maximize_window() pause(2) data_moment = &quot;2022-10-30&quot; driver.find_element(By.XPATH,f&quot;//*[@id='gz-time-slot-calendar']//a[@data-moment='{data_moment}']&quot;).click() pause(5) data_moment = &quot;2022-10-30&quot; driver.find_element(By.XPATH,f&quot;//*[@id='gz-time-slot-calendar']//a[@data-moment='{data_moment}']&quot;).click() pause(5) a = driver.find_elements(By.XPATH,&quot;//*[@id='time-slots-container-id']//a[@class='{'panel-heading'}']&quot;) pause(2) for i in a: print(i.text) </code></pre> <p>Here's an attached file. <a href="https://i.stack.imgur.com/QrTTB.png" rel="nofollow noreferrer">HTML</a></p>
[ { "answer_id": 74241550, "author": "Ndaw_Kunda", "author_id": 17432264, "author_profile": "https://Stackoverflow.com/users/17432264", "pm_score": 0, "selected": false, "text": "@media (max-width: 768px) {\n ...\n \n .nav__menu {\n ...\n z-index: -1;\n }\n \n ...\n}" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74241399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20278039/" ]
74,241,402
<p>I am writing a code where I am asking user to assign value to an array and where user press enter key I want to assign a default value to array elements. Any idea how to proceed with this ?</p> <p>I have tried using cin.get() method but it is not working. Here is my code :</p> <pre><code> #include&lt;iostream&gt; #include&lt;math.h&gt; #include&lt;cmath&gt; using namespace std; int main() { int n; cout &lt;&lt; &quot;Enter array size: &quot;; cin &gt;&gt; n; double y[n]; string input; for(int i=0; i&lt;n; ++i) { cout &lt;&lt; &quot;Enter Initial Velocity ( Default Value 0 ) : &quot; ; y[i] = cin.get(); if (input==&quot;&quot;) { y[i]=0.0; } else { y[i]=stod(input); } } } </code></pre>
[ { "answer_id": 74241550, "author": "Ndaw_Kunda", "author_id": 17432264, "author_profile": "https://Stackoverflow.com/users/17432264", "pm_score": 0, "selected": false, "text": "@media (max-width: 768px) {\n ...\n \n .nav__menu {\n ...\n z-index: -1;\n }\n \n ...\n}" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74241402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362007/" ]
74,241,446
<p>I want to create a DynamoDB table and backup using AWS Typescript CDK. Creating DynamoDB using CDK is pretty straightforward, but implementing backup is not easy. Could anyone help me to implement a backup using CDK? I tried to solve this problem, but not enough references on the internet. I would appreciate it if anyone could provide a full example of this scenario. Thanks in advance.</p> <p>I tried using this<a href="https://www.stackoverflow.com/">https://aws-cdk.com/aws-backup/</a>, but not really helpful.</p>
[ { "answer_id": 74241550, "author": "Ndaw_Kunda", "author_id": 17432264, "author_profile": "https://Stackoverflow.com/users/17432264", "pm_score": 0, "selected": false, "text": "@media (max-width: 768px) {\n ...\n \n .nav__menu {\n ...\n z-index: -1;\n }\n \n ...\n}" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74241446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14494450/" ]
74,241,486
<p>I need to work with only a part of the info-json that youtubedl obtains: the problem is in a video platform where, in the browser, you can watch the video or download/hear the audio file (that is besides the internal audio files from the video, like the &quot;visual&quot; option and the &quot;podcast&quot; option).<br> The problem is that it downloads both files (video+audio), this is how I obtain the info:</p> <pre><code>ydl = youtube_dl.YoutubeDL({'retries': 10 }) result = ydl.extract_info(vurl, download=False) </code></pre> <p>Where <code>vurl</code> is the video url; the json that I get in <code>result</code> is:</p> <pre><code>{ &quot;_type&quot;: &quot;playlist&quot;, &quot;entries&quot;: [ { &quot;formats&quot;: [ { &quot;format_id&quot;: &quot;3&quot;, &quot;manifest_url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556.mpd&quot;, &quot;ext&quot;: &quot;m4a&quot;, &quot;width&quot;: null, &quot;height&quot;: null, &quot;tbr&quot;: 96.0, &quot;asr&quot;: 48000, &quot;fps&quot;: null, &quot;language&quot;: &quot;eng&quot;, &quot;format_note&quot;: &quot;DASH audio&quot;, &quot;filesize&quot;: null, &quot;container&quot;: &quot;m4a_dash&quot;, &quot;vcodec&quot;: &quot;none&quot;, &quot;acodec&quot;: &quot;mp4a.40.5&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556_audio.mp4&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;3 - audio only (DASH audio)&quot;, &quot;protocol&quot;: &quot;https&quot; }, { &quot;format_id&quot;: &quot;2&quot;, &quot;manifest_url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556.mpd&quot;, &quot;ext&quot;: &quot;mp4&quot;, &quot;width&quot;: 480, &quot;height&quot;: 270, &quot;tbr&quot;: 350.0, &quot;asr&quot;: null, &quot;fps&quot;: null, &quot;language&quot;: null, &quot;format_note&quot;: &quot;DASH video&quot;, &quot;filesize&quot;: null, &quot;container&quot;: &quot;mp4_dash&quot;, &quot;vcodec&quot;: &quot;avc1.4d401f&quot;, &quot;acodec&quot;: &quot;none&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556_270.mp4&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;2 - 480x270 (DASH video)&quot;, &quot;protocol&quot;: &quot;https&quot; }, { &quot;format_id&quot;: &quot;1&quot;, &quot;manifest_url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556.mpd&quot;, &quot;ext&quot;: &quot;mp4&quot;, &quot;width&quot;: 960, &quot;height&quot;: 540, &quot;tbr&quot;: 1500.0, &quot;asr&quot;: null, &quot;fps&quot;: null, &quot;language&quot;: null, &quot;format_note&quot;: &quot;DASH video&quot;, &quot;filesize&quot;: null, &quot;container&quot;: &quot;mp4_dash&quot;, &quot;vcodec&quot;: &quot;avc1.640028&quot;, &quot;acodec&quot;: &quot;none&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556_540.mp4&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;1 - 960x540 (DASH video)&quot;, &quot;protocol&quot;: &quot;https&quot; }, { &quot;format_id&quot;: &quot;hls-219&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/hls/6e8ecf12-f7f8-4565-a8ae-a52c76333556_270.m3u8&quot;, &quot;manifest_url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/hls/6e8ecf12-f7f8-4565-a8ae-a52c76333556.m3u8&quot;, &quot;tbr&quot;: 219.293, &quot;ext&quot;: &quot;mp4&quot;, &quot;fps&quot;: 14.985, &quot;protocol&quot;: &quot;m3u8&quot;, &quot;preference&quot;: null, &quot;width&quot;: 480, &quot;height&quot;: 270, &quot;vcodec&quot;: &quot;avc1.4d401f&quot;, &quot;acodec&quot;: &quot;mp4a.40.5&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;hls-219 - 480x270&quot; }, { &quot;format_id&quot;: &quot;hls-475&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/hls/6e8ecf12-f7f8-4565-a8ae-a52c76333556_540.m3u8&quot;, &quot;manifest_url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/hls/6e8ecf12-f7f8-4565-a8ae-a52c76333556.m3u8&quot;, &quot;tbr&quot;: 475.81, &quot;ext&quot;: &quot;mp4&quot;, &quot;fps&quot;: 29.97, &quot;protocol&quot;: &quot;m3u8&quot;, &quot;preference&quot;: null, &quot;width&quot;: 960, &quot;height&quot;: 540, &quot;vcodec&quot;: &quot;avc1.4d401f&quot;, &quot;acodec&quot;: &quot;mp4a.40.5&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;hls-475 - 960x540&quot; } ], &quot;subtitles&quot;: {}, &quot;thumbnail&quot;: &quot;https://photos.brighteon.com/file/brighteon-thumbnails/poster/05fc220c-5fa5-4ac5-b2e4-96229bce92cf&quot;, &quot;id&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9-1&quot;, &quot;title&quot;: &quot;Situation Update, 10/24/22 - Dirty bomb false flag event to IGNITE World War with Russia (1)&quot;, &quot;n_entries&quot;: 2, &quot;playlist&quot;: &quot;Situation Update, 10/24/22 - Dirty bomb false flag event to IGNITE World War with Russia&quot;, &quot;playlist_id&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;playlist_title&quot;: &quot;Situation Update, 10/24/22 - Dirty bomb false flag event to IGNITE World War with Russia&quot;, &quot;playlist_uploader&quot;: null, &quot;playlist_uploader_id&quot;: null, &quot;playlist_index&quot;: 1, &quot;extractor&quot;: &quot;generic&quot;, &quot;webpage_url&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;webpage_url_basename&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;extractor_key&quot;: &quot;Generic&quot;, &quot;thumbnails&quot;: [ { &quot;url&quot;: &quot;https://photos.brighteon.com/file/brighteon-thumbnails/poster/05fc220c-5fa5-4ac5-b2e4-96229bce92cf&quot;, &quot;id&quot;: &quot;0&quot; } ], &quot;display_id&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9-1&quot;, &quot;requested_subtitles&quot;: null, &quot;requested_formats&quot;: [ { &quot;format_id&quot;: &quot;1&quot;, &quot;manifest_url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556.mpd&quot;, &quot;ext&quot;: &quot;mp4&quot;, &quot;width&quot;: 960, &quot;height&quot;: 540, &quot;tbr&quot;: 1500.0, &quot;asr&quot;: null, &quot;fps&quot;: null, &quot;language&quot;: null, &quot;format_note&quot;: &quot;DASH video&quot;, &quot;filesize&quot;: null, &quot;container&quot;: &quot;mp4_dash&quot;, &quot;vcodec&quot;: &quot;avc1.640028&quot;, &quot;acodec&quot;: &quot;none&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556_540.mp4&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;1 - 960x540 (DASH video)&quot;, &quot;protocol&quot;: &quot;https&quot; }, { &quot;format_id&quot;: &quot;3&quot;, &quot;manifest_url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556.mpd&quot;, &quot;ext&quot;: &quot;m4a&quot;, &quot;width&quot;: null, &quot;height&quot;: null, &quot;tbr&quot;: 96.0, &quot;asr&quot;: 48000, &quot;fps&quot;: null, &quot;language&quot;: &quot;eng&quot;, &quot;format_note&quot;: &quot;DASH audio&quot;, &quot;filesize&quot;: null, &quot;container&quot;: &quot;m4a_dash&quot;, &quot;vcodec&quot;: &quot;none&quot;, &quot;acodec&quot;: &quot;mp4a.40.5&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/dash/6e8ecf12-f7f8-4565-a8ae-a52c76333556_audio.mp4&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;3 - audio only (DASH audio)&quot;, &quot;protocol&quot;: &quot;https&quot; } ], &quot;format&quot;: &quot;1 - 960x540 (DASH video)+3 - audio only (DASH audio)&quot;, &quot;format_id&quot;: &quot;1+3&quot;, &quot;width&quot;: 960, &quot;height&quot;: 540, &quot;resolution&quot;: null, &quot;fps&quot;: null, &quot;vcodec&quot;: &quot;avc1.640028&quot;, &quot;vbr&quot;: null, &quot;stretched_ratio&quot;: null, &quot;acodec&quot;: &quot;mp4a.40.5&quot;, &quot;abr&quot;: null, &quot;ext&quot;: &quot;mp4&quot; }, { &quot;formats&quot;: [ { &quot;ext&quot;: &quot;mp3&quot;, &quot;width&quot;: null, &quot;height&quot;: null, &quot;tbr&quot;: null, &quot;format_id&quot;: &quot;0&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/audio/6e8ecf12-f7f8-4565-a8ae-a52c76333556.mp3&quot;, &quot;vcodec&quot;: &quot;none&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;0 - audio only&quot;, &quot;protocol&quot;: &quot;https&quot; } ], &quot;subtitles&quot;: {}, &quot;thumbnail&quot;: null, &quot;id&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9-2&quot;, &quot;title&quot;: &quot;Situation Update, 10/24/22 - Dirty bomb false flag event to IGNITE World War with Russia (2)&quot;, &quot;n_entries&quot;: 2, &quot;playlist&quot;: &quot;Situation Update, 10/24/22 - Dirty bomb false flag event to IGNITE World War with Russia&quot;, &quot;playlist_id&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;playlist_title&quot;: &quot;Situation Update, 10/24/22 - Dirty bomb false flag event to IGNITE World War with Russia&quot;, &quot;playlist_uploader&quot;: null, &quot;playlist_uploader_id&quot;: null, &quot;playlist_index&quot;: 2, &quot;extractor&quot;: &quot;generic&quot;, &quot;webpage_url&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;webpage_url_basename&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;extractor_key&quot;: &quot;Generic&quot;, &quot;display_id&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9-2&quot;, &quot;requested_subtitles&quot;: null, &quot;ext&quot;: &quot;mp3&quot;, &quot;width&quot;: null, &quot;height&quot;: null, &quot;tbr&quot;: null, &quot;format_id&quot;: &quot;0&quot;, &quot;url&quot;: &quot;https://video.brighteon.com/file/BTBucket-Prod/audio/6e8ecf12-f7f8-4565-a8ae-a52c76333556.mp3&quot;, &quot;vcodec&quot;: &quot;none&quot;, &quot;http_headers&quot;: { &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3680.1 Safari/537.36&quot;, &quot;Accept-Charset&quot;: &quot;ISO-8859-1,utf-8;q=0.7,*;q=0.7&quot;, &quot;Accept&quot;: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;, &quot;Accept-Encoding&quot;: &quot;gzip, deflate&quot;, &quot;Accept-Language&quot;: &quot;en-us,en;q=0.5&quot;, &quot;Referer&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot; }, &quot;format&quot;: &quot;0 - audio only&quot;, &quot;protocol&quot;: &quot;https&quot; } ], &quot;id&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;title&quot;: &quot;Situation Update, 10/24/22 - Dirty bomb false flag event to IGNITE World War with Russia&quot;, &quot;extractor&quot;: &quot;generic&quot;, &quot;webpage_url&quot;: &quot;https://www.brighteon.com/cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;webpage_url_basename&quot;: &quot;cadd23ad-e855-4c1b-ba6d-a605c71a07c9&quot;, &quot;extractor_key&quot;: &quot;Generic&quot; } </code></pre> <p>I want to modify the json (I need to delete the elements from <code>json[&quot;entries&quot;]</code> that in <code>element[&quot;ext&quot;]</code> do not have a video extension) and then use the modified json to download the video; is it possible?, and, in case it is, how?<br> Thanks in advance,</p>
[ { "answer_id": 74241550, "author": "Ndaw_Kunda", "author_id": 17432264, "author_profile": "https://Stackoverflow.com/users/17432264", "pm_score": 0, "selected": false, "text": "@media (max-width: 768px) {\n ...\n \n .nav__menu {\n ...\n z-index: -1;\n }\n \n ...\n}" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74241486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13570110/" ]
74,241,504
<p>When comming back to an initialized page it doesn't run ngOnInit. For example <code>/user/profile</code> shows username, I go on <code>/user/settings</code> change username, and came back to <code>/user/profile</code>. Username on <code>/user/profile</code> didn't change because ngOnInit wasn't called.</p> <p>So what I want is to re-init page which has been already initialized. This is <code>router.service.ts</code> which is used for navigation:</p> <pre><code>export class RouterService { constructor( private router: Router, ) { this.router.routeReuseStrategy.shouldReuseRoute = () =&gt; false; this.router.onSameUrlNavigation = &quot;reload&quot;; }; async go(path: string[], options: NavigationExtras = {}) { this.router.navigate(path, { ...options }); } } </code></pre> <p>If I add <code>replaceUrl: true</code> to the function options it works, initted page re-inits, <strong>but</strong> the url is not being saved to the browser history and browser back button doesn't work (it redirects to the beggining of the app).</p> <p>This is <code>app.module.ts</code>:</p> <pre><code>@NgModule({ declarations: [AppComponent], imports: [ ... BrowserModule, AppRoutingModule, HttpClientModule, ], providers: [ { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, ], bootstrap: [AppComponent] }) </code></pre> <p>This is <code>app-routing.module.ts</code>:</p> <pre><code>@NgModule({ imports: [ RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules, onSameUrlNavigation: &quot;reload&quot; }), ], exports: [RouterModule] }) export class AppRoutingModule { } </code></pre> <p>Those are the routes:</p> <pre><code>const routes = [ { path: &quot;user/profile&quot;, loadChildren: () =&gt; import(&quot;./user/profile/profile.module&quot;).then(m =&gt; m.ProfilePageModule), canActivate: [LoggedGuard], }, { path: 'user/settings', loadChildren: () =&gt; import('./user/settings/settings.module').then(m =&gt; m.SettingsPageModule), canActivate: [LoggedGuard], }, </code></pre>
[ { "answer_id": 74241550, "author": "Ndaw_Kunda", "author_id": 17432264, "author_profile": "https://Stackoverflow.com/users/17432264", "pm_score": 0, "selected": false, "text": "@media (max-width: 768px) {\n ...\n \n .nav__menu {\n ...\n z-index: -1;\n }\n \n ...\n}" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74241504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14494977/" ]
74,241,519
<p>please i want know In detail step by step please</p> <p>i will install plugin in script Written on the plugin site</p> <p>Run from the project root directory:</p> <pre><code> composer dump-autoload php artisan rout:clear </code></pre> <p>how can i do it please</p> <p>I have tried many tasks with no result</p>
[ { "answer_id": 74243682, "author": "Jaya Rathinam", "author_id": 4489475, "author_profile": "https://Stackoverflow.com/users/4489475", "pm_score": 0, "selected": false, "text": "php artisan route:clear\n" } ]
2022/10/28
[ "https://Stackoverflow.com/questions/74241519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18508838/" ]
74,241,522
<p>I have an address that looks like this: 3513 Jones Drive Apt #500a</p> <p>How do I capitalize any characters that come after Ap to be all caps. Including the a after the apartment number.</p> <p>3513 Jones Drive APT #500A</p> <p>I started using indexOf! Any help is appreciated.</p> <pre><code>NewAddress = toggleCaseText(GetRecordsLF_Address); //3513 Jones Drive Apt #500a FinalAddress = NewAddress.substring(NewAddress.indexOf('Ap') + 1); //needs to be 3513 Jones Drive APT #500A </code></pre>
[ { "answer_id": 74241569, "author": "Barmar", "author_id": 1491895, "author_profile": "https://Stackoverflow.com/users/1491895", "pm_score": 0, "selected": false, "text": "let NewAddress = '3513 Jones Drive Apt #500a';\nlet FinalAddress = NewAddress.replace(/Ap.*/, match => match.toUpperC...
2022/10/28
[ "https://Stackoverflow.com/questions/74241522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362076/" ]
74,241,523
<p>Python's <code>pandas</code> library allows getting <code>info()</code> on a data frame.</p> <p>For example.</p> <pre><code>&lt;class 'pandas.core.frame.DataFrame'&gt; RangeIndex: 30 entries, 0 to 29 Data columns (total 9 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Name 30 non-null object 1 PhoneNumber 30 non-null object 2 City 30 non-null object 3 Address 30 non-null object 4 PostalCode 30 non-null object 5 BirthDate 30 non-null object 6 Income 26 non-null float64 7 CreditLimit 30 non-null object 8 MaritalStatus 24 non-null object dtypes: float64(1), object(8) memory usage: 2.2+ KB </code></pre> <p>Is there an equivalent in Deedle's data frame? Something that can get an overview for missing values and the inferred types.</p>
[ { "answer_id": 74260934, "author": "Tomas Petricek", "author_id": 33518, "author_profile": "https://Stackoverflow.com/users/33518", "pm_score": 3, "selected": true, "text": "// Prints column names and types, with data preview\ndf.Print(true)\n\n// Print key range of rows (or key sequence...
2022/10/28
[ "https://Stackoverflow.com/questions/74241523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/977406/" ]
74,241,531
<p><code>BankAccount.java</code></p> <pre><code>public class BankAccount { private double checkingBalance; private double savingBalance; private static int numberOfAccounts; public BankAccount() { this(0, 0); numberOfAccounts++; } public BankAccount(double checkingInitial, double savingInitial) { this.checkingBalance = checkingInitial; this.savingBalance = savingInitial; numberOfAccounts++; } public static int getNumberOfAccounts() { return numberOfAccounts; } </code></pre> <p><code>Test.java</code></p> <pre><code>public class Test { public static void main(String[] args) { BankAccount account1 = new BankAccount(50, 50); BankAccount account2 = new BankAccount(100, 80); BankAccount account3 = new BankAccount(); System.out.println(&quot;number of accounts is &quot; + BankAccount.getNumberOfAccounts()); </code></pre> <p>I should get <code>number of accounts is 3</code> but I'm getting 4. If I instantiate all accounts with the parametrized constuctor, I get 3. If I add <code>BankAccount account4 = new BankAccount();</code>, I get 6. Is the default constructor called twice?</p>
[ { "answer_id": 74241559, "author": "access violation", "author_id": 19322069, "author_profile": "https://Stackoverflow.com/users/19322069", "pm_score": 2, "selected": true, "text": "public BankAccount() {\n this(0, 0);\n numberOfAccounts++; // <<<<<\n}\n" }, { "answer_id": ...
2022/10/28
[ "https://Stackoverflow.com/questions/74241531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10821328/" ]
74,241,538
<p>Given a UI element reference, how do I &quot;append&quot; a string to it so that I can find its next sibling element of type <code>XCUIElementTypeStaticText</code>?</p> <p>The framework I am using contains a <code>driver_helper.py</code> file.</p> <p>Within that file are the <code>find_element</code> &amp; <code>find_elements</code> methods defined as:</p> <pre><code>def find_element(self, locator: tuple) -&gt; WebElement: return self.driver.find_element(*locator) def find_elements(self, locator: tuple) -&gt; list[WebElement]: return self.driver.find_elements(*locator) </code></pre> <p>There is also a <code>selector_const.py</code> file containing declarations for the various types of selectors. The one I am using specifically for this question is:</p> <p><code>BY_XPATH = MobileBy.XPATH</code></p> <p>In the screen/page object file I am working on, I define a tuple <code>self.CHECKBOXES = (sc.BY_XPATH, '//XCUIElementTypeButton[@name=&quot;Square&quot;]')</code></p> <p>which I then use to create this variable: <code>checkboxes = self.driver_helper.find_elements(self.CHECKBOXES)</code></p> <p>I want to find a sibling element to one of the checkboxes, but this snippet of code:</p> <pre><code>checkboxes = self.driver_helper.find_elements(self.CHECKBOXES) sibling = ( sc.BY_XPATH, f'{checkboxes[0]}/following-sibling::XCUIElementTypeStaticText', ) test = self.driver_helper.find_element(sibling) print(&quot;checkbox 0 sibling element text: &quot; + str(test)) </code></pre> <p>fails with <code>NoSuchElementError: An element could not be located on the page using the given search parameters. </code> I have included a screenshot of the domain of the screen to show that the checkboxes do exist and that there is an <code>XCUIElementTypeStaticText</code> right next to it</p> <p>Domain of iOS app screen:</p> <pre><code>&lt;XCUIElementTypeButton type=&quot;XCUIElementTypeButton&quot; name=&quot;Square&quot; label=&quot;Square&quot; enabled=&quot;true&quot; visible=&quot;true&quot; accessible=&quot;true&quot; x=&quot;15&quot; y=&quot;428&quot; width=&quot;20&quot; height=&quot;21&quot; index=&quot;22&quot;/&gt; &lt;XCUIElementTypeStaticText type=&quot;XCUIElementTypeStaticText&quot; value=&quot;checkbox 1 text&quot; name=&quot;checkbox 1 text&quot; label=&quot;checkbox 1 text&quot; enabled=&quot;true&quot; visible=&quot;true&quot; accessible=&quot;true&quot; x=&quot;43&quot; y=&quot;428&quot; width=&quot;308&quot; height=&quot;18&quot; index=&quot;23&quot;/&gt; &lt;XCUIElementTypeButton type=&quot;XCUIElementTypeButton&quot; name=&quot;Square&quot; label=&quot;Square&quot; enabled=&quot;true&quot; visible=&quot;true&quot; accessible=&quot;true&quot; x=&quot;15&quot; y=&quot;478&quot; width=&quot;20&quot; height=&quot;21&quot; index=&quot;24&quot;/&gt; &lt;XCUIElementTypeStaticText type=&quot;XCUIElementTypeStaticText&quot; value=&quot;checkbox 2 text&quot; name=&quot;checkbox 2 text&quot; label=&quot;checkbox 2 text&quot; enabled=&quot;true&quot; visible=&quot;true&quot; accessible=&quot;true&quot; x=&quot;43&quot; y=&quot;478&quot; width=&quot;260&quot; height=&quot;35&quot; index=&quot;25&quot;/&gt; &lt;XCUIElementTypeButton type=&quot;XCUIElementTypeButton&quot; name=&quot;Square&quot; label=&quot;Square&quot; enabled=&quot;true&quot; visible=&quot;true&quot; accessible=&quot;true&quot; x=&quot;15&quot; y=&quot;542&quot; width=&quot;20&quot; height=&quot;21&quot; index=&quot;26&quot;/&gt; &lt;XCUIElementTypeStaticText type=&quot;XCUIElementTypeStaticText&quot; value=&quot;checkbox 3 text&quot; name=&quot;checkbox 3 text&quot; label=&quot;checkbox 3 text&quot; enabled=&quot;true&quot; visible=&quot;true&quot; accessible=&quot;true&quot; x=&quot;43&quot; y=&quot;542&quot; width=&quot;333&quot; height=&quot;86&quot; index=&quot;27&quot;/&gt; &lt;XCUIElementTypeButton type=&quot;XCUIElementTypeButton&quot; name=&quot;Square&quot; label=&quot;Square&quot; enabled=&quot;true&quot; visible=&quot;true&quot; accessible=&quot;true&quot; x=&quot;15&quot; y=&quot;657&quot; width=&quot;20&quot; height=&quot;21&quot; index=&quot;28&quot;/&gt; &lt;XCUIElementTypeStaticText type=&quot;XCUIElementTypeStaticText&quot; value=&quot;checkbox 4 text&quot; name=&quot;checkbox 4 text&quot; label=&quot;checkbox 4 text&quot; enabled=&quot;true&quot; visible=&quot;true&quot; accessible=&quot;true&quot; x=&quot;43&quot; y=&quot;657&quot; width=&quot;320&quot; height=&quot;52&quot; index=&quot;29&quot;/&gt; </code></pre>
[ { "answer_id": 74242733, "author": "AbiSaran", "author_id": 7671727, "author_profile": "https://Stackoverflow.com/users/7671727", "pm_score": 1, "selected": false, "text": "main_element = \"//*[@id=\"submenu1\"]/a[2]\"\n\nelement = driver.find_element(By.XPATH, main_element)\n\n\nsibling...
2022/10/28
[ "https://Stackoverflow.com/questions/74241538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1133255/" ]
74,241,598
<p>I want to do stripe monthly subscription with these conditions</p> <p>monthly charge 29.99 dollars</p> <p>when registration is done in the middle of the month installation price of 50.00 dollars will be added with subscription price.</p> <p>For example, user registered October 29th</p> <p>79.99 dollars should be paid at that timing. Installation Fees + Subscription Fees</p> <p>29.99 us dollar subscription is charge at the same date of next month how can I configure this? I want to know the configuration for stripe in codeigniter php</p> <pre><code>$price = \Stripe\Price::create([ 'unit_amount' =&gt; 29.99*100, 'currency' =&gt; 'usd', 'recurring' =&gt; ['interval' =&gt; 'month'], 'product' =&gt; 'Monthly Plan Home Internet', ]); $customer = \Stripe\Customer::create([ 'email' =&gt; $email, 'source' =&gt; $token, ]); $subscription = \Stripe\Subscription::create(array( &quot;customer&quot; =&gt; $customer-&gt;id, &quot;currency&quot; =&gt; $currency, &quot;add_invoice_items&quot;=&gt;array( array( &quot;price&quot;=&gt;$price-&gt;id ), ), &quot;items&quot; =&gt; array( array( &quot;price&quot; =&gt; &quot;29.99&quot; ), ), )); </code></pre>
[ { "answer_id": 74242733, "author": "AbiSaran", "author_id": 7671727, "author_profile": "https://Stackoverflow.com/users/7671727", "pm_score": 1, "selected": false, "text": "main_element = \"//*[@id=\"submenu1\"]/a[2]\"\n\nelement = driver.find_element(By.XPATH, main_element)\n\n\nsibling...
2022/10/28
[ "https://Stackoverflow.com/questions/74241598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362105/" ]
74,241,622
<p>Im wondering if there is any way to pass a reference down to an injected object in Javascript. Cannot use inheritance in this case as this class will take many objects as parameters within its constructor that are created elsewhere.</p> <pre><code>class Parent { private Child child; constructor(child: Child) { this.child = child; } // method needs to be called from within the `child` public log(message: string) { // logs out &quot;Parent logged: This is a log message from the child&quot; console.log(`Parent logged: ${message}`); } } </code></pre> <pre><code>class Child { private Parent: parent; constructor() { } log() { parent.log(&quot;This is a log message from the child&quot;); } } </code></pre> <p>If the object is built in the <code>Parent</code> constructor, you can just pass a reference in and then assign it to a property within <code>Child</code>. However, unfortunately the object is created outside the <code>Parent</code> class.</p> <pre><code> this.child = new Child(this); </code></pre>
[ { "answer_id": 74241701, "author": "Dan Crews", "author_id": 652728, "author_profile": "https://Stackoverflow.com/users/652728", "pm_score": 3, "selected": true, "text": "class Child {\n private Parent: parent;\n\n constructor() { }\n\n setParent(parent) {\n this.parent = p...
2022/10/28
[ "https://Stackoverflow.com/questions/74241622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3783770/" ]
74,241,644
<p>I started off by pulling the page with Selenium and I believe I passed the part of the page I needed to BeautifulSoup correctly using this code:</p> <pre><code>soup = BeautifulSoup(driver.find_element(&quot;xpath&quot;, '//*[@id=&quot;version_table&quot;]/tbody').get_attribute('outerHTML')) </code></pre> <p>Now I can parse using BeautifulSoup</p> <pre><code>query = soup.find_all(&quot;tr&quot;, class_=lambda x: x != &quot;hidden*&quot;) print (query) </code></pre> <p>My problem is that I need to dig deeper than just this one query. For example, I would like to nest this one inside of the first (so the first needs to be true, and then this one):</p> <pre><code>query2 = soup.find_all(&quot;tr&quot;, id = &quot;version_new_*&quot;) print (query2) </code></pre> <p>Logically speaking, this is what I'm trying to do (but I get SyntaxError: invalid syntax):</p> <pre><code>query = soup.find_all((&quot;tr&quot;, class_=lambda x: x != &quot;hidden*&quot;) and (&quot;tr&quot;, id = &quot;version_new_*&quot;)) print (query) </code></pre> <p>How do I accomplish this?</p>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17212057/" ]
74,241,689
<p>Let's assume that I have a list of the following objects:</p> <pre><code>class Row{ int a; int b; } </code></pre> <p>Data is set up in a way in which if sorted by a, the data automatically gets sorted by b. I need to write a function that takes in the parameters <code>(int x, List&lt;Row&gt; rows)</code> which finds the row whose b comes right after x. The number of records is 1000 so the basic and easy way to do it is to sort by a and then find the nearest element by using iteration. Is there another way to structure data in way in which I don't have to iterate through the entire list?</p>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7543388/" ]
74,241,766
<p>I am trying to add a superscript to my Y-axis title on ggplot but can't get it to work. I looked at similar questions on here such as <a href="https://stackoverflow.com/questions/37825558/how-to-use-superscript-with-ggplot2">this one</a>, but I think that because I have another symbol within the same parenthesis it is not working.</p> <p>I need my Y-axis title label to be: Total Density (individuals ∙ L⁻¹)</p> <p>I have tried the following:</p> <p>1.</p> <pre><code>labs(y=&quot;Total Density (individuals ∙&quot;~L^-1) </code></pre> <p>which almost works but I can't figure out how to add the closing parenthesis to this</p> <p>2.</p> <pre><code>labs(y=&quot;Total Density&quot;~(individuals ∙ L^-1)) </code></pre> <p>gives an error</p> <p>3.</p> <pre><code>labs(y=&quot;Total Density&quot;~(individuals~L^-1)) </code></pre> <p>this works, except when I try to add the multiplication ∙ symbol</p> <p>4.</p> <pre><code>ylab(&quot;Total Density&quot; &quot;(individuals p &quot;~L^-1*&quot;)&quot;) </code></pre> <p>this also gives an error</p> <p>5.</p> <pre><code>ylab(&quot;Total Density&quot; (~individuals ∙ L^-1)) </code></pre> <p>gives an error</p> <p>6.</p> <pre><code>labs(y=expression(Total~Density~(~individuals~∙~L^{-1}))) </code></pre> <p>error</p> <p>7.</p> <pre><code>labs(y=expression(Total~Density~(individuals ∙ L^-1))) </code></pre> <p>error</p> <p>8.</p> <pre><code>ylab(bquote('Total Density (individuals ∙ L^-1)')) </code></pre> <p>not putting the &quot;-1&quot; as superscript</p> <p>9.</p> <pre><code>ylab(bquote('Total Density (individuals ∙ L'^-1)) </code></pre> <p>almost works but again, can't figure out how to add the closing parenthesis to this</p> <p>I feel like I am close to get what I need, but no matter what I do I can't get it to work. Is there another way I should be typing in the multiplication sign to get this to work? I basically just copied/pasted &quot;∙&quot; to be there.</p>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14663341/" ]
74,241,790
<p>Is there a way where a checkbox will automatically appear when new data is entered in google sheet? So this will save time for me that whenever new data is entered, there's a corresponding checkbox to it.</p> <p>Thank you!</p>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16811337/" ]
74,241,809
<p>I need a list of URLs that pip is using to download packages from the internet preferably using a list of python packages in a requirements.txt file.</p> <p>Do you know a quick and easy solution to this problem? Maybe there is a tool out there or a feature of pip that I'm unaware of?</p> <p>I need to know the download urls <strong>without</strong> installing the packages. I can download the package .whl files though.</p> <p>I have tried using pip download -r requirements.txt which downloads files to my computer from pypi. I can see the urls over the network using wireshark. I don't know how to programmatically get the url used to download the file.</p>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7931834/" ]
74,241,835
<p>I am making a simple rock paper scissors game, so when you click on the button, it will say rock, paper or scissors. That works, however, I coded it to say &quot;Rock has been chosen&quot; when rock gets picked. Whenever rock shows up, it never shows up. I have tried using an on click, but that didnt work. I've also tried using double equals but that hasn't seemed to work either. Does anyone know how to fix it? Thank you so much.</p> <p>Home.html:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;title&gt;Rock paper scissors&lt;/title&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;p id=&quot;rand&quot;&gt;&lt;/p&gt; &lt;p id=&quot;decider&quot;&gt;&lt;/p&gt; &lt;button type=&quot;button&quot; id=&quot;randi&quot;&gt; new choice &lt;/button&gt; &lt;script src=&quot;Home.js&quot;&gt; &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Home.js:</p> <pre><code> function getRndInteger(min, max) { return Math.floor(Math.random() * (max - min) ); } const element = document.getElementById(&quot;randi&quot;); element.addEventListener(&quot;click&quot;, Choose, check); function Choose() { return document.getElementById(&quot;rand&quot;).innerHTML = choix[getRndInteger(0,3)]; } function check() { if (Choose() === 'Rock'); { document.getElementById(&quot;decider&quot;).innerHTML = &quot;rock has been chosen&quot;; } } const choix = [&quot;Rock&quot;, &quot;Paper&quot;, &quot;Scissors&quot;]; </code></pre>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19967743/" ]
74,241,845
<p>I'm trying to match two values from an images alt text. There will be other text inside these alt as well that can be ignored.<br /> The property will be either size or crop.</p> <p>The alt tags would look like:</p> <ul> <li>alt=&quot;size: 16 crop: mid crop&quot;</li> <li>alt=&quot;size: 16 crop: close crop&quot;</li> <li>alt=&quot;size: 16 crop: full body&quot;</li> <li>alt=&quot;size: 8 crop: mid crop&quot;</li> <li>alt=&quot;size: 8 crop: close crop&quot;</li> <li>alt=&quot;size: 8 crop: full body&quot;</li> <li>alt=&quot;size: 0 crop: mid crop&quot;</li> <li>alt=&quot;size: 0 crop: close crop&quot;</li> <li>alt=&quot;size: 0 crop: full body&quot;</li> </ul> <p>For size I'm trying to get &quot;0&quot; or &quot;8&quot; or &quot;16&quot; For crop I'm trying to get &quot;full body&quot; or &quot;mid crop&quot; or &quot;close crop&quot;</p> <p>is this possible?</p> <pre><code>function getImageProperty(image, property) { const regex = new RegExp(`${property}: (.+)[]]`, 'g'); const matches = image.altText.match(regex); return matches &amp;&amp; matches[1]; } /** * Returns a matching product image for provided size and crop. */ const getMatchingImage = (images: size, crop) =&gt; { return images.find( (image) =&gt; getImageProperty(image, size) &amp;&amp; getImageProperty(image, crop), ); }; </code></pre>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9430769/" ]
74,241,871
<p>First time posting here so could be a little vague.</p> <p>I recently started working on .NET Web API and was trying to create controller class for the API. In the controller class I wanted to instantiate an object of a class(lets say class GetLabels) whose methods will be used to modify variable of the class(in my case want to modify a dictionary of the GetLabels class which is private).</p> <pre><code>[Route(&quot;api/[controller]&quot;)] [ApiController] public class ConnectionController : ControllerBase { GetLabels getLabels; public ConnectionController() { getLabels = new GetLabels; } // Post: api/Connection/ [HttpPost] public IActionResult BuildLabels() { getLabels.Add(key,value);// a public method Add() of class GetLabels adds a key to the dictionary } [HttpPost&quot;{id}&quot;] public IActionResult RemoveLabels() { getlabels.Remove(key,value);// a public method Remove() of class GetLabels deletes the previously added key from the dictionary } } </code></pre> <p>When I run the Put methods one after another(first add and then delete), on the second put method I get empty dictionary even though I using the same instance of the class for both the controller methods. What I am doing wrong over here.</p>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362280/" ]
74,241,874
<p>I am having a problem with list of lists. I want to know if there is a way to eliminate a column if some value is present Example:</p> <pre><code>List = [[1, 4, 1, 1, 1, 4, 1], [2, 2, 2, 4, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3]] </code></pre> <p>if the number 4 is present in the list of lists eliminate that column giving for result:</p> <pre><code>Result_List = [[1, 0, 1, 0, 1, 0, 1], [2, 0, 2, 0, 2, 0, 2], [3, 0, 3, 0, 3, 0, 3]] </code></pre> <p>Due to 4 is present in List[0][1],List[1][3],List[0][5] Thanks for all the help.</p>
[ { "answer_id": 74241771, "author": "Nicholas Hansen-Feruch", "author_id": 11280068, "author_profile": "https://Stackoverflow.com/users/11280068", "pm_score": 1, "selected": false, "text": "import re\n\nquery = soup.find_all(\n lambda tag: \n tag.name == 'tr' and\n 'id' i...
2022/10/28
[ "https://Stackoverflow.com/questions/74241874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18655289/" ]
74,241,881
<p>What is the most idiomatic way to achieve function currying?</p> <p>Eg. in Haskell:</p> <pre class="lang-hs prettyprint-override"><code>times a b = a * b -- This can then be used uncurried: times 2 3 -- Result is 6 -- But there is also auto-currying: (times 2) 3 -- This works too </code></pre> <p>In Julia, some built-ins support this:</p> <pre><code>&lt;(8, 7) # Result is false &lt;(8)(7) # Same 7 |&gt; &lt;(8) # Same </code></pre> <p>However, user-defined functions don't automatically have this functionality:</p> <pre><code>times(a, b) = a * b times(2, 3) # Result is 6 3 |&gt; times(2) # MethodError: no method matching times(::Int64) </code></pre> <p>I can manually define a one-argument version and then it works:</p> <pre><code>times(a) = b -&gt; a * b </code></pre> <p>But my question is, is there a <em>better</em> way?</p>
[ { "answer_id": 74255597, "author": "BallpointBen", "author_id": 5496433, "author_profile": "https://Stackoverflow.com/users/5496433", "pm_score": -1, "selected": false, "text": "julia> struct Curry\n func::Function\n args::Tuple\n Curry(func, args...) = new(func, args)\...
2022/10/28
[ "https://Stackoverflow.com/questions/74241881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/579078/" ]
74,241,892
<p>I want to be able to call <code>setInterval</code> (or something similar) at two different lengths, alternating.</p> <p>For example, running a function after 5 seconds, then 1 second, then 5 seconds again, and so on.</p> <p>Is this possible? I tried a function that alternates the value, but it didn't seem to work.</p> <pre><code>let num = 5000 function alternateNum() { if (num === 5000) { num = 1000 } else { num = 5000 } } setInterval(() =&gt; { // ... alternateNum() }, num); </code></pre>
[ { "answer_id": 74241908, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 1, "selected": false, "text": "setInterval(() => {\n console.log(\"first\");\n setTimeout(() => console.log(\"second\"), 750);\n}, 2000);" }...
2022/10/28
[ "https://Stackoverflow.com/questions/74241892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1950503/" ]
74,241,896
<p>I can implement my own generator function which returns a Generator. The type for this can be defined as <code>type Iterable = { [Symbol.iterator](): Generator };</code>, but this isn't valid for built-in types like Array. Probably because they're designed to iterate multiple times instead of just once.</p> <p>Reading the docs on Array, it says this method returns &quot;new array iterator object&quot; which links to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol</a></p> <pre><code>type IterableBuiltIn = { [Symbol.iterator](): { next: any, value: any, return: any }; const array: IterableBuiltIn = [1, 2, 3]; for (const value in array) { console.log(value); } </code></pre>
[ { "answer_id": 74241908, "author": "caTS", "author_id": 18244921, "author_profile": "https://Stackoverflow.com/users/18244921", "pm_score": 1, "selected": false, "text": "setInterval(() => {\n console.log(\"first\");\n setTimeout(() => console.log(\"second\"), 750);\n}, 2000);" }...
2022/10/28
[ "https://Stackoverflow.com/questions/74241896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3854436/" ]
74,241,900
<p>I am trying to code something basic in python just for fun and I encountered an issue,</p> <pre><code># Employee is a class with the initialization being self, name, status e1 = Employee(&quot;Tom, Lincoln&quot;, &quot;Present&quot;) e2 = Employee(&quot;Sam, Bradley&quot;, &quot;Absent&quot;) print(e1.status) # printing e1 status will make &quot;Present&quot; or &quot;Absent&quot; while True: try: cmd = input(&quot;Cmd: &quot;) if cmd == &quot;status_check&quot;: who = input(&quot;Who: &quot;) # putting in e1 or e2 will get their respective statuses </code></pre> <p>I've tried everything I can think off like, making it so that it gets a number out of the <code>input(&quot;Who: &quot;)</code> input so I can better use eval or exac, but doing that makes it so I cant run <code>e1.status</code> because all it has is a 1 and I can't make a &quot;e&quot; appear in front of it so I can't run <code>e1.status</code>. I've also tried using just eval or exac but that didn't get the wanted result because I would have to type my code in the <code>input(&quot;Cmd: &quot;)</code>. That's isn't the only things I've tried but those are some that come to mind.</p> <p>I'm just stumped here.</p>
[ { "answer_id": 74241920, "author": "Silvio Mayolo", "author_id": 2288659, "author_profile": "https://Stackoverflow.com/users/2288659", "pm_score": 3, "selected": true, "text": "e1 = Employee(\"Tom, Lincoln\", \"Present\")\ne2 = Employee(\"Sam, Bradley\", \"Absent\")\n" }, { "answ...
2022/10/28
[ "https://Stackoverflow.com/questions/74241900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20362293/" ]
74,241,939
<p>When i type the command <code>gcc filename.c</code> a new file 'a.exe' is created, then i have to run <code>a.exe</code> to get my program to run.</p> <p>Is there a way just to type one command to run my program or can you run a C program without having a new .exe file being created?</p> <p>I use gcc version <strong>gcc (MinGW.org GCC-6.3.0-1) 6.3.0</strong></p> <p>(Complete beginner with C)</p>
[ { "answer_id": 74241971, "author": "user1234", "author_id": 20326824, "author_profile": "https://Stackoverflow.com/users/20326824", "pm_score": -1, "selected": false, "text": "build.bat\n gcc %1.c -o %1.exe\n %1.exe\n" }, { "answer_id": 74242446, "author": "John Bode", ...
2022/10/29
[ "https://Stackoverflow.com/questions/74241939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18749472/" ]
74,241,965
<p><strong>What I want to achieve, is to keep changes in the state between refresh.</strong> <strong>Now I think about this solution below,</strong> <em>(using localStorage with useRef())</em> but I'm suspicious about it, it seems like it isn't technically correct, what do you think about that? It is useRef() supposed to be used for cases like this one, or maybe there are other more convenient solutions? It is supposed to not use any database. <strong>Is a little project, a movie app, not a prod</strong> or stuff like that, the 5mb from localStorage are pretty much enough.</p> <p><strong>State (fetched from the API)</strong></p> <pre><code> const [popularMovies, setPopularMovies] = useState(false); </code></pre> <p><strong>Fetch Data for state</strong></p> <pre><code> function getPopularMoviesData() { const url = &quot;https://api.themoviedb.org/3/movie/popular?api_key=60186105dc57d2473a4b079bdee2fa31&amp;language=en-US&amp;page=1&quot;; fetch(url) .then((response) =&gt; response.json()) .then((data) =&gt; { setPopularMovies(data); }) .catch((err) =&gt; console.error(err)); } useEffect(() =&gt; { getPopularMoviesData(); }, []); </code></pre> <p><strong>useRef()</strong></p> <pre><code> const prevPopularMovies = useRef(); </code></pre> <p><strong>keep our previous data after each re-render</strong></p> <pre><code> useEffect(() =&gt; { prevPopularMovies.current = popularMovies; setPopularMovies(prevPopularMovies.current); }); </code></pre> <p><strong>localStorage for keeping data on refresh</strong></p> <pre><code>useEffect(() =&gt; { const popularMoviesData = localStorage.getItem(&quot;popularMovies&quot;); if (popularMoviesData !== null) { setPopularMovies(JSON.parse(popularMoviesData)); } }, []); useEffect(() =&gt; { localStorage.setItem(&quot;popularMovies&quot;, JSON.stringify(popularMovies)); }, [popularMovies]); </code></pre>
[ { "answer_id": 74241971, "author": "user1234", "author_id": 20326824, "author_profile": "https://Stackoverflow.com/users/20326824", "pm_score": -1, "selected": false, "text": "build.bat\n gcc %1.c -o %1.exe\n %1.exe\n" }, { "answer_id": 74242446, "author": "John Bode", ...
2022/10/29
[ "https://Stackoverflow.com/questions/74241965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9323736/" ]
74,241,994
<p>So i have basically used the intl-tel-input plugin in my registration form. My webapp is in django. But whenever i submit the form, i get an error which is like the phone_number field is required, even though i have filled in the number. Seems like the form isn't saving the phone number data. How can i solve this?</p> <p>form temlplate looks like this:</p> <pre><code>{% load static %} {% load crispy_forms_tags %} &lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot; dir=&quot;ltr&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;/static/css/register.css&quot;&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css&quot;/&gt; &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js&quot;&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; &lt;/head&gt; &lt;body&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;title&quot;&gt;REGISTER &lt;/div&gt; &lt;div class=&quot;content&quot;&gt; &lt;form action=&quot;#&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt; {% csrf_token %} &lt;div class=&quot;user-details&quot;&gt; &lt;div class=&quot;input-box&quot;&gt; {{form.name|as_crispy_field}} &lt;/div&gt; &lt;div class=&quot;input-box&quot;&gt; {{form.email|as_crispy_field}} &lt;/div&gt; &lt;div class=&quot;input-box&quot;&gt; &lt;span class=&quot;details&quot;&gt;Phone number&lt;/span&gt; &lt;input id=&quot;phone&quot; type=&quot;tel&quot; name=&quot;phone&quot; /&gt; &lt;/div&gt; &lt;div class=&quot;input-box&quot;&gt; {{form.address|as_crispy_field}} &lt;/div&gt; &lt;div class=&quot;input-box&quot;&gt; {{form.nin|as_crispy_field}} &lt;/div&gt; &lt;div class=&quot;input-box&quot;&gt; {{form.LC1_letter|as_crispy_field}} &lt;/div&gt; &lt;div class=&quot;input-box&quot;&gt; {{form.National_Id|as_crispy_field}} &lt;/div&gt; &lt;div class=&quot;input-box&quot;&gt; {{form.password1|as_crispy_field}} &lt;/div&gt; &lt;div class=&quot;input-box&quot;&gt; {{form.password2|as_crispy_field}} &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;form-check d-flex justify-content-center mb-5&quot;&gt; &lt;input class=&quot;form-check-input me-2&quot; type=&quot;checkbox&quot; value=&quot;&quot; id=&quot;form2Example3c&quot; /&gt; &lt;label class=&quot;form-check-label&quot; for=&quot;form2Example3&quot;&gt; First agree with all statements in &lt;a href=&quot;#!&quot;&gt;Terms of service&lt;/a&gt; to continue &lt;/label&gt; &lt;/div&gt; &lt;div class=&quot;button&quot;&gt; &lt;input type=&quot;submit&quot; value=&quot;Register&quot; href=&quot;#&quot;&gt; &lt;input type=&quot;submit&quot; value=&quot;Login&quot; style=&quot;margin-left: 200px;&quot;&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;script&gt; const phoneInputField = document.querySelector(&quot;#phone&quot;); const phoneInput = window.intlTelInput(phoneInputField, { onlyCountries: ['ug'], utilsScript: &quot;https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js&quot;, }); const info = document.querySelector(&quot;.alert-info&quot;); function process(event) { event.preventDefault(); const phoneNumber = phoneInput.getNumber(); info.style.display = &quot;&quot;; info.innerHTML = `Phone number in E.164 format: &lt;strong&gt;${phoneNumber}&lt;/strong&gt;`; } &lt;/script&gt; &lt;/html&gt; </code></pre> <p>forms.py:</p> <pre><code>from django import forms from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import AbstractBaseUser from .models import * from django.core.exceptions import ValidationError class RegForm(UserCreationForm): name = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'username'})) email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'Enter your name', 'id':'email', 'name':'email'})) address = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Enter your District, Subcounty, Village' ,'id':&quot;location&quot;})) nin = forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Enter your NIN', 'id':&quot;NIN&quot;,'name':&quot;nin&quot;})) LC1_letter = forms.FileField(widget=forms.FileInput(attrs={'name':'upload'})) National_Id = forms.FileField(widget=forms.FileInput()) def __init__(self, *args, **kwargs): super(RegForm, self).__init__(*args, **kwargs) for fieldname in ['LC1_letter', 'nin','password1', 'password2']: self.fields[fieldname].help_text = None class Meta: model = Account fields = ['email', 'name', 'address', 'phone_number', 'LC1_letter', 'nin', 'National_Id', 'password1', 'password2'] </code></pre> <p>and views.py:</p> <pre><code>from django.shortcuts import render, redirect from django.contrib.auth.forms import UserCreationForm from accounts.forms import RegForm from django.contrib.auth import login, authenticate from .models import * from django.contrib import messages from django.core.files.storage import FileSystemStorage # Create your views here. def register(request): if request.method == &quot;POST&quot;: form = RegForm(request.POST, request.FILES) if form.is_valid(): upload = request.FILES['upload'] fss = FileSystemStorage() file = fss.save(upload.name, upload) file_url = fss.url(file) form.save() return render(request,'main_app/base.html', {'file_url': file_url}) else: print('Form is not valid') print(form.errors) else: form = RegForm() return render(request, 'accounts/register.html', {'form': form}) </code></pre>
[ { "answer_id": 74241971, "author": "user1234", "author_id": 20326824, "author_profile": "https://Stackoverflow.com/users/20326824", "pm_score": -1, "selected": false, "text": "build.bat\n gcc %1.c -o %1.exe\n %1.exe\n" }, { "answer_id": 74242446, "author": "John Bode", ...
2022/10/29
[ "https://Stackoverflow.com/questions/74241994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18548015/" ]
74,241,995
<p>I have an AJAX function in my JavaScript like so</p> <pre><code>function getWeather(countryName) { const monthNames = [&quot;January&quot;, &quot;February&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;, &quot;June&quot;, &quot;July&quot;, &quot;August&quot;, &quot;September&quot;, &quot;October&quot;, &quot;November&quot;, &quot;December&quot; ]; let dateObj = new Date(); let month = monthNames[dateObj.getUTCMonth()]; let day = dateObj.getUTCDate() - 1; let year = dateObj.getUTCFullYear(); let newDate = `${month} ${day}, ${year}`; $.ajax({ url: &quot;assets/geojson/countryBorders.geo.json&quot;, type: &quot;GET&quot;, dataType: &quot;json&quot;, data: { }, success: function(result) { .... etc </code></pre> <p>Within my HTML modal for displaying the weather per country, I would like to include things such as the date.</p> <p>Is there any way to use the Javascript variable <code>newDate</code> in the HTML script?</p> <p>something like ....?</p> <pre><code> &lt;div class=&quot;modal-body&quot;&gt; &lt;h6 id=&quot;capitalCity&quot; class=&quot;modal-sub-header&quot;&gt;&lt;/h6&gt; &lt;hr&gt; &lt;ul class=&quot;dem&quot;&gt; &lt;p class=&quot;date&quot; id=&quot;newDate&quot;&gt;&lt;/p&gt; </code></pre>
[ { "answer_id": 74242018, "author": "Franco Agustín Torres", "author_id": 20318366, "author_profile": "https://Stackoverflow.com/users/20318366", "pm_score": 1, "selected": false, "text": "document.getElementById('newData').textContent = 'the value'\n" }, { "answer_id": 74242037, ...
2022/10/29
[ "https://Stackoverflow.com/questions/74241995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14274764/" ]
74,242,053
<p>I'm combining 12 CSV files into one dataframe in R. Before doing this I want to ensure all the column names are an exact match with each other. I've made a dataframe where each column is the column names of the 12 CSV files.</p> <pre><code>jul21_cols &lt;- data.frame(colnames(jul21)) aug21_cols &lt;- data.frame(colnames(aug21)) sep21_cols &lt;- data.frame(colnames(sep21)) oct21_cols &lt;- data.frame(colnames(oct21)) nov21_cols &lt;- data.frame(colnames(nov21)) dec21_cols &lt;- data.frame(colnames(dec21)) jan22_cols &lt;- data.frame(colnames(jan22)) feb22_cols &lt;- data.frame(colnames(feb22)) mar22_cols &lt;- data.frame(colnames(mar22)) apr22_cols &lt;- data.frame(colnames(apr22)) may22_cols &lt;- data.frame(colnames(may22)) jun22_cols &lt;- data.frame(colnames(jun22)) col_df &lt;- cbind(jul21_cols,aug21_cols,sep21_cols,oct21_cols,nov21_cols,dec21_cols, jan22_cols,feb22_cols,mar22_cols,apr22_cols,may22_cols,jun22_cols) </code></pre> <p>I've tried using the identical function to compare 2 columns at a time.</p> <pre><code>identical(col_df[['jul21']], col_df[['aug21']]) identical(col_df[['aug21']], col_df[['sep21']]) identical(col_df[['sep21']], col_df[['oct21']]) identical(col_df[['oct21']], col_df[['nov21']]) identical(col_df[['nov21']], col_df[['dec21']]) identical(col_df[['dec21']], col_df[['jan22']]) identical(col_df[['jan22']], col_df[['feb22']]) identical(col_df[['feb22']], col_df[['mar22']]) identical(col_df[['mar22']], col_df[['apr22']]) identical(col_df[['apr22']], col_df[['may22']]) identical(col_df[['may22']], col_df[['jun22']])` </code></pre> <p>All of the identical lines return the value of TRUE</p> <p>I'm just trying to verify that this code is telling me all my column names are identical in each CSV files before I move on. I'd also like to know if there is a more efficient way to solve this problem.</p>
[ { "answer_id": 74242306, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 2, "selected": true, "text": "identical()" }, { "answer_id": 74244767, "author": "G. Grothendieck", "author_id": 516548, "aut...
2022/10/29
[ "https://Stackoverflow.com/questions/74242053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16215972/" ]
74,242,067
<p>I am trying to split a string in multiple lines. Here is an example of the string:</p> <pre><code>Here the line that have to be under 120 chars and cut at the point in the string where the last word is under 120 chars because this part have to be in the second line and it also needs to be seperated such as the string part before and this has to be in the third line with the end of the string </code></pre> <p>It has to be split like this:</p> <pre><code>Here the line that have to be under 120 chars and cut at the point in the string where the last word is under 120 chars because this part have to be in the second line and it also needs to be seperated such as the string part before and this has to be in the third line with the end of the string </code></pre> <p>I'm trying to split the string at the length of 120 chars but if a word is about to be cut it should use the last word before that limit und put the last word in the next line and calculate how the rest have to treated the same way if the text is any longer than 2 lines.</p> <p>Also there is a part in the string that have to stay in one line at the end.</p> <p>How do i do this dynamically? I tried some solutions like <code>string[0:120]</code>, <code>string.splitlines()</code> and <code>wrap</code>. Maybe like putting it in a list and loop through it but how to build this splitting logic?</p> <p>Is there maybe a built-in solution for this?</p>
[ { "answer_id": 74242306, "author": "zephryl", "author_id": 17303805, "author_profile": "https://Stackoverflow.com/users/17303805", "pm_score": 2, "selected": true, "text": "identical()" }, { "answer_id": 74244767, "author": "G. Grothendieck", "author_id": 516548, "aut...
2022/10/29
[ "https://Stackoverflow.com/questions/74242067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19333009/" ]
74,242,074
<p>I have this array of objects:</p> <pre><code>let a = [{ fecha: '2022-10-28', txt: 'some text', },{ fecha: '2022-10-26', txt: 'some text', },{ fecha: '2022-10-27', txt: 'some text', }] </code></pre> <p>If I try this, it returns the array untouched:</p> <pre><code>a.sort((c,d) =&gt; c.fecha &gt; d.fecha) </code></pre> <p>Even though, this test throws a boolean:</p> <pre><code>a[0].fecha &gt; a[1].fecha // true </code></pre> <p>I don't understand.</p>
[ { "answer_id": 74242131, "author": "Nick", "author_id": 9473764, "author_profile": "https://Stackoverflow.com/users/9473764", "pm_score": 3, "selected": true, "text": "localeCompare" }, { "answer_id": 74242144, "author": "Jackson Quintero", "author_id": 9984878, "auth...
2022/10/29
[ "https://Stackoverflow.com/questions/74242074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4123670/" ]
74,242,112
<p>I have two arrays. One with 10 Indexes, One with 2 Indexes.</p> <p>I want to check if the large array has the exact values of the small array.</p> <p>There is a total of 9 comparisons that need to be made.</p> <p>How do I calculate this value for arrays of different sizes?</p> <p>I need this value to manipulate control flow.</p> <pre><code>largeArr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] smallArr = [9, 10] </code></pre> <p>On the 9th Comparison it will be true.</p>
[ { "answer_id": 74242133, "author": "craigb", "author_id": 20236884, "author_profile": "https://Stackoverflow.com/users/20236884", "pm_score": 2, "selected": true, "text": "len(largeArr) - len(smallArr) + 1" }, { "answer_id": 74242322, "author": "Dario", "author_id": 12628...
2022/10/29
[ "https://Stackoverflow.com/questions/74242112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20180626/" ]
74,242,119
<p>I have a tableview with this awkward gap between the top of the first section and the nav bar. I tried the following solutions I found online to hide the section but none seem to be working here:</p> <pre><code>tableView.tableHeaderView?.frame = CGRect.zero </code></pre> <p>also tried adding</p> <pre><code>func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -&gt; String? { return nil } </code></pre> <p>Neither seem to work. Any suggestions?</p> <p><a href="https://i.stack.imgur.com/9hyPX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9hyPX.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74242133, "author": "craigb", "author_id": 20236884, "author_profile": "https://Stackoverflow.com/users/20236884", "pm_score": 2, "selected": true, "text": "len(largeArr) - len(smallArr) + 1" }, { "answer_id": 74242322, "author": "Dario", "author_id": 12628...
2022/10/29
[ "https://Stackoverflow.com/questions/74242119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1925859/" ]
74,242,148
<p>Say I have a list of N members:</p> <pre><code>const list = [0, 1, 2, ...(N-1)]; </code></pre> <p>I want to do (N choose X), mathematically, so I need to create a function:</p> <pre><code>const findAllCombinations = (x, list) =&gt; { // return all x combinations of the list }; </code></pre> <p>if X were 2, I could do this:</p> <pre><code>const findAllCombinations = (x, list) =&gt; { for(let i = 0; i &lt; list.length; i++){ for(let j = i+1; j &lt; list.length; j++){ // N choose 2 } } }; </code></pre> <p>but not certain off-hand how to loop in a way to capture N choose X, it would be nice to do this <em>iteratively</em> instead of <em>recursively</em> if possible! But a recursive solution would be just fine.</p> <p>Here is my attempt, but it's wrong:</p> <pre><code> const combine = (x, list) =&gt; { // Note: N = list.length if(list.length &lt; x){ throw new Error('not enough elements to combine.'); } if (x &lt; 1) { return []; } const ret = []; for(let v of combine(x-1, list.slice(1))){ ret.push([list[0], ...v]); } return ret; } console.log( combine(3, ['a','b,'c','d']) ) </code></pre> <p>the goal would be to get these 4 combinations:</p> <pre><code>[a,b,c] [a,b,d] [a,c,d] [b,c,d] </code></pre> <p>..because <code>(4 choose 3) = 4</code>.</p> <p>Here is my desired output:</p> <pre><code>combine(0,[1,2,3]) =&gt; [[]] // as N choose 0 = 1 combine(1,[1,2,3]) =&gt; [[1],[2],[3]] // as N choose 1 = N combine(2,[1,2,3]) =&gt; [[1,2],[1,3],[2,3]]]] // as N choose N-1 = N combine(3,[1,2,3]) =&gt; [[1,2,3]] // as N choose N = 1 </code></pre> <p>to see a better list of desired output, see: <a href="https://gist.github.com/ORESoftware/941eabac77cd268c826d9e17ae4886fa" rel="nofollow noreferrer">https://gist.github.com/ORESoftware/941eabac77cd268c826d9e17ae4886fa</a></p>
[ { "answer_id": 74242484, "author": "qrsngky", "author_id": 4225384, "author_profile": "https://Stackoverflow.com/users/4225384", "pm_score": 0, "selected": false, "text": "itertools.combinations" }, { "answer_id": 74246107, "author": "EricLavault", "author_id": 2529954, ...
2022/10/29
[ "https://Stackoverflow.com/questions/74242148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1223975/" ]
74,242,155
<p>I have used the yq command to format a yaml file:</p> <p><strong>cat includelist.yml |yq -r '.ProductLine.ADO_FeedsList'</strong></p> <p>output:</p> <pre><code>--- ProductLine: ProductLineName: AAAAA ADO_FeedsList: - ProjectName: IT FeedsName: - test - test2 - ProjectName: organization FeedsName: - hello - world --- ProductLine: ProductLineName: BBBBB ADO_FeedsList: - ProjectName: Fin FeedsName: - good - aaaa - ProjectName: organization FeedsName: - bbb - ccc </code></pre> <p>Could somebody give me some suggestion,I don't known how to convert to csv format.</p> <p>My question: how to convert the content to the following format:</p> <p>IT,test</p> <p>IT,test2</p> <p>orginazation,hello</p> <p>orginazation,world</p> <p>Fin,good</p> <p>Fin,aaaa</p> <p>organization,bbb</p> <p>organization,ccc</p> <hr /> <p>Thanks a ton.</p>
[ { "answer_id": 74242621, "author": "Clair", "author_id": 19623474, "author_profile": "https://Stackoverflow.com/users/19623474", "pm_score": 1, "selected": false, "text": "yq eval -o json includelist.yml | \\\n jq -r '.ProductLine.ADO_FeedsList[]|\"\\(.ProjectName),\\(.FeedsName[])\"'...
2022/10/29
[ "https://Stackoverflow.com/questions/74242155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19623474/" ]
74,242,171
<p>I have 2 tables</p> <p>Table 1</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Customer</th> <th>Date_last_transacted</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>2021-08-06</td> </tr> <tr> <td>B</td> <td>2007-09-02</td> </tr> </tbody> </table> </div> <p>Table 2</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Customer</th> <th>Transactionid</th> <th>TransactionDate</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>123</td> <td>2021-08-06</td> </tr> <tr> <td>B</td> <td>234</td> <td>2007-09-02</td> </tr> <tr> <td>A</td> <td>356</td> <td>2014-09-09</td> </tr> <tr> <td>B</td> <td>456</td> <td>2003-08-03</td> </tr> <tr> <td>A</td> <td>4567</td> <td>2017-08-23</td> </tr> <tr> <td>A</td> <td>2244</td> <td>2021-08-07</td> </tr> <tr> <td>A</td> <td>45678</td> <td>2021-07-21</td> </tr> </tbody> </table> </div> <p>Table 1 is derived from table2 using max(transactionDate)</p> <p>I want to select all rows in table 2 that are 24 months before date_last_transacted for that particular customer.</p> <p>So, the result I want to get from table 2 is: Table 2</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Customer</th> <th>Transactionid</th> <th>TransactionDate</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>123</td> <td>2021-08-06</td> </tr> <tr> <td>B</td> <td>234</td> <td>2007-09-02</td> </tr> <tr> <td>A</td> <td>2244</td> <td>2021-08-07</td> </tr> <tr> <td>A</td> <td>45678</td> <td>2021-07-21</td> </tr> </tbody> </table> </div> <p>Can you please help with the code?</p>
[ { "answer_id": 74242282, "author": "ahmed", "author_id": 12705912, "author_profile": "https://Stackoverflow.com/users/12705912", "pm_score": 2, "selected": true, "text": "SELECT T.Customer, T.Transactionid, T.TransactionDate\nFROM Table2 T\nJOIN\n(\n SELECT Customer, MAX(TransactionDate...
2022/10/29
[ "https://Stackoverflow.com/questions/74242171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16415656/" ]