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: Warning: Invalid hook call. Hooks can only be called inside of the body of a function component<p>Hi I am building a spotify clone and at some point the guid...
<p>I saw a solution from the comment section where the user said to delete your node_modules folder and reinstall everything using <code>npm install</code>.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to unit test react hooks by shallow mounting React Functional components?<p>Is there a way to test functional components built using React hooks by shall...
<p>Yes you can but will need to use <strong>spies</strong>. For example if you are using <code>jest</code> you can you use <a href="https://jestjs.io/docs/en/jest-object#jestspyonobject-methodname" rel="nofollow noreferrer">jest.spyOn</a> with <a href="https://jestjs.io/docs/en/mock-function-api#mockfnmockimplementatio...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Async fetch results not transferred to data function<p>I have the code below in the file <code>_slug.vue</code></p> <p><code>{{ feed }}</code> always returns...
<p>You should use <code>fetch()</code> without anything inside of <code>()</code> otherwise, you'll be using the old fetch as explained here: stackoverflow.com/a/68820416/8816585</p> <p>Access the params through regular <code>this.$route.params.slug</code>.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: React js - Add unique key for ant design switch<p>I am having a problem on how to add a unique key to the switch that is under my loop.</p> <p>Actual Output...
<p>Here is how to handle an individual <a href="https://ant.design/components/switch/" rel="nofollow noreferrer">switch</a>. Do change the <a href="https://stackblitz.com/edit/so-59962894-multiple-antd-switch" rel="nofollow noreferrer">demo code</a> as per your demand.</p> <p><strong>App</strong></p> <pre><code>class...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Android XzingScanner : How to customise ZxingScanner layout ? (add button)<p>I'm realising a barcode scanner using Zxing Scanner, everything is working for t...
<p>This is good to customize QR/Barcode scanner with ZXing library</p> <p><a href="https://github.com/journeyapps/zxing-android-embedded" rel="noreferrer">https://github.com/journeyapps/zxing-android-embedded</a></p> <p>You can see sample app project there and customize (add button, set flash on/off) in yourself.</p>...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to achieve this design in flutter?<p>I want to make a design similar to this but I don't know how to achieve this design?<a href="https://i.stack.imgur.c...
<p>You can use stepper class or create your own widgets for this. Check out the following code for implementation:</p> <pre><code>class Home extends StatefulWidget { const Home({Key? key}) : super(key: key); @override State&lt;Home&gt; createState() =&gt; _HomeState(); } class _HomeState extends State&lt;Home&g...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Python/Matplotlib - Change subplot background color based on a binary array of strings<p>The code:</p> <pre><code>labels_0 = [] labels_1 = [] for i in range...
<p>You can use <a href="https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.fill_between.html?highlight=fill_between#matplotlib.axes.Axes.fill_between" rel="nofollow noreferrer"><code>fill_between</code></a> with red on a green background:</p> <pre><code>axs[1].patch.set_facecolor('g') axs[1].fill_between(en...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to import other types from `.ts` file in `.d.ts` file<p>I have a electron project which has strucutre:</p> <pre> src - main - preload - preload.ts ...
<p><a href="https://stackoverflow.com/a/51114250/12568197">https://stackoverflow.com/a/51114250/12568197</a></p> <blockquote> <p><code>.d.ts</code> files are treated as an ambient module declarations only if they don't have any imports. If you provide an import line, it's now treated as a normal module file, not the gl...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Hello I can’t make js files in the bottom in Wordpress<pre><code>function med_scripts() { wp_enqueue_script('BOOT-js', get_template_directory_uri() . '/a...
<p>Your code is working correctly. I tested it on my development site. You need to create a main.js file in the js folder if main.js does not exist. If you write custom code for jQuery, please pass jquery in the array. for example:</p> <pre><code>function med_scripts() { wp_enqueue_script('BOOT-js', get_template_di...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Position relative to the visible part of its container<p>So in the example below, I would like the label to always be visible at the top of the visible red p...
<p>You can use <code>position: sticky</code></p> <p>You can read more about it <a href="https://www.w3schools.com/css/css_positioning.asp#:%7E:text=An%20element%20with%20position%3A%20sticky,(like%20position%3Afixed)." rel="nofollow noreferrer">here</a> but basically it will act as position relative until you scroll to...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: vhost rewrite rules in apache - get rid of the subdomain without redirecting<p>I know similar questions have been asked, but for the life of me I can't seem ...
<p>It sounds like you require a "reverse proxy" since <code>example.com</code> is physically hosted on a different server. (However, you state in comments that "in the future" <code>example.com</code> would be back on the same server - at that time you may not need the "reverse proxy" if the subdomain and main domain p...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: HTML CSS Timeline alignment fails after the third element<p>I am new to HTML, CSS and JS currently trying to create a personal website for a course project. ...
<p>Your problem has been solved. Hope you benefit</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>/* Boilerplate CSS for box sizing and body */ * { box-sizing: border-box;...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Conditional Difference of Two Rows based on Two Different Groups in R<p>Following data set contains hourly accumulated rainfall. I want to calculate hourly r...
<p>You need to create groups when <code>HOUR == 9</code></p> <pre><code>library(dplyr) df %&gt;% group_by(gr = cumsum(HOUR == 9)) %&gt;% #Maybe you'll also need to add more groups #group_by(STATION, CODE, gr = cumsum(HOUR == 9)) %&gt;% mutate(RAINFALL = hr_rain - lag(hr_rain, default = 0)) # STATION COD...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Pre and post increment behaviour in C++<p>(C++) Why<br> <code>std::cout &lt;&lt; ++(a++);</code><br> shows <code>error: lvalue required as increment operand<...
<p>The return type of preincrement is <code>T&amp;</code>, which allows you to modify it (because it's a non-<code>const</code> reference). Postincrement returns <code>T</code>: it's an unnamed value in the <code>t++</code> context. Therefore, the result is considered const-like so you can't change its state.</p> <p>I...
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 flatten an Array of Array type?<p>I have a function that takes in a type like:</p> <pre><code>type Input = [Array&lt;string&gt;, Array&lt;n...
<pre><code>type Unarrayify&lt;T&gt; = { [K in keyof T]: T[K] extends Array&lt;infer E&gt; ? E : T[K] }; type MyType = Unarrayify&lt;[Array&lt;number&gt;, Array&lt;string&gt;, Array&lt;boolean&gt;]&gt;; // [number, string, boolean] function foo&lt;T&gt;(arrays: T): Array&lt;Unarrayify&lt;T&gt;&gt;() { ... } </code><...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Error trying to install mariadb package using pip3<p>I am trying to install mariadb usin pip3 on a python 3.8 environment on a Ubuntu 2004 server.</p> <p>I d...
<p>Since setup.py doesn't claim about missing Connector/C version (required is C/C 3.2.4 for Connector/Python 1.1.x) it looks like that mariadb_config (which will be used to check the installed version) was found, but somewhere is another <strong>mysql.h</strong> include file (either from an older MariaDB Connector/C, ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to see only 5 high results from the duplicates<p>I have a CSV file with 500 rows and 2 columns, one for numbers and the other for the number of duplicate...
<p>You can do</p> <pre><code>out = df2.sort_values('Total Duplicated',ascending=False).head(5) </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Downcasting a Rc<RefCell<Box<struct>>> to Rc<RefCell<Box<dyn trait>>><p>I have the following struct. It is just a wrapper for a vector of a given data type <...
<p>You need to get rid of the <code>Box</code>.</p> <p>The problem is that we allocated <code>Rc&lt;RefCell&lt;Box&lt;Port&lt;T&gt;&gt;&gt;&gt;</code>. <code>Box&lt;Port&lt;T&gt;&gt;</code> has a size of 1 <code>usize</code>, but now you want to convert it to <code>Box&lt;dyn PortTrait&gt;</code> which has size of 2 <c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do I get the x-coordinate into my plot?<p>I have the following dataframe and I am wanting to generate a graph that has date in the x-axis and median valu...
<p>I'm assuming you're using <a href="https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.DataFrame.plot.html" rel="nofollow noreferrer"><code>DataFrame.plot</code></a>. You could convert the index into a column:</p> <pre><code>median_price = median_price.reset_index() median_price.plot(x='Date', y='...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Is it possible to communicate classes between files in JS?<p>I've been working on a website that requires a large amount of Javascript. Naturally, I have a n...
<p>Yes you can use multiple files with the <code>export</code> and <code>import</code> commands</p> <p>To make classes in a file accessible outside it, <code>export</code> the values:</p> <pre><code>// numberedClasses.js class Class1 { constructor() { // Your code for the class here } // Your additional me...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to check if mat[j][i]>mat[j+1][i] with rows of different length?<p>hello i have to do the following exercise: Write an iterative e1 method with the follo...
<p>As far as I can understand the 7th test assumption is wrong since:</p> <pre><code>m6[0][1] &lt; m6[1][1] = true; // 1 &lt; 2 int[][] m6 = { { 0, 1 }, { 0, 2, 3 }, null }; System.out.println("Caso 7:" + (e1(m6) == false)); </code></pre> <p>.. so this should be</p> <pre><code>System.out.println("Caso 7:" + (e1(m...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: seaborn facetgrid: when hue value doesn't appear in all graphs the legend is misannotated<p>I've also opened an issue in the seaborn git repo <a href="https:...
<p>maybe unsurprisingly, I should have read the documentation more closely. As mentioned in the <a href="https://seaborn.pydata.org/generated/seaborn.lineplot.html" rel="nofollow noreferrer">lineplot()</a> documentation &quot;Using <a href="https://seaborn.pydata.org/generated/seaborn.relplot.html#seaborn.relplot" rel=...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Bootstrap Navbar not working when in mobile mode<p>I'm quite new to BOOTSTRAP 5 (Web Development in general) and I am currently trying to make a simple websi...
<p>You also need to link the JavaScript Bundle for Bootstrap. The mobile menu only works with JS.</p> <p>The JS Bundle code is:</p> <pre><code>&lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js&quot; integrity=&quot;sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHU...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why my header files can't correctly index each other's declaration dependency with clangd in VSCode?<p>I'm now codeing C/C++ in VSCode with clangd.There are ...
<p>This has nothing to do with VScode or clangd.</p> <p>Instead, the problem is that in file <code>b.h</code> you have not included <code>a.h</code> and thus <code>uint64</code> is unknown at the point where you're using it <code>uint64 abc;</code>.</p> <p>To solve this, you need to include <code>a.h</code> before usin...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to show SwiftUI preview in landscape<p>.previewLayout(.fixed(width: 480, height: 320)) has no effect in Xcode 13.4 and Xcode 14 beta 3</p> <p>The preview...
<p>To make it clear here, you did not actually set your <code>preview</code> in landscape mode. Two solutions for your problem:</p> <ol> <li>You actually requested the preview to be in a fixed size window, so to make this work, you need to choose <code>Selectable</code> in the canvas window to preview in a fixed sized ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to properly use Dart encapsulation in inheritance<p>Encapsulation says you should use private attributes, but this brought me an issue. I cannot access s...
<p>You could try and use getters for the private fields</p> <pre><code>class Animal { String? _color; String? _specie; int? _age; String? get color =&gt; _color; String? get specie =&gt; _specie; int? get age =&gt; _age ... } </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: HttpNotFoundException message not displayed in Laravel<p>I am handling the HttpNotFoundException and want to when redirecting back with an error message, but...
<p>I have found the solution in <a href="https://laracasts.com/discuss/channels/requests/session-variables-inside-exceptionhandler" rel="nofollow noreferrer">here</a>.</p> <p>just added <code>\Illuminate\Session\Middleware\StartSession::class,</code> to middleware array of kernel.php</p> <p>Thanks from all.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Using Curl in Batch to control HTML elements<p>I am currently trying to figure out a way to press a button on a website by simply using a batch file.</p> <p...
<p>You should extract the stream by another tool in my case i can extract with <code>IDM : Internet Downloader Manager</code></p> <p>And you can write it with a batch file that use a vbscript to play the stream :</p> <pre><code>@echo off Title Welcome to the world of the music Mode 50,3 &amp; color 9E echo( echo ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: same LINQ queries but different tables<pre><code>await _context.TableA .Where(x =&gt; request.A == null || x.A == request.A) ...
<p>You could do this if both of your entities implement the same interface with all relevant properties. Same goes for the DTO classes too. For example:</p> <pre><code>public interface IFoo { string A { get; } DateTime CreatedAt { get; } // etc } </code></pre> <p>And each of your entities must implement tha...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Unique key with not null values<p>I have an array like this one:</p> <pre><code>const es = [ ['A', 'A1'], // first A key ['B', null], ['C', null], [...
<p>You can try something like this:</p> <p>You need to set new value only if:</p> <ul> <li>value is empty <code>null</code> or <code>undefined</code></li> <li>Both the values exists and are valid</li> </ul> <p>Idea is to assign first value and replace with latest non-empty value.</p> <p><div class="snippet" data-la...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to use .innerHTML in template element<p>I'm making an app with a framework that uses templates in HTML pretty heavily. It was all going well until I bump...
<p><strong>1) Template-element content is not rendered by default</strong></p> <p>You can re-use the content in a template-element as many times as you want, but you need to manually specify that using Javascript. If you don't use any Javascript to render your template-element it won't be visible in the DOM. Resulting...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to add column with conditions to dataframe<p>My dataframe can be simplified like this:</p> <p>Dataframe :</p> <pre><code>df = pd.DataFrame({'Customer_ID'...
<p>I think this is what your want: show the topest characteristic of animals.</p> <pre><code>df[&quot; oldest&quot;] = df.groupby('Category')[&quot;Age&quot;].rank(ascending=False) df[&quot; heaviest&quot;] = df.groupby('Category')[&quot;Weight&quot;].rank(ascending=False) df[&quot;Top&quot;] = df[[&quot; oldest&quot;,...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to turn table of colums into rows in Excel<p>I would like to set up a live Excel query for our SQL database for product categories. The way I will be abl...
<p>Power Query is the perfect tool for this, assuming you're using at least Excel 2010. </p> <p>In 2016 go to Data on the ribbon then in the 'Ger &amp; Transform Data' section on the left, choose the Get Data button, choose Database then SQL Server Database. <a href="https://i.stack.imgur.com/zlkjq.png" rel="nofollow...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Spinning Artifactory instance (container) during CI pipeline<p>I would like to spin a containerized Artifactory instance, to generate a PyPi repository and p...
<p>As PyPi is part of the paid Artifactory subscription, you can consider using a <a href="https://jfrog.com/start-free/#saas" rel="nofollow noreferrer">free Artifactory cloud instance</a>.</p> <p>It has full support of PyPi and other technologies, but is limited by storage and data transfer.</p> <p>It means you'll hav...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Cant update to Angular 8 since the command is not found<p>I want to upgrade my ionic application. First I tried to do it with </p> <blockquote> <p>ng upda...
<p>You need to install <code>@angular/cli</code> globally in order to access the <code>ng</code> command.</p> <pre><code>npm install -g @angular/cli </code></pre> <p>Notice the <code>-g</code> here, it stands for <code>global</code></p> <p>If this is already installed, you might want to check your <code>$PATH</code>...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Solving dispersion equation<p>I am trying to solve the dispersion equation:</p> <p><code>w^2 = k*g * tanh(kh)</code></p> <p>I have a vector (25x1 element) ...
<p>You can use an apply function, like so:</p> <pre class="lang-r prettyprint-override"><code># Parameters g &lt;- 9.81 h &lt;- 8 w &lt;- c(0.1, 0.2, 0.3) # Function to find root of disp_root &lt;- function(k, w) {k * g * tanh(k * h) - w^2 } # Apply for each w res &lt;- sapply(w, function(x)rootSolve::uniroot.all(...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to index individual layers from a SpatRaster object by time?<p>I found out the other day, more or less by chance, that it is possible to query layers fro...
<p>You are mixing up layer names (that may look like a time-stamp) with an actual time-stamp.</p> <p>Here is how you can use time-stamps (using Date here, as it is a bit less verbose)</p> <pre><code>library(terra) r &lt;- rast(ncols = 10, nrows = 10, nlyr = 365) time(r) &lt;- as.Date(&quot;2001-01-01&quot;) + 0:364 hea...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to join ListQueryable table and return toList();<p>Here is my code, I try to join two <code>ListQueryable</code> tables and return in <code>List();</code...
<p>You need to change your code to return a list instead, change the return type of your method to <code>Task&lt;List&lt;TestModel&gt;&gt;</code> and change <code>FirstOrDefault</code> to <code>ToList</code>, something like this:</p> <pre><code>public async Task&lt;List&lt;TestModel&gt;&gt; Report(TestModel model) { ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Azure Devops CI pipeline failing when adding SonarQube<p>I'm trying to add SonarQube into a CI pipeline on Azure DevOps.</p> <p>My project is .Net Core 2.2 ...
<p>The problem was in the JDK used in Micorosft Hosted Machine, for some reason the JDK used was not the supposed one. The solution was following these steps:</p> <ol> <li>Uploading a JDK <code>zip</code>file to Azure blob storage</li> <li>Running Java Tool Installer in my Pipeline, giving it the Uploaded <code>zip</c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: System.getProperty("line.separator") and " \n " Causes listview not to populate<p>In my app I have a List view,</p> <p>The view is populated by an array of ...
<p>I solved this By changing the Listview to A Spinner and calling a spinner adapter</p> <pre><code> StaffList.setAdapter(new ArrayAdapter&lt;&gt;(createProject.this, android.R.layout.simple_spinner_dropdown_item, Array)); </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Regex spacy matcher not working as expected in spacy<p>I am learning how to use the matcher in spacy and get this unexpected situation</p> <pre><code>pnum1 =...
<p>Convert f-string to normal:</p> <pre class="lang-none prettyprint-override"><code>pnum1 = [ { 'TEXT': {'REGEX':r&quot;\d{1,4}&quot;} } ] </code></pre> <p>In f-strings, <code>{{</code> and <code>}}</code> must be used as literal braces.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Square Payment Gateway integration in PHP website doesn't redirect to payment portal<p>I m trying Square payment gateway using the API code found in the belo...
<p>My Apologies to Every One who banged their heads at this issue and wasted their valuable time on this.,</p> <p>Turns out the reason for this silly issue is <strong>not having the site secured (i.e., Absence of SSL certification)</strong></p> <p>I came to know about this after going through square-up documentation....
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: chalk tagged template literals within strings<p>i am using chalk and i am constructing a string programatically (see <code>str</code> in the snippet below).<...
<p>i found a <a href="https://gist.github.com/bennadel/71eb3670ccf51daabf1658fb13b337b1#file-test2-js" rel="nofollow noreferrer">proxy for chalk</a> that does just this</p> <pre><code>const chalk = require("chalk"); const chalkish = (parts, ...substitutions) =&gt; { const rawResults = []; const cookedResults = []...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Exception::raise(): Unimplemented Parser Node: EmptyElse<p>When running srb init in a Rails app I get the following:</p> <pre><code>Generating /tmp/d20220723...
<p>Anytime you see <code>Exception::raise</code> in a Sorbet error message, it means there was a bug in Sorbet. You can report Sorbet bugs at <a href="https://github.com/sorbet/sorbet/issues" rel="nofollow noreferrer">https://github.com/sorbet/sorbet/issues</a></p> <p>I have created a fix for this bug here: <a href="ht...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Pyomo (Transportation theory): including a constraint that compares the value of period 'T' with 'T-1'<p>I'm trying to solve the classical 'Transportation th...
<p>This is all doable. A couple of key ingredients...</p> <ul> <li>You will need 2 new binary variables, indexed appropriately. First, you need to track whether a particular factory is &quot;running&quot; in any period. I did this with a big-M constraint (see code). You will then need a second binary variable to in...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do I know if my Neural Network model is overfitting or not (Keras)<p>I'm using Keras to predict if I'll get an output of 1 or 0. The data looks like this...
<p>Your <strong>test data</strong> meant to be for monitoring the model's <a href="https://en.wikipedia.org/wiki/Overfitting" rel="nofollow noreferrer">overfitting</a> on <strong>train data</strong>:</p> <pre><code>hist = model.fit(X_train, Y_train, validation_data=(X_test, Y_test), epochs=10, batch_size=2) </code></p...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Create an order with different quantities of products<p>I have page that list the products available and I want the user to be able to indicate which quantit...
<p>Product model</p> <pre><code>class Product &lt; ApplicationRecord has_and_belongs_to_many :orders, join_table: PurchaseProduct.table_name has_many :purchase_products end </code></pre> <p>Order Model</p> <pre><code>class Order &lt; ApplicationRecord has_and_belongs_to_many :products, join_table: PurchasePro...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to pass props to React component using React Router after state change?<p>I'm building a web app and it contains a dropdown list with various <code>score...
<p>With React-Router, you can pass a state with your navigation call, like so:</p> <pre><code>... const navigate = useNavigate(); ... &lt;NavDropdown.Item key = {i} id = {score[&quot;scoreId&quot;]} onClick = {(e) =&gt; { navigate('/home/score', { state: {score} }); }} &gt; {score[&quot;scoreName&quot;...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to find if a value exists in a range and print "FOUND" or "MISSING" in a new column<p>I am trying to perform a function simmiliar to the function in exce...
<p>Based on the limited information:</p> <pre><code>lookup_list &lt;- c(1:3) x &lt;- c('a','b','c') y &lt;- c(10, 3, 5) df &lt;- data.frame(x,y) x y 1 a 10 2 b 3 3 c 5 df &lt;- df %&gt;% mutate(status = case_when( y %in% lookup_list ~ 'FOUND', !y %in% lookup_list ~ 'MISSING' )) x y status 1 a 10 ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Error: Connection timeout at SMTPConnection._formatError<p>Error: Connection timeout at SMTPConnection._formatError, don't know what is wrong, can't send ma...
<p>The part of the error message to focus on here is <code>SMTPConnection._formatError</code>. You are receiving this error because the transport configuration variables are not correct. You need the following variables, with correct values for each.</p> <p>There are additional variables that can be used, but based on ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to move or remove the legend from a seaborn JointGrid or jointplot<p>How to remove the legend in the <a href="https://seaborn.pydata.org/generated/seabor...
<ul> <li>To remove the legend, the correct part of the <a href="https://seaborn.pydata.org/generated/seaborn.JointGrid.html" rel="nofollow noreferrer"><code>sns.JointGrid</code></a> must be accessed. <ul> <li>In this case <code>g.ax_joint</code> is where the legend is located.</li> </ul> </li> <li>As stated in a commen...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Print all the dividers from a number, unsupported operand type for string and range<p>I am trying to exercise my python and do exercices. One exercise is to ...
<p>try this...</p> <pre><code>a = int(input(&quot;give me a number: &quot;)) for elem in range(2,a+1): if a%elem == 0: print(elem) </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Load bitmap asynchronously Direct2D C++<p>I have a class that represents an gui-element, that has method to set an image on it's background:</p> <pre><code>c...
<p>First off, your code is far from a minimal reproducible example. But then again, I've never touched Direct2D before, and I still managed to get it working.</p> <p>Anyway, it doesn't matter what you do, you'll have to load the image before you're able to render it. Since you used browsers as an example in the comment...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Bash Diff of Nested Files<p><strong>Premise</strong>:</p> <p>I have <strong>five</strong> files in <strong>two</strong> directories.</p> <pre><code>folder/ ├...
<p>Run <code>jq</code> on each json file to produce a common format of output then <code>diff</code> THAT:</p> <pre><code>diff &lt;(jq . folder/old/a.json) &lt;(jq . folder/new/a.json) </code></pre> <p>For example:</p> <pre><code>$ head *.json ==&gt; x.json &lt;== { &quot;hello&quot;: { }, &quot;world&quot;: &...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to make a code that shakes the camera of the player<p>I tried to make a code that's shake the camera player when a RemoteEvent is fired by a key on the k...
<p>Your problem is that you made the <code>CameraType</code> scriptable, with it scriptable, the character's <code>Humanoid</code> no longer has control of it. Remove the lines that make the <code>CameraType</code> scriptable and it will solve your issue.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: TypeScript: How to filter data that is in a separate component to the filter function<p>I am currently working on a filter function for a table. I have one ...
<p>The way to handle this type of cross-component communication in React is through state management. And one of the simplest ways to do this is by <a href="https://reactjs.org/docs/lifting-state-up.html" rel="nofollow noreferrer"><em>lifting state</em></a> to a parent component. The parent component holds the state, ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do i fetch data from the backend to the frontend?<p>I have this get API in my server side (Node JS):</p> <pre><code>app.get(&quot;/todos&quot;, async(req...
<p>It should be:</p> <pre><code>useEffect(()=&gt; { getTodos(); }, []); </code></pre> <p>Instead of:</p> <pre><code>useEffect = (()=&gt; { getTodos(); }, []); </code></pre> <p>You declared a new variable by accident</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: new line in textarea while looping with props<p>Given this snippet, how can I insert a new line at the specified position?</p> <pre><code>&lt;div&gt; &lt...
<p>Your &quot;cheating&quot; method is correct of course, and is not really cheating. It follows the rules of outputting exactly what you want in the template. (You are inserting the newline exactly where you want it). See discussion <a href="https://stackoverflow.com/a/34647721/1054484">here</a>.</p> <p>But yes it may...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: flutter how to remove gap from left side in CarouselSlider<p>I want to show the all images from the API in the carousel and for items, I want to show 2 items...
<p>Set initial page</p> <pre><code>initialPage: 1, </code></pre> <p>also change</p> <pre><code>enableInfiniteScroll: true, </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to install and run pip in Google Dataproc cluster<p>I created a cluster in Google DataProc with the following commands:</p> <pre><code>gcloud beta datap...
<p>I changed <code>--metadata PIP_PACKAGES=numpy:scipy:pandas:scikit-learn:matplotlib:seaborn</code> to <code>--metadata PIP_PACKAGES="numpy scipy pandas scikit-learn matplotlib seaborn"</code> in your command and was able to use the <code>pip-install.sh</code> initialization script.</p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I get summary of customed tensorflow Model<p>How can I get the summary of customed tensorflow Model?</p> <pre><code>class Discriminator_block(tf.kera...
<p>You need to change and consider multiple steps in your code to print a <code>summary</code> of your custom block.</p> <ol> <li>Important thing is to change <code>tf.keras.layers.Layer</code> to <code>tf.keras.Model</code></li> <li>Create an instance of your model.</li> <li>Input a random tensor to the model that you...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Future assigned to MicroTask or Event Queue?<p>In the example below:</p> <pre><code>void main() { print('Start'); Future( () { print('Mid'); ...
<p>The computation of <code>Future(() { ... })</code> is scheduled in the event queue. It happens in a later event (a timer event, actually, not a microtask event).</p> <p>That happens in both cases. Everything up to the scheduling of that computation is the same in both programs. It's what happens afterwards that diff...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: The optional parameter in the route does not work<p>I'm having a problem with the optional parameter; in particular I notice that it is not read in the link....
<p>The parameter is working as expected. Change</p> <pre class="lang-html prettyprint-override"><code>&lt;td&gt;&lt;a href=&quot;{{route('project.index')}}&quot; class=&quot;link-primary&quot;&gt;{{ $client-&gt;projects_count }}&lt;/a&gt;&lt;/td&gt; </code></pre> <p>to</p> <pre class="lang-html prettyprint-override"><c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Loop through key value pair<p>How do I loop through a key value pair array?</p> <p>I declare mine as such:</p> <pre><code>produse!: {[key: string] : ProductD...
<p><code>this.produse</code> is an array of objects (<code>Array&lt;{[key: string] : ProductDTO}&gt;</code>). At the end of type <code>[]</code> means that it is an array. So you need to loop array first, then objects:</p> <pre><code>for (const produses of this.produse) { for (const produs of Object.values(produses) ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to create a debounce-like function using variables in React?<p>I have a component in React that essentially <strong>autosaves form input</strong> 3 secon...
<p>Note: I was typing up answer on how I solved this previously in my own projects before I read @DrewReese's comment - that seems like a way better implementation than what I did, and I will be using that myself going forward. Check out his answer here: <a href="https://stackoverflow.com/a/70270521/8690857">https://st...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Python basic - os library issue - os.path.isfile() not working as expected<p>I tried to make a small python program that lists the files and folders in a dir...
<p><code>os.listdir</code> returns the names of files and directories, not the full path. You need to create the full path your self using <code>os.path.join</code>:</p> <pre><code>import os list_files = [] list_dir = [] enter_dir = input('Enter dir to list its content: ') for item in os.listdir(enter_dir): full...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Percentiles in MariaDB<p>I'm trying to find the 25th and 75th percentiles in MariaDB 10.4.11, according to <a href="https://mariadb.com/kb/en/percentile_cont...
<p>The <code>PERCENTILE_CONT</code> function is a window function and therefore is applied to the entire result set. You could get the output you want by aggregating by name and taking the max of each expression:</p> <pre><code>SELECT name, MAX(percentile_25) AS percentile_25, MAX(median) AS median, ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to create a new column based on the filtering and calculation in pandas?<p>I have a dataset like:</p> <div class="s-table-container"> <table class="s-tab...
<p>You can use <a href="https://pandas.pydata.org/docs/reference/api/pandas.pivot_table.html" rel="nofollow noreferrer"><code>pd.pivot_table</code></a> with <code>aggfunc='sum'</code> on <code>column='revenue'</code>.</p> <pre><code>df = pd.pivot_table(df, index=['ymd'], values='revenue', aggfunc='...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Animations of the bottom line from the center<p>I want to style the bottom line in the dropdown so that when I clicked it was the same color as the input, i....
<p>i have shared code hover effect on Input &amp; dropdown. please check</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>/******************************************************...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to implement Retry logic in RabbitMQ?<p>In my project I'm setting <code>SimpleRetryPolicy</code> to add custom exception and <code>RetryOperationsInterce...
<p>Your <code>GlobalErrorHandler</code> does its logic before the retry happens and you override there an exception with the <code>AmqpRejectAndDontRequeueException</code>. And looks like you do there a publish to DLX. Consider to move your <code>GlobalErrorHandler</code> logic to a more general <code>ErrorHandler</cod...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: (Python Snake game) For loop doesn't draw snake<p>This is a small problem, been working on a snake game in python, it's not complete yet and there's just one...
<p>You don't need <code>x_head</code>, <code>y_head</code> and <code>length</code> at all. The position of the snake is stored in the lists <code>x_pos</code> and <code>y_pos</code>, use it:<br> (<a href="https://docs.python.org/3/library/functions.html#zip" rel="nofollow noreferrer"><code>zip()</code></a> aggregates t...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Difference between DELETE HTTP request parameters and request body<p>I'm trying to understand the behaviour of an HTTP DELETE request.</p> <p>On my java web ...
<blockquote> <p>I use the module spring-boot-starter-web of <strong>spring boot (v2.7.1 on my project)</strong>.</p> </blockquote> <p>According to the most <a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html" rel="nofollow noreferrer">recent</a> ver...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: HTML Google chart with value argument in Javascript<p>I try to display a google chart in HTML using an argument from Javascript. my code is the following:</p...
<p>you need to wait for google charts to load,<br> before drawing a chart. </p> <p>which is the point of --> <code>setOnLoadCallback</code> </p> <p>you pass a function to this method,<br> which will be called when google charts has fully loaded. </p> <p>here, <code>drawBasic</code> is called with the argument,<br...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to splice a certain item within another array<p>I receive something like this:</p> <p>serverDocument.scheduledLines [</p> <p>{ _id: 'd375d9f136d9aed8161e...
<p>You can just remove the property from each array item with a <code>map</code> function</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 = [ { _id: 'd375d9f136...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Redis streams with persistent storage<p>Is it possible to use <strong><em>Redis streams with persistent storage</em></strong> or are streams limited to in me...
<p>Redis Streams are persisted as any other data type. Streams are a data structure on its own right, a core one in the sense that it is part of Redis core since 5.0.</p> <p>There is no way to actually persist only some data types. It persists them all if AOF or RDB are set up.</p> <p>Pub/sub is not persisted at all,...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I get Javascript onSuccess response object variables in Python?<p><strong><em>Background:</em></strong></p> <p>Working in a Django application, I ha...
<p>Using ideas from @Lag11 and @Arount and a wonderful tutorial <a href="https://www.pluralsight.com/guides/work-with-ajax-django" rel="nofollow noreferrer">here</a>, I created 2 function based views, one to just serve the 'page' the other to handle the 'page post to DB'.</p> <p>Summary, I did this in the <strong><em>...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Jest mock a fetch function from a connected component<p>I have some code which works. However for my test I would like to mock the fetch that is done in the ...
<p>Jest itself is in charge of the modules. So in the following example you will see that the module coming from '../http' can be <em>mocked</em>.</p> <p>You can then overwrite the props of that module by first adding the default props, and after that overwrite the ones you need with your own.</p> <pre><code>jest.moc...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to Make selectable appPackage and appActivity BeforeScenario in android Appium Test Automation<p>I want to choose starting app(appPackage,appActivity) in...
<p>You can pass app name from VM aguements and base on that you can set driver instance. Please have a look on code below: </p> <pre><code>@BeforeScenario public void beforeScenario(String appName) throws MalformedURLException { DesiredCapabilities desiredCapabilities = new DesiredCapabilities(); switch (appN...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: IntelliJ theme: customize bg-color of editor tab's close button<p>I maintain an IntelliJ theme (Darcula Sombre), and latest build of IntelliJ 2020.1 introduc...
<p>You can customise it with &quot;Actions.GreyInline&quot; and &quot;Actions.GreyInline.Dark&quot; properties.</p> <p><a href="https://i.stack.imgur.com/bC6LJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bC6LJ.png" alt="enter image description here" /></a></p>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to create and insert a column with categorical variables for specific ranges<p>I have a dataframe with over a thousand rows with very long sample names a...
<p><em>You can use <code>base::strsplit</code>.</em> </p> <p>Here, I split the <code>sample</code> column at each <code>_</code>. The fourth element of separated character list is our index. I am using <code>[4]</code> within <code>lapply</code> to get the 4th element of each row.</p> <pre class="lang-r prettyprint-o...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Big O: What is the name for the complexity O(a * b)?<p>I am new to studying the Big O notation and have thought of this question. What is the name for the co...
<p><em>O(ab)</em> is just <em>O(ab)</em>. Technically, <em>ab</em> is a <a href="https://mathworld.wolfram.com/MultivariatePolynomial.html" rel="nofollow noreferrer">multivariate polynomial</a> of 2<sup>nd</sup> degree. But this is not equivalent to a quadratic polynomial, such as <em>a<sup>2</sup></em>.</p> <p>If you ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to remove duplicate files from an arraylist<p>A bit different from the others. I'm retrieving an arraylist of files for processing (basically handling DL...
<p>Use a hashtable to keep track of the last file seen for a specific file name:</p> <pre><code>$files = @{} Get-ChildItem -Path $PSScriptRoot -File -Recurse -Filter *.dll |Where-Object FullName -notmatch 'dll_Old' |ForEach-Object { $files[$_.Name] = $_ } $uniqueFiles = $files.Values </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: got cannot resolve symbol error when adding new view to fragment programmatically<p>when I am writing a viewholder as the android guide described, I got erro...
<p>You are casting wrongfully to <code>TextView</code>, because the method returns data-type <code>View</code>.</p> <p>Typically it would look alike this:</p> <pre><code>View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_newly_added_view, parent, false); TextView test = view.findById(R.id.test);...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to import custom fonts for PDFMake in Angular application?<p>I just started reading into PDFMake's documentation to build a document in my Angular app, I...
<p>have just spent an afternoon trying to do the same. The documentation is at minimum, but I have figured it out.</p> <p>1) First you need to clone the PdfMake repo locally.</p> <p><a href="https://github.com/bpampuch/pdfmake" rel="nofollow noreferrer">https://github.com/bpampuch/pdfmake</a></p> <p>2) Once download...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Chrome Autofill CSS + Background Image<p>So... I got these inputs (sort of) working in Chrome but the Auto fill classes are still giving me trouble with back...
<p>use <code>-webkit-background-clip:text;</code> to remove chrome autofill effect</p> <p>add input to transparent and set wrapper to add background image</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...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Error using svc.fit(): ValueError: bad input shape<p>I have data about Parkinson patients stored in the dataframe <em>X</em> and whether a patient has Parkin...
<p>You have problems with the definition of <code>train_test_split</code> Careful! <code>train_test_split</code> outputs the <code>X</code> part first followed by the <code>Y</code> part. You are actually naming y_train what is X_test. Change this and it should work:</p> <pre><code>X_train, X_test, y_train, y_test = t...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Choose file name depend on parameter in command line running pytest<p>I have a project with structure the same as this: <a href="https://github.com/RomanBagg...
<p>Here is the final code, that solve my problem: conftest.py</p> <pre><code>@pytest.fixture def choose_status(request): return request.config.getoption("status") def test_main_page(choose_status): MainPage().go_to_login_page(choose_status) </code></pre> <p>In main_page.py</p> <pre><code>class MainPage(Bas...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How add columns with variable and different names in pandas<p>Suppose I have a dataframe in pandas, e.g.</p> <pre><code>import pandas as pd import numpy as n...
<p>You cau use <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.assign.html" rel="nofollow noreferrer"><code>pandas.assign</code></a> like below.</p> <pre><code>df = df.assign(**{f'new_column_{k}' : 0 for k in range(2)}) print(df) </code></pre> <hr /> <pre class="lang-none prettyprint-override"><c...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Mockito: Mocking abstract enum throws exception<p>I have a lot of tests, that worked with Java 11, but do not work anymore with Java 17 and newer versions of...
<p>After some digging we found the following:</p> <p>The issue is that the current Mockito version (4.6.1) can't mock <code>sealed</code> classes.<br /> <code>sealed</code> is a new modifier in java 17, which in short is the same as <code>final</code> with exceptions which classes are allowed to implement the sealed cl...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Select query returning None<p>Even after inserting few rows in mySql server database, when running select query I am getting result as None.</p> <p>Here's my...
<p>You need to fetch the results after executing the query</p> <pre><code>sqlCursor.execute(&quot;SELECT status FROM edp_report&quot;) results= sqlCursor.fetchall() #use fetchone() if you expect a single result </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why does tf.random.uniform generate duplicates inside a function but not in the main program?<p>I'm new to TensorFlow, and I was trying to understand how see...
<p>Let's answer your first question</p> <blockquote> <p>Why did the two prints inside the function show different output to the print from the return value of the function, in other words why was no value (numpy=array...) shown in the first two lines compared to the last two?</p> </blockquote> <h1>Eager Execution vs Gr...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Android disable Scrollview end animation<p>There is animation when reaching the end of Scrollview with great velocity. The animation basically pulling the Sc...
<p>I think you mean over scroll effect which can be disabled in your xml </p> <pre><code> android:overScrollMode="never" </code></pre> <p>or </p> <pre><code> listView.setOverScrollMode(View.OVER_SCROLL_NEVER); </code></pre>
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: C# assign value to another object member that is list<p>I have question about assigning value to the list&lt;> member of another object. I'm receiving error...
<p>You need to instantiate Hobbies collection.</p> <pre><code>public class Survey { public List&lt;Person&gt; Poll; public Person p; public void StartPoll() { p = new Person(); p.FullName = "Billy"; p.LastName = "Bob"; p.Location = "America"; p.Hobbies = new List&lt;str...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: SwiftUI's custom modal logic: how to present view from parent<p>Coming from UIKit, I'm building my own modal navigation logic in SwiftUI, because I want cust...
<p>Here's a simple solution using <code>UIKit</code>:</p> <p><a href="https://i.stack.imgur.com/NKeO9.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NKeO9.gif" alt="enter image description here" /></a></p> <pre><code>extension View { func presentModalView&lt;Content: View, Item: Equatable&gt;(it...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: R - How to format text output from a list<p>I have the following dataframe:</p> <pre><code> Name Occupation Country code Remarks Mark Engineer ...
<p>In this case, we can do a single split, <code>paste</code> the 'Occupation' with the 'NameRemarks' column and <code>cat</code> to create new files</p> <pre><code>lst2 &lt;- split(df2[-3], df2$Countrycode) lapply(names(lst2), function(nm) with(lst2[[nm]], { v1 &lt;- tapply(NameRemarks, Occupation, FUN = paste, co...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Assigning state to a nested array with ReactJS<p>I am currently trying to assign <code>state</code> to a nested object using the hook <code>setState()</code>...
<p>One of the rules of React hooks is <a href="https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level" rel="nofollow noreferrer">don't call hooks inside loops</a>. You can instead move your code into a new component and call the hook inside the component:</p> <pre class="lang-js prettyprint-overrid...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Ionic NullInjectorError: No provider for NetworkProvider<p>Hi i am trying to determine if my device is connected to the internet or not. But when i run the a...
<p>You're trying to inject <code>NetworkProvider</code> when it is not yet declared to be provided in the service itself or the app module. It needs to be declared as a provider just like Network, Statusbar and Splashscreen. Add <code>NetworkProvider</code> to the provider array or Change <code>@Injectable()</code> to ...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Incorrect plotting of ramp sequence in Matlab<p>I am trying to plot a discrete <a href="https://en.wikipedia.org/wiki/Ramp_function" rel="nofollow noreferrer...
<p>You are passing the whole vector <code>n</code> into the <code>pw()</code> function. However, the <code>pw()</code> function then compares <code>n</code> to 0, which is a scalar.</p> <p>You could adjust your <code>pw()</code> function to operate on vector inputs like this:</p> <pre><code>function y = pw(n) y =...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Apply formula based on condition in certain column<p>I have a DataFrame that looks like that:</p> <pre><code>df1=pd.DataFrame([[1,0.10],[1,0.15],[3,0.16],[3...
<p>Use custom function with consecutive groups by <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.shift.html" rel="nofollow noreferrer"><code>Series.shift</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.cumsum.html" rel="nofollow noreferr...
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Using column as a parameter in macro dbt jinja<p><em>Hello everyone, I have 28 tables(models) to create. I need to do some transformations on these tables. S...
<p>I see you found <a href="https://stackoverflow.com/questions/72899333/not-able-to-access-dictionary-value-in-macro-dbt">my other answer</a> that attempts to explain the difference between the compilation step and the query execution step. But I think you're making the same mistake as that other person, and you're us...