input_text_instruct
stringlengths
288
45.8k
output_text
stringlengths
37
33.2k
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Loop function to rename dataframes<p>I am new to coding and currently i want to create individual dataframes from each excel tab. It works out so far by doin...
<p>You need to create variables which correspond to the three dataframes:</p> <pre><code>alpha = d['alpha'] beta = d['beta'] charlie = d['charlie'] </code></pre> <p>or more succinctly:</p> <pre><code>alpha, beta, charlie = d.values() </code></pre> <p>Edit:</p> <p>Since you mentioned that the excel sheet could have 50+ ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to replace/delete comments or lines starts with particular word in Android studio?<p>I want to delete all comments in an android project, all the comment...
<p><strong>Note:</strong> I'm answering myself I figure it out</p> <p>In android studio, right-click on the project and select Replace in files, a new window pop up</p> <p>1 in the first search field tape in this <code>^\s+//.*$</code></p> <p>2 in the second search field, keep it empty if you just want to delete all th...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Return True when subsequent array values match<p>I need to identify specific array values with subsequent matching values. In this example, I'd like to know ...
<p>Why not just a list comprehension?</p> <pre><code>[i &lt; len(arr) - 2 and x == 'B' and arr[i+1:i+3] == ['B', 'B'] for i, x in enumerate(arr)] </code></pre> <p>Result:</p> <pre><code>[False, False, True, False, False, False] </code></pre> <p>We first test to ensure there <em>can be</em> two following values, then wh...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to parse string in PHP?<p>I get string from server:</p> <pre><code>auto status simple.cars OK simple.moto OK authorize.cars O...
<p>Here is one way to build a map containing keys and their OK/FAIL values:</p> <pre class="lang-php prettyprint-override"><code>$input = &quot;auto status\n simple.cars OK\n simple.moto OK\n authorize.cars OK\n authorize.moto OK&quot;; preg_match_all(&quot;/(\S+)\s+(OK|FAIL)/&quot;, $...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can we query array field with size less than some specific value in mongodb using springboot?<p>My objective is to query the array fields who have size l...
<p>You are not using annotations.</p> <pre><code>{$expr:{$lt:[{$size:&quot;$MainArray&quot;}, 5]}} </code></pre> <p>You need to use <code>$expr</code> to use operators in simple find.</p> <p>Equivalent in <code>BasicDBObject</code> is</p> <pre><code>new BasicDBObject(&quot;$expr&quot;, new BasicDBObject(&quot;$...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: typescript strict mode dynamically access different properties of different objects<p>I have the following code:</p> <pre class="lang-js prettyprint-override...
<p>As you noted, the problem is that the compiler only sees that the types of <code>HIERARCHY[obj.type]</code> and <code>obj</code> are both <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types" rel="nofollow noreferrer">union types</a>, but it doesn't have a way to represent the fact...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Is this correct implementation of pipelining in StackExchange.Redis in .NET?<p>I'm trying to increase performance of reading hashes from Redis and I've tried...
<p>StackExchange.Redis will automatically pipeline everything for you if you use the async API and an array of tasks. You will also want to make sure in the case of Hashes that you take advantage of the variadicity of the HSET/HMGET command to decrease the number of raw commands you need to issue to Redis.</p> <p>I'm n...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Find elements missing from 2nd list from first list, and add them into 2nd list<p>I have two list of list and I want to check what element of l1 is not in l2...
<p>This should work:</p> <pre><code>l1 = [[1,2,3],[5,6],[7,8,9,10]] l2 = [[1,8,10],[3,9],[5,6]] l1n = set([x for xs in l1 for x in xs]) l2n = set([x for xs in l2 for x in xs]) l2.append(list(l1n - l2n)) </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Make specific letters in another color<p>I got a text and behind the text is an SVG Blob. I want the Letters in front of the blob to be another color. Is thi...
<p>Is this what you are asking for ?</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>.invert-bg{ width: 100%; height: 100%; filter: invert(1); } .circle{ width: 200px; height...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do I pseudo-color a grayscale image in Matlab using custom RGB values from .csv file<p>I have an 8-bit image ('Example_image.tif') that I would like to p...
<p>Try to do:</p> <pre><code>cmap=csvread('pseudocolor_sheet.csv'); imshow(ExampleImage ,cmap); </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: What is the difference between SonarQube and Checkmarx CxSAST & CxSCA?<p>I have integrated SonarQube and Checkmarx SAST and SCA into the Azure DevOps build p...
<p>If I were to boil it down to a short phrase, SonarQube is used for ensuring code quality, and CheckMarx is used for ensuring the security of a system running that code.</p> <p>SonarQube looks at several areas, including the code coverage percentage of unit tests of the code, duplication percentages, and also code qu...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Getting invalid_client error when trying to revoke an access token in Spring Authorization Server<p>I am using <strong>Spring Authorization Server 0.3.1</str...
<p>Managed to solve the problem. It happened because I had <strong>oauth2ResourceServer()</strong> in the authorization filter chain settings (to enable userInfo endpoint) and sent a Bearer token in the header of /oauth2/revoke call:</p> <pre><code>@Bean @Order(2) @SuppressWarnings(&quot;unused&quot;) public SecurityFi...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Write multiple lists to different columns in a single cell in CSV<p>I have multiple lists and I want to write all those lists under different column names; t...
<p>Another version, pass <code>columns=</code> parameter and list of rows into a DataFrame constructor:</p> <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame([[list1, list2, list3]], columns=columns) print(df) </code></pre> <p>Prints:</p> <pre class="lang-none prettyprint-override"><code> c1...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: EEException: Image.visualize: Parameter 'image' is required<p>Im trying to use planet labs skysat ortho rgb high res satellite to give me an overlayed raster...
<p>The date interval appears to be the issue, as there are no images available.</p> <p>I made a few changes in order to run your code:</p> <pre><code>lc = ee.ImageCollection('SKYSAT/GEN-A/PUBLIC/ORTHO/MULTISPECTRAL').filterDate(i_date,i_date2) i_date = '2014-01-01' i_date2 = '2014-12-01' lc_img = lc.first().select(['N'...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: many to many relationship knex js<p>I am trying to fetch data from the database in this way: I want all the templates and those templates have an array of ca...
<p>You are not waiting for the promises to resolve. You should do:</p> <pre><code>await Promise.all(template.map(yourFunction)) </code></pre> <p>instead of</p> <pre><code>template.forEach(yourFunction) </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to delete records in a different model in Odoo<p>I have added a Boolean attribute to res_config_settings. When the Boolean is False I want to delete all ...
<p>Depends on two special factors: security and active mechanism. To really delete everything use <code>sudo()</code> to act as superuser and <code>.with_context(active_test=False)</code> to also find inactive records.</p> <p>Example:</p> <pre class="lang-py prettyprint-override"><code>self.env['my.device'].sudo().with...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to exit QApplication from another thread?<p>So the problem is that in any application sometimes the GUI might freeze. Regardless of why it has happened, ...
<p>Do you want a hard or a graceful exit? For a super hard exit, that can't be blocked by shutdown handlers (destructors, functions registered with <code>atexit</code>) use the C standard function <code>abort</code>: <a href="https://en.cppreference.com/w/cpp/utility/program/abort" rel="nofollow noreferrer">https://en....
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to do yearly comparison in spark scala<p>I have dataframe which contains columns like <strong>Month</strong> and <strong>Qty</strong> as you can see in b...
<pre><code>import org.apache.spark.sql.SparkSession import org.apache.spark.sql.functions.{col, sum} import spark.implicits._ val df1 = Seq( (&quot;2021-01&quot;, &quot;orange&quot;, 5223), (&quot;2021-02&quot;, &quot;orange&quot;, 23), (&quot;2022-01&quot;, &quot;orange&quot;, 2342), (&quot;2022-02&quot;, &qu...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Is ftp connection to secure server in c++ program secure with libcurl?<p>Is ftp connection to secure server in c++ program secure with libcurl?I need to make...
<p>FTP is insecure, it transfers data, user names &amp; passwords in the clear. Don't use it. Use either https, scp or sftp.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why does Object.assign numbers my array of objects after copying a JSON data file?<p>I have a json file that I need to copy to my local object. I need to use...
<p>I'm not sure why you need <code>new Object()</code> or <code>Object.assign</code>, but this uses both of those:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const MyData ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: getInitialProps function in document.js run on server or client?<p><code>getInitialProps</code> function run just in servser or client or both ?</p> <pre><co...
<p><a href="https://github.com/vercel/next.js/discussions/11211#discussioncomment-1692" rel="nofollow noreferrer">https://github.com/vercel/next.js/discussions/11211#discussioncomment-1692</a></p> <blockquote> <p>If I use getInitialProps will the list of books be outdated to what was the list at the time I ran npm run ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: pivot dataframe such that unique column names become headers and unique references become index (sparse matrix)<p>given the dataframe as follows:</p> <pre><c...
<pre><code>df.pivot_table(index='reference', columns='name', values='value', aggfunc='sum') </code></pre> <p>Output:</p> <pre><code>name name_1 name_2 reference ab1234 0.10 0.03 ab4567 NaN 0.10 cd1111 0.20 NaN cd1112 0.01 NaN </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to slice every element of array in React<p>I have an array of elements: [AdsAyush, AdsFace, AdsKicks, AdsMac] I want to slice every element of this array...
<p>You can use the function <code>Array.prototype.map</code> as follows.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>const array = ["AdsAyush", "AdsFace", "AdsKicks", "AdsM...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Looking for an explanation of this attempted SQL injection query<p>Looking through my logs I found the following query string as an attempt to perform a SQL ...
<p>I don't know what the point of this is, nor what the point is of trying to figure out the point. Injections are easier to block than to reverse engineer, and the latter doesn't contribute much to the former.</p> <p>The point of the + and the /**/ are probably pretty much the same, they separate tokens without the u...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I read an *.rtf file?<p>I have a large *.rtf file with meteorological data. When I open it using LibreOffice I get the data in the following format:<...
<p>This appears to be JSON, so we can use <code>jsonlite</code>. Taking that and storing it in an object,</p> <pre class="lang-r prettyprint-override"><code>chr &lt;- '[ { &quot;fecha&quot; : &quot;2022-01-01&quot;, &quot;indicativo&quot; : &quot;0016A&quot;, &quot;nombre&quot; : &quot;REUS AEROPUERTO&quot;, &q...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: sh: 1: tailwindcss: Permission denied // error on build process Tailwindcss CLI<p>I have installed nodejs version: <code>v18.2.0</code>,</p> <p>and while i a...
<p>Had the same problem again after a new installation of ubuntu and for me worked now this solution:</p> <pre><code>npm rebuild </code></pre> <p>source: <a href="https://stackoverflow.com/questions/54831494/sh-1-cross-env-permission-denied-on-laravel-mix">sh: 1: cross-env: Permission denied on laravel mix</a></p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Google script to create calendar event for selected multiple rows<p>I tried to put together a script which would create calendar events only for the check ma...
<p>I would do it like this:</p> <pre><code>function createThickEvents() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const sh = ss.getSheetByName(&quot;formhelper&quot;); const vs = sh.getRange(&quot;A1&quot;).getDataRegion().getValues(); const cal1 = &quot;calendarID&quot;; const cal2 = &quot;calendar...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to rearrange table td<p>I have this problem, is there a way to change the order of the td and th with &quot;testing&quot; class such that it will be the ...
<p>Here is an example using flex and the css order property. I used the hover property because it's easier to test than resizing the snippet, but you could change the style from a hover to a media query and check the screen size.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babe...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to evaluate two enum members with same value as not equal in C#?<p>I have this enum instance</p> <pre><code>public enum MyEnum {A1 = 0, A2 = 0} </code></...
<p>I found an easy work around that is most suffiecient for my problem.</p> <p>That is to simply use modulo to allow all members in <code>MyEnum</code> to have different values while still evaluate to the same value.</p> <p>This method also made it very easy to add enum members to <code>MyEnum</code> and without taking...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: python selenium how to get hover element information<p>I need to get information from this <a href="https://kalstall.de/" rel="nofollow noreferrer">site</a> ...
<p>Just grab all the values in the element div with id tip after you hover using ActionChains.</p> <pre><code>values=[x.text for x in driver.find_elements(By.CSS_SELECTOR,&quot;div#tip a&quot;)] print(values) </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Check if true or false on json parse into html<p>Currently have all data displaying perfectly except the boolean ones. I have some data that if <code>true</c...
<p>You can use a ternary expression in the template literal.</p> <pre><code> out += ` &lt;div class=&quot;supporter&quot;&gt; &lt;h4 class=&quot;supporter__name&quot;&gt; &lt;span class=&quot;supporter__thumbnail&quot;&gt;&lt;/span&gt; ${supporter.name} ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Building a toggle switch widget using react js<p>I am trying to build a toggle widget. This is the code I am trying to execute. Here, I am facing one issue i...
<p>You no need to get value from <code>e.target.value</code> instead you can use callback to update state as:</p> <p><a href="https://codesandbox.io/s/sad-ishizaka-uu3kc6?file=/src/App.js" rel="nofollow noreferrer">codesandbox demo</a></p> <pre><code> handleChange(event) { const { booleanAttribute } = this.props; ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: View functions error : Returned values aren't valid, did it run Out of Gas?<p>I'm calling the methods in the deployed smart contracts in Ganache. Other metho...
<p>I had the same problem, and I was using Hardhat .</p> <p>after spending hours and not resolved, I switched Rinkeby test network, and everything goes well.</p> <p>refer to: <a href="https://ethereum.stackexchange.com/a/129721/30431">https://ethereum.stackexchange.com/a/129721/30431</a></p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Vertical order traversal of a binary tree: when nodes overlap<p>I am working on the LeetCode problem <a href="https://leetcode.com/problems/vertical-order-tr...
<p>In your final loop, you can just add a call to <code>sort</code> on the inner vector (that corresponds to a certain horizontal distance and certain level). It is in that vector you could get overlapping nodes.</p> <p>So:</p> <pre class="lang-cpp prettyprint-override"><code> for(auto i: nodes){ for...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: MySQL - Subtrack week from YearWeek column correctly<p>I have a calendar table in MySQL that maintains a column having YEARWEEK value (eg: 202230, 202301). W...
<p>You can get the date of a specific day, for example Sunday, of that yearweek value with <a href="https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_str-to-date" rel="nofollow noreferrer"><code>STR_TO_DATE()</code></a>:</p> <pre><code>STR_TO_DATE('202301 Sunday', '%X%V %W') </code></pre> <p...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: In Vaadin 14's Uploader, how do I clear the previously uploaded files?<p>In Vaadin 14, I've used Vaadin Designer to add an Uploader component. It works fine....
<p>Yes, use <code>upload.getElement().setPropertyJson(&quot;files&quot;, Json.createArray());</code> to clear the visual file representation on the client side. This was improved in V23 where you can just call <code>upload.clearFileList();</code></p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Vue - Using a list of object from data in a function on methods, to check if is equal with an input<p>So I am new in Vue and JS in general, and I am trying t...
<p><em><strong>Observations :</strong></em></p> <ul> <li><p>As <code>list</code> is an array of objects. You can't access the objects properties directly via <code>dot(.)</code> notation. You have to access those via <code>index</code>.</p> <pre><code>this.list.forEach(obj =&gt; { console.log(obj.user) }); </code></p...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Django query with conflicting fields returns duplicate answers<p>Query:</p> <pre class="lang-py prettyprint-override"><code>cameraSystems = DWCloudSystem.obj...
<p>Use a single filter condition and use <a href="https://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct" rel="nofollow noreferrer"><strong><code>.distinct(…)</code></strong> <sup>[Django-doc]</sup></a> to return distinct <code>DwCloudSystem</code>s:</p> <pre><code>from django.db.models import Q DWCloudS...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do I make text "bold" in email body in python?<p>How can I make text bold in the email body in python? I am using the following code to send mail :</p> <...
<p>According to <a href="https://docs.djangoproject.com/en/4.0/topics/email/#sending-alternative-content-types" rel="nofollow noreferrer">Django DOCS</a>, html should be added as separate file, so it could be read with or without html (depending on what receiver is using, not everyone want html in emails). You need <co...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Javascript: using a math function to control an output range according to an input range<p>If I know that a ratio of two input variables &quot;a/b&quot; has ...
<p>I'm not sure if there is an existing good algorithm for that, but from your description of the problem I can recommend doing something like that:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyp...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Unable to focus form element on modal open with react-hook-form<p>I'm trying to solve a problem that seems quite straight forward. I want to focus a form ele...
<p>Maybe setFocus can't run because the modal content (and the input inside) is first unmounted.</p> <p>An easy solution using setFocus is to make the form as an independant component :</p> <pre><code>const Form = () =&gt; { const { setFocus, register } = useForm(); useEffect(() =&gt; { setFocus(&quot;name&quo...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Laravel Mongodb Getting Data from the same collection but has different type<p>I am trying to make a VOD and Aduio Streaming platform and I am using Laravel ...
<p>Yes, it's possible using the <a href="https://laravel.com/docs/master/eloquent#query-scopes" rel="nofollow noreferrer">eloquent's query scope feature.</a></p> <p>As you mentioned, you already have a &quot;Media&quot; model from which you can access both Audio and Video.</p> <p>Now you want to create an &quot;Audio&q...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: VS Code takes several seconds to save a document in C++<p>This is my C/C++ configs in <code>/home/user/.config/Code/User/settings.json</code>:</p> <pre class...
<p>In vscode, i tried to disable all the extensions that i installed previously, i disabled them one by one, after each disable, i test by changing the code then saving, yet the problem persists, until all the extensions are off.</p> <p>Then i remembered there are some other built-in extensions. I opened the extensions...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Changing navigation bar's color in a latex beamer with Frankfurt theme<p>I would like to change the color of the black navigation bar, which is at the top of...
<p>You can change the background colour of the headline like this:</p> <pre><code>\documentclass{beamer} \usetheme{Frankfurt} \setbeamercolor{section in head/foot}{bg=red} \begin{document} \section{title} \begin{frame} \frametitle{title} abc \end{frame} \end{document} </code></pre> <p><a href="https://i.s...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Sumproduct in R using dplyr<p>Using dplyr, I´m trying to sumproduct in R two columns as it can be done in Excel but although I´ve tried several aproaches, no...
<pre class="lang-r prettyprint-override"><code>library(tidyverse) df %&gt;% group_by(dem_sect) %&gt;% filter(!duplicated(area, kg_med)) %&gt;% summarise(sumproduct = sum(area * kg_med)) %&gt;% as.data.frame() # to view the result with more significant digits #&gt; dem_sect sumproduct #&gt; 1 MF ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Jasmine spy callFake not being reached when trying spy on a service method that is called inside ngOnInit<p>I am trying to set up some unit tests for a compo...
<p>This solution solves my problem, but it still doesn't really <em>answer</em> my questions. So if anyone can shed some extra light on this, I'd be happy to mark their response as the accepted answer.</p> <p><strong>The unit test</strong></p> <p>It looks like the order with which I was calling <code>spyOn</code>, <cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Accuracy not increasing when running multiple LinearRegressions tests<p>I made a very simple program, that takes columns of data from a csv file, here is a s...
<p>You are not training the model any further by using your loop. You start fresh every 500 times, only difference is the random initialisation of you train-test split.</p> <p>As for improvements of your classifier, I would steer away from Linear Regression. Regression is not the same thing as classification. Classific...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: I'm trying to index an array of nodes (linked lists)<p>Node struct implementation:</p> <pre><code>typedef struct node{ int data; struct node* next; }...
<p>There are two major issues with this program. The first is that you have not initialized your list pointers. You allocate storage for them, but their actual values can be anything. Attempting to dereference such values will result in Undefined Behavior.</p> <p>You could <code>memset</code> after calling <code>malloc...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Find maximum id value in a deeply nested array of objects<p>I have an tree data structure with each object containing children:</p> <pre><code>const data = {...
<p>First, as to why your code is broken: You just missed an assignment. Where you have</p> <pre class="lang-js prettyprint-override"><code> newID( obj, idKey ); </code></pre> <p>you are ignoring the resulting value. You need to assign it back to <code>idKey</code>:</p> <pre class="lang-js prettyprint-override"><cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: UWP Delayed updates to Textbox using TraceListener<p>I have a tracelistener:</p> <pre><code>public class WindowTraceListener : System.Diagnostics.TraceListen...
<p>Found the answer here: <a href="https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/keep-the-ui-thread-responsive" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/keep-the-ui-thread-responsive</a></p> <p>My long running process was being invoked on the GUI thread:</p> ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to delete a column in a matrix in Julia?<p>If I had a matrix <code>M</code> such that <code>M = [0 1 2; 3 4 5; 6 7 8]</code>, how could I delete a specif...
<p>You can do it directly with array indexing,</p> <pre><code>julia&gt; M = [0 1 2; 3 4 5; 6 7 8]; julia&gt; M[:, 1:3 .≠ 2] 3×2 Matrix{Int64}: 0 2 3 5 6 8 </code></pre> <p>note that <code>≠</code> is written as <code>\neq</code> + <kbd>Tab</kbd> from keyboard.</p> <p>Or using packages like <a href="https://githu...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Import module from parent folder but still working in child directory<p>I'm relatively new to Python and I need to make a script which can call a function fr...
<p>The correct way of doing this is to run the script with the -m switch</p> <pre><code>python -m childDirectory.childScript # from the parent of childDirectory </code></pre> <p>Then in childScript you do a simple <code>from parentModule import runFunction</code>. Hacking the sys path is bad practice and using chdir sh...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: android studio kotlin notification body click<p>Not sure how to open MainActivity when the body of notification is clicked:</p> <pre><code>class Notification...
<p>You need to add <code>setContentIntent</code> with pending intent for the MainActivity:</p> <pre class="lang-kotlin prettyprint-override"><code>class Notification : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val activityIntent = Intent(context, MainActivity::clas...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to get indexes of elements in MatrixSymbol<p>i generate two matrices :</p> <p>y=MatrixSymbol('y', n, k)</p> <p>T=MatrixSymbol('T', n,k) , where</p> <p>n=...
<p>This is how you get those elements:</p> <pre class="lang-py prettyprint-override"><code>from sympy import * from sympy.matrices.expressions.matexpr import MatrixElement n=k=3 y=MatrixSymbol('y', n, k) T=MatrixSymbol('T', n,k) M1 = Matrix([[y[0, 2] + 11.0 * y[1, 2] - 12.0 * y[2, 2] + 195.0*exp(-100000/(5819.8 * T[1...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: python-script does not load libraries when invoked by cron<p>I have a python-script that uses matplotlib and pandas to load and plot some data. The <a href="...
<p>Silly me! <a href="https://linuxcommand.org/lc3_man_pages/sourceh.html" rel="nofollow noreferrer">source</a> just did the trick. Added <code>source /home/pi/.bashrc</code> to the bash-script and python does load it all as supposed.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: pytorch gives me an error when I don't run it in ~/ directory<p>When I run the following python script in an subdirectory, for example ~/test_dir, python res...
<p>It seems that you named your working directory and a script <code>torch</code>. It causes a conflict with the installed Pytorch library, therefore you're calling <em>your</em> <code>torch</code>, not the installed one.</p> <p>Try it after changing the names of your directory and script.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to create a vertical group of buttons in ImGui?<p>I have this ImGui menu:</p> <p><a href="https://i.stack.imgur.com/c94jy.png" rel="nofollow noreferrer">...
<p>I normally use <code>ImGui::SetCursorPos()</code> for this, as suggested by @thedemons. But there is also <code>ImGui::BeginGroup();</code>.</p> <p>Remove the last <code>ImGui::SameLine();</code> and wrap the two buttons in <code>Begin/EndGroup</code>. Here's a simplified example:</p> <pre><code>ImGui::Begin(&quot;W...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Name Services under started process in cmd<p>In windows 10 cmd, I started a process <code>C:\Windows\system32\svchost.exe -k RPCSS -p</code> successfully. Ho...
<p>You can try with <a href="/questions/tagged/wmic" class="post-tag" title="show questions tagged &#39;wmic&#39;" rel="tag">wmic</a> in cmd to get the commandline of the process :</p> <hr /> <pre><code>wmic process where &quot;name like 'svchost.exe' And CommandLine!=Null&quot; get commandline /Value </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Modifying e.range.getA1Notation() to accept wider range of inputs in Google Apps Script<p>I'm using a Google Apps script to update the active sheet's name wi...
<p>Try</p> <pre><code>function onEdit(e) { e.source.getActiveSheet().setName(e.source.getActiveSheet().getRange('C6').getValue()); } </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Calendar Ant Design: How to show events with variable dates?<p>I am looking for a way to show events in an Ant Desing Calendar using dateCellRender with the ...
<p>Since <code>antd</code> calendar works with <code>moment</code> object, so when you try to render the calendar, you can covert the value of current date to string by using <code>format</code> method of moment object like this:</p> <pre><code>&lt;Calendar dateCellRender={(value) =&gt; { const stringValue = value.fo...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Is there a way to tell which set a list item came from?<p>I currently have this working to where it outputs any changes made to the sitemap.</p> <p>What I wa...
<p>You can't tell which set a value came from when you use <code>oldPage ^ newPage</code>. Use subtraction to get each difference.</p> <pre><code>added = newPage - oldPage deleted = oldPage - newPage </code></pre> <p>Then when you're writing these to the CSV file, you can add a label to each row indicating which set it...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Removing duplicate entries whilst joining<div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>user</th> <th>learning_group</th> <th>progr...
<p>This should do the job:</p> <pre><code> SELECT count(distinct lgu.user_id) FROM learning_group_user lgu INNER JOIN learning_group_program lgp ON lgp.group_id = lgu.group_id WHERE lgp.program_id = :programId; </code></pre> <p>it will only count the distinct userIds, however, note possible performanc...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: form doesnt get submitted after disabling button after submit<p>Hello there i want my button disabled after the form submitted. Disabling the button works bu...
<p>If you want to disable the button <em>after</em> executing the php code, then you need to make it happen when the page reloads. Any JavaScript which runs during the &quot;submit&quot; event is happening <em>before</em> the request containing the form data is sent to the server for PHP to process it. And your current...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Angular 13 - Unable to update formGroup with data from API<p>I am trying to make a form to submit data, then populate that form with data in order to edit it...
<p>As Angular warns you, it's a bad practice to mix <code>Template driven form</code> and <code>Reactive form</code> this can lead to a lot of unwanted behaviours (you can get a lot of informations about Angular forms in the <a href="https://angular.io/guide/forms-overview" rel="nofollow noreferrer">official Angular do...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Skip a spec file on fail and still report it as failed on result<p>I am aiming to skip a spec files once an <code>it()</code> inside it <strong>fails</strong...
<p>The <code>afterEach()</code> is too early to call <code>Cypress.runner.stop()</code>, but it seems to work with <code>test:after:run</code>.</p> <pre class="lang-js prettyprint-override"><code>describe('test body', () =&gt; { Cypress.on('test:after:run', (result) =&gt; { if (result.currentRetry === result.ret...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Speedup web scraping with selenium<p>I am newbie to web scraping using selenium and I am scraping seetickets.us My scraper works as follows.</p> <ul> <li>sig...
<p>To speedup web scraping using <em>Selenium</em>:</p> <ul> <li>Remove <a href="https://stackoverflow.com/a/45674706/7429447">implicitwait()</a> totally.</li> <li>Induce <a href="https://stackoverflow.com/a/59130336/7429447">WebDriverWait</a> to synchronise the webdriver instance with the WebBrowser instance for eithe...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Trouble with Seeding data in ASP.NET Core 6<p>I am currently having problem while trying to seed my data in ASP.NET Core 6. After running the application, I ...
<p>I do some change based on your code. And I get the data in the database.</p> <p>Seller</p> <pre><code>public class Seller { public int SellerId { get; set; } public string SellerFirstName { get; set; } public string SellerLastName { get; set; } public string SellerEmail { get; ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why the same mongodb query behaves inconsistently between different client?<p>firstly, let's take this simple query as example:</p> <p><code>ObjectId('62663d...
<p>mongosh and MongoDB JDBC driver that is used in DataGrip have the same core so they should be very similar (and your examples show that. <code>{&quot;$oid&quot;: &quot;62663def4e578b0a1cb482c5&quot;}</code> is just json representation of ObjectId type).</p> <p>I don't remember what Navicat uses. I might guess that t...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Flutter TextField selection highlighter controls appear too high<p>Screenshot of the issue and code in use below, the selection controls are above the textfi...
<p>In answer to my own question, this in the TextField attributes did the job in my case:</p> <pre><code> decoration: InputDecoration( isDense: true, // important line contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5), border: InputBorder.none, ), </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Fonctionnement formulaire contrôlé react?<p>I have a problem with react. with a form, I created more inputs that are controlled. I created a function that ru...
<pre><code>setOutput({ [e.target.name]: e.target.value }); </code></pre> <p>This will not be merged with the old state, it will <em>replace</em> the old state. So if they change <code>lastName</code>, the new state will be <code>{ lastName: &quot;some string&quot; }</code>, and all other values will be undefined.</p> <...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Can't make Apache Airflow installation to work<p>I'm trying to run <code>airflow standalone</code> but im getting <code>AirflowConfigException( airflow.excep...
<p>Running Airflow on Windows is not yet supported unless you use something like WSL. See <a href="https://airflow.apache.org/docs/apache-airflow/stable/installation/prerequisites.html?highlight=windows" rel="nofollow noreferrer">here</a> and <a href="https://github.com/apache/airflow/issues/10388" rel="nofollow noref...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Difference between differents test-flags of go test<p>I am planning to run my Cucumber test in go (using Godog) &amp; I came up with the following possibilit...
<p>This is answered on the GO blog: <a href="https://go.dev/blog/cover#heat-maps" rel="nofollow noreferrer">https://go.dev/blog/cover#heat-maps</a>:</p> <blockquote> <ul> <li>set: did each statement run?</li> <li>count: how many times did each statement run?</li> <li>atomic: like count, but counts precisely in parallel...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: In PyQt5's QListWidget, how can I only show the tooltip for an item when the user chooses it?<p>I was inspired by this <a href="https://github.com/yjg30737/p...
<p>Expanding on the suggestion from <a href="https://stackoverflow.com/users/2001654/musicamante">musicamante</a> in the comments, I was able to get tooltip to display only for the selected item by overriding the event method and watch for a tooltip event (inspired from this SO <a href="https://stackoverflow.com/a/6305...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Add styling to translation string in i18n-js React Native<p>I use i18n-js for translation purposes in my React Native app. But I cannot get any styling like ...
<p>You can use syntax something like this</p> <p>Create 3 string in translation file. Example</p> <p>in translation files</p> <pre><code>str1: 'this is&quot; str2: 'bold' str3: 'copy' </code></pre> <p>Now you can do something like</p> <pre><code>&lt;&gt; &lt;Text&gt;{i18n.t(str1)}&lt;/Text&gt; &lt;Text className=&q...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Pygame error: TypeError: 'pygame.Surface' object is not subscriptable<p>guys! I am trying to create a chess game. The algorithm is ready, but I am struggling...
<p>You need to add the images to the <code>images</code> dictionary instead of assigning each <em>Surface</em> object to the variable <code>images</code>:</p> <pre class="lang-py prettyprint-override"><code>for piece in image_names: # instead of #images = p.transform.scale(p.image.load(piece + &quot;.png&quot;...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Separating the lists where after conversion all values are numbers<p>To separate only the lists that converted become all numbers, I do it like this:</p> <pr...
<p>Using a regex approach to validate the numerical format. Regex not best but should work for positive and negative integer or decimal and compatible with scientific notation.</p> <pre><code>import re a = ['start','nan','1.004569','0.8554','nan'] b = ['0.464','-5','4.8784','2.411474','0.44', '-1.23e-07'] c = ['start'...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to make a split screen with Bootstrap?<p>I have been trying very hard to make a split screen using Bootstrap. Here's what it looks like when I managed to...
<p>A few things, if you are using a library then take advantage of it, use its <a href="https://getbootstrap.com/docs/4.0/utilities/" rel="nofollow noreferrer">utility classes</a>, and learn its <a href="https://getbootstrap.com/docs/4.0/layout/grid/" rel="nofollow noreferrer">grid system</a>:</p> <ul> <li>Add <code>vh...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to access Elasticache and Internet in AWS Lambda?<p>I just wrote a python script that connect to the AWS ElastiCache. And it just check the connection.</...
<p>In a nutshell, this is what I did</p> <ol> <li>Follow <a href="https://youtu.be/JcRKdEP94jM" rel="nofollow noreferrer">AWS Knowledge Center Videos: How do I give internet access to my Lambda function in a VPC?</a> and created a Lambda function that would have internet access in the VPC</li> <li>Follow <a href="https...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: HTML table to array key issue<p>I currently have a function which creates an array from a html table the array output is</p> <pre><code>array:1 [ 0 =&gt; a...
<p>You'll have to push an object instead of an array since you want string keys.</p> <p>Since your input fields aren't named, I'm using my own array <code>let name = ...</code> to determine the key names based on the index number.</p> <pre><code>let convertedIntoArray = []; $(&quot;table#campaign_csv_table tr&quot;).ea...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: ini-parser add key in a for loop<p>hi can anyone please help me? im trying to add a some keys with ini-parser, but i only get the last index of the loop.</p>...
<p>One thing that could really help you debug is to go from DeviceInstance enumeration to <code>List&lt;KeyValuePair&lt;string, string&gt;&gt;</code>, and then in a separate loop use the list of pairs to update the INI file.</p> <pre><code>var devenum = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.Attac...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Type 'any View' cannot conform to 'View' on protocol with generics<p>I'm using a protocol to define an override to the default <code>View</code> protocol to ...
<p>If I understand correctly, you want a specialised version of the <code>View</code> protocol, where <code>Body</code> is <code>CalculationComponent&lt;some View&gt;</code>, and you don't want to write explicitly what &quot;<code>some View</code>&quot; is when conforming to the protocol, plus some other requirements.<...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Bootstrap: Horizontal Align H1 and dropdown button<p>I put a dropdown button beside an H1 tag and I want the dropdown button moved up just a bit because they...
<p>You can use Bootstrap's flexbox class and attributes to align items</p> <p><a href="https://getbootstrap.com/docs/5.0/utilities/flex/" rel="nofollow noreferrer">https://getbootstrap.com/docs/5.0/utilities/flex/</a></p> <p>In this case, I just did center but you can use whatever attribute that gives you the positioni...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to run window.stop after certain time in puppeteer<p>I want to web scrap a site but the problem with that site is this, content in the site load in 1s bu...
<p>Similar approach to Marcel's answer. The following will do the job:</p> <pre class="lang-js prettyprint-override"><code>page.goto(url) await page.waitForTimeout(1000) await page.evaluate(() =&gt; window.stop()) // your scraper script goes here await browser.close() </code></pre> <p>Notes:</p> <ul> <li><a href="https...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Use Parameters in Table in Search Query in Splunk<p>I have a saved table dataset in Splunk. When I choose to &quot;Investigate in Search&quot; this table dat...
<p>The <code>from</code> command does not support passing arguments. The <code>savedsearch</code> command does, however. You could save Sample2 as this saved search</p> <pre><code>index=&quot;my_index&quot; sourcetype=&quot;*&quot; earliest=$earliest_time$ latest=now | fields _time statusCode result | table _...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Replace the Field Values in a Column Using Condition in SQL<p>here's a sample table I am working with:</p> <blockquote> <pre><code>ID fruit first apl...
<pre><code>select id, case when fruit='apl' then 'apple' when fruit='bnna' then 'banana' else fruit end as fruit from your_table </code></pre> <p>in case you need to update the data</p> <pre><code>update your_table set fruit='apple' where fruit='appl'; update your_table set fruit='banana' where fruit='bnna'; <...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to transform elements of list into dict/tuple? Python<p>I need to transform this list:</p> <pre><code>[124, '-9.6713520', '-35.745578', 132, '-9.6713765'...
<p>If you make an iterator from your list, you can zip it with itself three times to iterate in triples:</p> <pre><code>l = [124, '-9.6713520', '-35.745578', 132, '-9.6713765', '-35.745620', 140, '-9.6712351', '-35.745561', 159, '-9.6712457', '-35.745545'] it = iter(l) [{'uc': k, 'location': (float(a), float(b))} f...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Best way to redirect user to login URL in WordPress?<p>I have numerous pages that require my users to be logged in when accessing them.</p> <p>I've remapped ...
<p>Here are 2 examples please check you can add on function.php file</p> <pre><code>add_action( 'admin_init', 'redirect_non_logged_users_to_specific_page' ); function redirect_non_logged_users_to_specific_page() { if ( !is_user_logged_in() &amp;&amp; is_page('add page slug or ID here') &amp;&amp; $_SERVER['PHP_SELF']...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to scrape a word from img, alt tag<pre><code>HTMLCode </code></pre> <p>&lt; div class=&quot;movieLogo&quot;</p> <p>img alt=&quot;1 Million&quot; src=&quo...
<p>Considering the lack of information, hard to give you a proper answer.</p> <p>If I understand you correctly, you're looking for the text &quot;<em>1 Million</em>&quot;, which is the text of the attribute &quot;<em>alt</em>&quot; and <strong>NOT</strong> from &quot;<em>@class=&quot;movieLogo</em>&quot;.</p> <p>So let...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Android - LiveData observe not getting update from AndroidViewModel in active Activity<p>I do see quite some questions about this issue but most of them are ...
<p>In the examples you linked (<a href="https://developer.android.com/topic/libraries/architecture/viewmodel" rel="nofollow noreferrer">here</a>) the <code>loadUsers()</code> method does not <em>return</em> the data, it calls some method to get it asynchronously, then posts it to the LiveData (but they don't show that ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: ActiveRecord migration - when reversible.up/reversible.down feature was introduced?<p>I'm currently in the process of upgrading old legacy Rails app and tryi...
<p><a href="https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md#rails-400-june-25-2013" rel="nofollow noreferrer">4.0.0</a> it was.</p> <blockquote> <p>New method <code>reversible</code> makes it possible to specify code to be run when migrating up or down. See the <a href="https://github.com/rails...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to select a random image from a folder for CNN test process?<p>I would like to ask if there is any way for my codes to select an image randomly from a fo...
<p>the code</p> <pre><code>os.listdir(&quot;drive/My Drive/HAZIQ/TESTTEST/MODELTEST/&quot;) </code></pre> <p>will return a file name but NOT the full path to the file and consequently it is not found. What you need to do is</p> <pre><code>sdir=r'drive/My Drive/HAZIQ/TESTTEST/MODELTEST/' flist=os.listdir(sdir) test_img=...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Deleting all Like shapes on active sheet not deleting all<p>I created this function to go through my current sheet and delete all shapes starting with &quot;...
<p>You need to count backwards when deleting shapes. If you, say, delete shape 1, then shape 2 then becomes the new shape 1 but the loop counter moves on to 2, bypassing that shape. So you can't use For Each, you have to use a plain old For but count by -1.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Cannot bind parameter 'headers' for command curl<p>I am trying to use curl command with following line below and encountering errors.</p> <pre><code>curl -H ...
<p>I can say you are using Microsoft Power shell utility.. which has different syntax. It is expecting a hash table type value for headers</p> <pre><code>@{&lt;name&gt; = &lt;value&gt;; [name = &lt;value&gt; ] ...} </code></pre> <p>If you really want it to be working in power shell, please go through power shell's I...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: GitLab oauth2 Laravel "{"message":"401 Unauthorized"}"<p>My gitLab controller. Links taken from the documentation. After submitting the form returns an error...
<p>Adding 'token_type' to the request headers helped me</p> <pre><code> $token = $response-&gt;json('access_token'); $tokenType = $response-&gt;json('token_type'); $response = Http::withHeaders(['Authorization' =&gt; $tokenType . ' ' . $token]) -&gt;get('https://gitlab.com/api/v4/user'); </code></pre> <p>The ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: for loop in recursive function python<p>I tried to use for loop in a recursive function to find all path that the child class related to its parents.</p> <pr...
<p>Try the following implementation using recursion:</p> <pre class="lang-py prettyprint-override"><code>class A: pass class B(A): pass class C(A): pass class F(A): pass class L(C,B): pass class D(B,F): pass class M(L,D): pass def bases(cls): if cls.__bases__ == (object, ): # if &quot;r...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to group on multiple fields including nested eager columns<p>I have some carts, products and users. I try to get statistics like number of carts per user...
<p>The issue is that <code>count()</code> counts the number of records returned <a href="https://www.w3schools.com/Sql/func_mysql_count.asp" rel="nofollow noreferrer">by your MySQL query</a>, so if you're looking at 20 rows all with the same <code>cart.id</code>, it's still going to count all 20 of them.</p> <p>You can...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Linux command piping in openssl to use string input<p>I have a shell script where a file path <code>$path</code> have some text which I encrypt as below and ...
<p>Correct answer below <code>content_sha256=&quot;$(echo $body | openssl dgst -binary -sha256 | openssl enc -e -base64)&quot;;</code></p> <p>Points to note:</p> <ol> <li>Include <code>-binary</code> option.</li> <li>Instead of redirection of file content as input, use <code>echo $body</code> with pipe .</li> </ol>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Need help handling incorrect parameters<p>I want to know how to deal when one of my routes is given an incorrect parameter. For example, in this <code>update...
<p>I would argue that validations are a model concern. It is best practice and encurreaged to use validators in the model layer, this is what they were built for.</p> <p>And IMHO setting proper <code>StrongParams</code> in the controller and using validations in the model fulfill the <em>&quot;The post_params should be...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to change the start position of svg image using animateMotion?<p>I am trying to change the start position of an svg image to animate it along a path usin...
<p>You can give the circle the desired cx and cy (<code>cx=&quot;6.25&quot; cy=&quot;100&quot;</code>) and <code>set</code> those attributes to o when the animation begins.</p> <p>Please read about the <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/set" rel="nofollow noreferrer">set element</a>.</p> ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Edit text when I open a window<p>I'm working with PYQt5 and Python. Whenever I open a new window and that window has a lineEdit, I have to clic in the lineEd...
<p>Thanks to musicamante the question was solved. I added the setFocus() like this.</p> <pre><code> def __init__(self): super(VentanaInicio,self).__init__() loadUi('D:\Matt\Combi\Archivo.ui',self) self.lineEdit.setFocus(True) self.pushButton.clicked.connect(self.conectar) </code></pr...