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:
Concurrency problem when retrieving data from Firebase to display it in a table view<p>I am currently trying to retrieve user data from my real time database... | <p>Your problem is cause because your call to <code>self.tableView.reloadData()</code> is actually inside the Firebase callback with your data. This callback is not guaranteed to be on the main thread, and <strong>all UI operations must occur on the main thread, always</strong>. You need to wrap the call to reload the ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to POST data using AJAX from one form when there are multiple forms on the same page?<p>I am trying to build a quiz and I would like users to be able to ... | <p>If you listen for a form to be submitted you will have direct access to the data within that form. Additionally, if you listen for a <code>form.submit()</code> and a submit button within that form is clicked it will trigger the <code>form.submit()</code> (kind of a two birds with one stone thing).</p>
<pre><code>&l... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Node.js cors origins from app deployed on heroku<p>I've deployed my node.js app on heroku and now I'm trying to connect to this from my localhost:3000, but I... | <p>You can try this.</p>
<pre><code>import express from 'express';
import mongoose from 'mongoose';
import blogRouter from './routes/blog-routes';
import router from './routes/user-routes';
import cors from 'cors';
const port = process.env.PORT || 5000
const app = express();
let corsOrigins=[];
if(process.env.REQUE... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Fastest way to count frequencies of ordered list entries<p>I'm counting the occurrences of non-overlapping grouped subsequences of length <code>i</code> in a... | <p>I don't know if is faster, but try</p>
<pre><code>
import numpy as np
# create data
bits = np.random.randint(0, 2, 10000)
def subseq_counter(i: int, l: np.array):
"""
Counts the number of subsequences of length l in the array i
"""
# the list l is reshaped as a matrix... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to delete break lines on JSON between rows when printing it in a web browser in Javascript?<p>In Javascript I have to print in the document a JSON with s... | <p>@Adrian2895,</p>
<p>Simply convert it to string and this will remove new-line/carriage-return. And also the above code is working fine (which I referred to use deep-cloning to remove any attribute).</p>
<p><a href="https://i.stack.imgur.com/Ba0SM.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do I optimize a multi-vairable scalar function (that involves trace and matrices) in Python?<p>I am currently trying to optimize a function of the form:<... | <p>In scipy.optimize the x vector should be 1-dimensional vector of length NUMVAR. You pass on something more complicated. You should do something like:</p>
<pre><code>from scipy.optimize import minimize
import numpy as np
n1 = 2 # number of variables in user x array
n2 = 4 # number of variables in sigma
n = n1 + n... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
laravel merge all arrays into one<p>I have search function where it searches into several model and get results back, now i would like to have all those mode... | <p>You can store the results in an assoc array instead of separate variables.</p>
<pre><code>public function results(Request $request) {
$q = $request->input('q');
$result = [];
$result['products'] = Product::where('name', 'like', "%{$q}%")
->orWhere('body', 'like', "%{$q}%")
->paginate... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Could not create SSL/TLS secure channel only on Windows Server 2012<p>I have a peculiar problem where a c# app works on all other machines and other client m... | <p>We had the same problem today.
Some unsafe cipher suites were removed at our webserver yesterday.
Though vulnerable, adding these cipher suites fixed the problem.
<a href="https://docs.microsoft.com/en-us/windows-server/security/tls/manage-tls" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/windows-serve... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to get a random value of a dictionary in swiftyJSON and Alamofire<p>I want to get <strong>1 (one)</strong> "value" in a <strong>random</strong> order wit... | <p>Create a model object for your JSON</p>
<pre><code>struct Entry: Codable {
let id, value, localization: String
}
</code></pre>
<p>and decode it using <code>JSONDecoder</code>:</p>
<pre><code>do {
let entries = try JSONDecoder().decode([Entry].self, from: data)
} catch {
print(error)
}
</code></pre>
<p>once... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Another stopwatch using JS?<p>The code is creating a responsive page. But every time I press stop and then start again the countdown speeds up. Seconds pass ... | <p>You have declared <code>setIntID</code> as a local variable in <code>click</code> for the <code>start</code> button, and therefore it isn't cleared in the <code>click</code> function for the <code>stop</code>button.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Why can't an expression be assigned to a PHP member variable by default?<p>The following code produces a fatal error in PHP:</p>
<pre><code>class A {}
class ... | <p>Java and PHP are different. They do things differently, particularly when it comes to the compilation step.</p>
<p>With PHP8.1, you can now use <code>new</code> <a href="https://www.php.net/releases/8.1/en.php#new_in_initializers" rel="nofollow noreferrer">in an initializer</a> which is functionally the same for an ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Can I save Event Grid messages to a file in a storage account?<p>I am new to Azure and am sending events to Event Grid. I'd like to be able to save these mes... | <p>Sure this is possible through Logic Apps. Below is a sample how you can build your flow in your logic apps.</p>
<p><a href="https://i.stack.imgur.com/mODHA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mODHA.png" alt="enter image description here" /></a></p>
<p>Below is the Code-view that you ca... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Laravel Barryvdh\DomPDF Inline block two different height div<p>I have a problem.
I would like make a pdf, but I can not to make a simple flex and items-cent... | <p>Okay, your problem is not really related to either Laravel nor DomPdf (Will adjust your tags :-)).</p>
<p>This is however how you get the 2 elements centered; The center is exactly between the 2 child DIVs, so you might want to adjust that with giving them a certain size, istead of auto.</p>
<pre><code><div sty... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
df.rename does not alter df column names, but df.columns and df.set_axis do (Pandas)<p>I have a pandas dataframe that I want to rename the columns on</p>
<p>... | <p>If you don't want to rename by using the old name, you could <code>zip</code> the current columns and pass in the number of items you want.</p>
<p>If you're using Python 3.7+ then order should be <a href="https://stackoverflow.com/questions/15372949/preserve-ordering-when-consolidating-two-lists-into-a-dict">preserv... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
List azure ad users using java<p>What is the way to connect to azure ad with username and password using java
I use python to print all users of azure direct... | <p><strong>Microsoft Graph</strong> supports all functionality exposed by Azure AD Graph, and Microsoft Graph is recommended.</p>
<p><strong>Install the dependency via Gradle</strong>:</p>
<p>Add the repository and a compile dependency for microsoft-graph-auth to your project's build.gradle</p>
<pre><code>repository... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
subset of a list by first match of a part of the column's name<p>I have a list (L) with several form of AB variable (like AB_1, AB_1_1 ,...), can I have a su... | <p>It is not the best answer, but it is a solution:
First change the name of all columns start with AB... to AB, and then remove the duplicate column names for each data frame in list (L).</p>
<pre><code>for (i in 1:length(L)){
colnames(L[[i]])[grepl('AB',colnames(L[[i]]))] <- 'AB'
L[[i]] <- L[[i]][ , !duplic... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Python transfering names in Pandas dataframe column into a dictionary alphabetically<p>I want to create a dictionary of full names that is sorted by last nam... | <p>Assuming you are using pandas, Here is a quick code for you:</p>
<pre><code>df['l_name_intial'] = df.name.apply(lambda x: x.split(" ")[-1][0])
df2 = df.groupby('l_name_intial')['name'].apply(list)
print(df2)
</code></pre>
<p>Which results in:</p>
<pre><code>l_name_intial
A [V. Aakalu, J.L. Accini, Kimbe... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Warning: Attempt to read property "term_id" on int - Woocommerce<p>I would like to create a condition to manually hide categories within the shop. I already ... | <p>You can I think you should use <code>get_terms_args</code> filter instead of <code>get_terms</code> and just add exclude arg, so now get_terms() function won't retrieve those cats and you'll get right count. Here's code example:</p>
<pre><code>add_filter( 'get_terms_args', 'mamaduka_edit_get_terms_args', 10, 2 );
/*... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to serialize a specific Id in Django?<p>I am using the <a href="https://docs.djangoproject.com/en/3.0/topics/serialization/#djangojsonencoder" rel="nofol... | <p>Use <a href="https://docs.djangoproject.com/en/3.0/ref/models/querysets/#django.db.models.query.QuerySet.filter" rel="nofollow noreferrer"><strong><code>filter(...)</code></strong></a> instead of <strong><code>get(...)</code></strong> methodas</p>
<pre><code>Sample.objects<b>.filter(id=1)</b></code></pre>
<p>ex: <... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to share domain event scheme between microservices?<p>In domain driven design we create bounded contexts. Which means that aggregates don't share a commo... | <p>Each service can have an internal model and you can use a <a href="https://www.enterpriseintegrationpatterns.com/patterns/messaging/CanonicalDataModel.html" rel="nofollow noreferrer">Canonical Data Model</a> for the communication between the services.</p>
<p>It's common to have a separate model used for integration... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Difference Between Using `NpgsqlParameter<T>` and `AddWithValue` with `NpgsqlDbType`<p>The <a href="https://www.npgsql.org/doc/basic-usage.html#strongly-type... | <p>After careful consideration of the input we've received from the community, we have decided to go with <code>NpgsqlParameter<T></code> with an explicit <code>NpgsqlDbType</code>.</p>
<p>While we agree that performance hits are indeed very difficult to notice with both options, the explicitness of declaring wh... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Mounting a Components Library in Vue 3<p>I am new to Vue.js and trying to migrate a Vue.js 2 migration to Vue.js 3. I have read the Vue.js instructions on ho... | <p>On this line:</p>
<pre class="lang-js prettyprint-override"><code>const layoutComponent = app.layoutComponents[layoutComponentName];
</code></pre>
<p>You refer to <code>app.layoutComponents</code>, which is an unknown property of <code>app</code>.</p>
<p>You probably meant</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:
Typescript conditionally optional callback for specific generic<p>I know there are numerous issues on StackOverflow about conditionally optional types in Typ... | <p>The only way I know of to get the compiler to follow your logic is to make the function take a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters" rel="nofollow noreferrer">rest parameter</a> of a <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Populate sheet from primary sheet column with condition<p>I have been trying to resolve in Excel using VLOOKUP and INDEX/MATCH and am hitting a dead end.</p>... | <p>So , this is what I have tried using <code>INDEX()</code>, <code>AGGREGATE()</code> & <code>MATCH()</code> Functions, <strong><a href="https://1drv.ms/x/s!AlEkksoPTc2chT6wkQESRUxaPaRK?e=y2iNSd" rel="nofollow noreferrer">Download_Workbook</a></strong></p>
<p><a href="https://i.stack.imgur.com/Rn11F.png" rel="nofo... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Setting a label background colour to transparent in WinForms make it ignore any images underneath it and displays the form background image instead<p>I'm wor... | <p>That's how transparency works in Windows Forms. It's fake. A transparent control isn't actually transparent and allowing what's behind it to show through. Instead, it just draws a copy of its parent in its own background. If you want a <code>PictureBox</code> to show through a <code>Label</code> then the <code>Label... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How the JVM executes JNI<p>I've been using JNI a bit recently, and I wonder something...
How JNI gets executed?</p>
<p>For example, <code>DefineClass</code>... | <p>Here is the source code of openjdk : <a href="http://Oh%20got%20it.%20I%20looked%20into%20the%20cpp%20file%20which%20implements%20the%20functions%20[link](https://github.com/openjdk/jdk/blob/161333eeba1d4ac163991d6697c24f3a59148b2b/src/hotspot/share/prims/jni.cpp)" rel="nofollow noreferrer">click</a></p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Add a new column that specify multiple columns name that have value<p>I have a dataframe with multiple columns like the following.</p>
<pre><code>df
ID var_1... | <p>You could use <code>apply</code> over rows, and <code>paste</code> the <code>names</code>:</p>
<pre class="lang-r prettyprint-override"><code>df$vars_with_value <- apply(df[, -1], 1, function(x) paste0(names(df[, -1])[x > 0], collapse = " "))
</code></pre>
<p>Or by a similar logic using <code>dplyr</... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to join counts from enumerate() in python?<p>How can I join double/triple/etc.-digit counts from enumerate() to form a single string? I want to iterate t... | <p>A straightforward way to find the zip and replace it with each of multiple other zips would be to use <a href="https://docs.python.org/3/library/re.html#re.search" rel="nofollow noreferrer"><code>re.search()</code></a> and the <a href="https://docs.python.org/3/library/re.html#re.Match.span" rel="nofollow noreferrer... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to filter Django's foreignKey form dropdown<p>I have a form that is used to edit (update) a record, and the <code>Author</code> field is automatically a ... | <p>Since <code>UpdateView</code> inherited also from <code>FormMixin</code>, in your <code>buildQueueEdit</code> you can override <a href="https://docs.djangoproject.com/en/3.0/ref/class-based-views/mixins-editing/#django.views.generic.edit.FormMixin.get_form" rel="nofollow noreferrer">get_form</a>, where form is insta... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is it possible to fill cells in a range with "x" if the number of filled cells in that column can't be divided by 4 using VBA?<p>In a sheet of my workbook I ... | <p>The following will pad the cells with <code>x</code> until there are a multiple of 4 cells populated:</p>
<pre><code>Sub pad_to_mod_4()
Dim myrange As Range
Dim ws As Worksheet
padding = "x"
Set ws = ActiveSheet 'set this to your worksheet
Set myrange = ws.Range(&q... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Flask app giving "Application Error" when hosted on Heroku<p><em>Just a precursor, I've looked at very similar questions on Stack Overflow and tried all the ... | <p>change your procfile to:
<strong>web: gunicorn app:app</strong>
your wsgi.py file can be deleted</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Converting an Array2 to Polar Coordinates<p>I am struggling to convert an Array2 of Cartesian Coordinates to Polar Coordinates. The two columns of each row h... | <p>I would suggest not using an <code>ndarray</code> to store the real and imaginary part of your values but a tuple. This has way less overhead.</p>
<p>For inplace mutation you can use <code>map_inplace()</code>:</p>
<pre><code>use ndarray::{array, Axis};
fn main() {
let mut coords = array![(1_f32, 0_f32), (1. / ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Typescript string dot notation of nested generic type that belongs to property of certain value<p>This question is an extension of the one found <a href="htt... | <p>Your approach, where <code>PathsToProps<T, V></code> generates paths as <a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types" rel="nofollow noreferrer">tuples</a>, and then where <code>Join<T, D></code> concatenates the tuple elements to form dotted paths, is problematic for t... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
ValueProvider Is Null MVC<p>I use this startup class in asp.net MVC 5 (using Microsoft.Extensions.DependencyInjection)</p>
<pre><code> [assembly: OwinStar... | <p>I changed, ApplicationUserManager and ApplicationSignInManager and RoleManager injections to the code bellow and now, everything works:</p>
<pre><code>...
services.AddTransient<ApplicationUserManager>(p => HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>());
...
services.Add... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Save a 3 dimensional array from R to a format to be read by Python numpy<p>I have a 3-dimensional array in R (numerical), which I want to <em>transfer</em> t... | <p>Try reticulate to convert the array from R to python. Then save it using numpy (called from within R). </p>
<pre><code>## inside R
library(reticulate)
x = array(runif(27),dim=c(3,3,3))
# import numpy
np = import("numpy")
np$save("test.npy",r_to_py(x))
</code></pre>
<p>Now we load it with python:</p>
<pre><code>i... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Image fromarray method is not working properly<p>i created a numpy array of size 10 by 10 with</p>
<pre><code>x = np.eye(10, dtype=np.uint8)
[[1 0 0 0 0 0 0... | <p>Do not use "1". Use "L"</p>
<pre><code>im = Image.fromarray(x, mode='L')
</code></pre>
<p>if you really want to use mode "1", you have to encode in bytes. Every bit on each byte is a pixel.</p>
<pre><code>import matplotlib.pyplot as plt
x=np.array(bytes([128,64,32,16,8,4,2,1]))
im = Im... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
apply shade to flutter color variable<p>I have defined a variable that holds a color value and when I setstate the screen, I always change this color. I want... | <p><code>shade100</code> is a getter for <a href="https://api.flutter.dev/flutter/material/MaterialColor-class.html" rel="nofollow noreferrer"><code>MaterialColor</code></a>. You can do</p>
<pre class="lang-dart prettyprint-override"><code> late MaterialColor objeColor;
...
color: objeColor.shade100
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
images appearing in warning but not in table?<p>I am working on a website whereby a load of advertisers are stored in the DB and then displayed to the user b... | <pre><code><?php
session_start();
require_once "config.php";
// Create connection
if ($link === false)
{
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "SELECT * FROM advertisers";
if ($result = mysqli_query($link, $sql))
{
if (mysqli_num_rows($result) &g... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Map Data Based off ID<p>If i'm using the map function, how would you limit it by ID, e.g I only want to map ID 1,2 out of 3 possible datapoints?</p>
<p>What'... | <p>Use <code>for</code> loop.</p>
<pre><code>function SomeComponent() {
const useInputs = [
/*...*/
]
const limit = 2
const userInputDomList = []
for (let i = 0; i < userInputs.length; i++) {
if (limit >= i) break
userInputDomList.push(<div key={userInputs[i].id}> </div>)
}
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Don't understand scipy.optimize.brute syntax<p>I don't understand the syntax of <code>scipy.optimize.brute</code> at all. If I have a list, say <code>[-1, 0,... | <p><a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.brute.html" rel="nofollow noreferrer"><code>scipy.optimize.brute</code></a> <strong>minimizes</strong> a function over a given range.<br>
The error relies in the way you pass the <code>ranges</code> arguments. As stated in the documentation... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to reset and shuffle a "next" iterator?<p>I have a function that generates numbers from -180 to 180:</p>
<pre><code>all_angles = list(range(-180,180))
ra... | <p>Generator endlessly shuffling and yielding:</p>
<pre><code>def endless_shuffling(iterable):
values = list(iterable)
while True:
random.shuffle(values)
yield from values
</code></pre>
<p>Instead of your <code>iter(all_angles)</code>, use <code>endless_shuffling(all_angles)</code> (and remove y... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Enum _missing_ function not silencing ValueError<p>I'm trying to set up an Enum that will return <code>None</code> if the value is not found. The documentati... | <p>The 2 main things that the documentation is missing regarding the <code>_missing_</code> function is the signature in the question, and the fact that the return type MUST be a member of the Enum. If <code>None</code> is returned, then the error simply isn't silenced.</p>
<p>This behaviour is only seen through sourc... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
List Google Cloud resources sorted by time<p>I am listing my compute disks as follows:</p>
<pre><code>▶ gcloud compute disks list
NAME ... | <p>You can use <code>creationTimestamp</code> as a sort parameter :</p>
<pre><code>gcloud compute disks list \
--format="value(name,creationTimestamp)" \
--sort-by=creationTimestamp
</code></pre>
<p>Note that you can sort them by descending order by adding a <code>~</code> in front of <code>creationTimestamp<... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to create Date from data string in typescript (react) where string should be treated as GMT? (code attached)<p>In React/Typescript how can I create a Dat... | <p>Would you want is: new <code>Date(parsedApiDate.setHours(parsedApiDate.getHours() + 10))</code>
Where 10 is options. 10 here is your timezone.</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to use String Value from sheet as a variable name<p>I am working on a minor addition to some code where I just want to use a value on the sheet to give m... | <p>You can do something similar using a collection</p>
<pre><code>Dim WHN As String
Dim Wn_Coll As New Collection
Wn_Coll.Add "Name1", "Wn18"
Wn_Coll.Add "Name2", "Wn6"
Wn_Coll.Add "Name3", "Wn77"
Wn_Coll.Add "Name4", "Wn26"
WHN = Wn_Coll(Range("G2"))
MsgBox WHN
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Where can I find actual link to Wordpress admin ( wp-admin ), when changed by plugin?<p>I have changed ( probably ) my <code>wp-admin</code> url with <a href... | <p>Seems like it's stored in the options table in the DB. the option name is <code>rwl_page</code></p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Reorder groups of values in the column with a new maximum value<p>I have a Pandas dataframe with a column with groups of digits placed in ascending order:</p... | <p>Use <code>groupby</code> to group by each group of monotonic increases, and then do some math do normalize back to the 1-4 range:</p>
<pre><code>MAX_NUMBER = 4
>>> df['column'].groupby((df['column'].diff() < 0).cumsum())\
.apply(lambda s: s//(max(s)/MAX_NUMBER))\
.fillna(0)
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to display an object properties on the page from an array of objects in Ember.js?<p>I have a website that has a list of products when a user clicks on 'A... | <p>You cann access the properties inside the <code>{{#each}}</code> block:</p>
<pre><code>{{#each cart.items as |item|}}
{{item.name}}
{{/each}}
</code></pre>
<p>You <em>could</em> also <code>{{#each-in</code> to loop through all properties:</p>
<pre><code>{{#each cart.items as |item|}}
{{#each-in item as |name ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
AMP for Email Form Component - Is it possible to redirect user to web page?<p>When using the AMP for Email form component, is it possible to redirect the use... | <p>No, it's not allowed. There's a section on this for the AMP for Website format: <a href="https://amp.dev/documentation/components/amp-form/#redirecting-after-a-submission" rel="nofollow noreferrer">https://amp.dev/documentation/components/amp-form/#redirecting-after-a-submission</a>, but notice that the section is n... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Option Base 0 and creating an Array from a Range<p>I am creating an arrays from a range of cells in Excel. All works, array is created. The problem is i use ... | <p><em>Is there any way to read an Array from a range with first element with number 0?</em></p>
<p>No</p>
<p><em>is there any possibility to read an array from a range as a "Boolean" or "Integer" instead of "Variant"?</em></p>
<p>No</p>
<p>Where <code>SomeRange</code> references a contiguous range of >1 cells, <co... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do I stop Visual Studio from Inserting Namespaces into the Designer Code<p>This is driving me to distraction and I can't stop it from happening.</p>
<p>I... | <p>I still have no idea why the issue occurred, however, I moved my project from VS 2017 to VS 2022 and it fixed it. Go figure!</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Session.SetString method throws exception "IFeatureCollection has been disposed. Object name: 'Collection'. " in ASP.NET Core 3.1<p>I have a project written ... | <p>An HttpContext is the context of a single request. It provides access to the request, response properties etc of that single request. You can't cache it, it becomes invalid once that request ends. </p>
<p>Session is another transient thing - it lives only as long as a single user session. There's at least one sessi... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do I extract full entity names from a hugging face model without IO tags<p>I am using a model from hugging face, specifically <code>Davlan/distilbert-bas... | <p>There is a bug in the code. The aggregation strategy is in the wrong place. It should read:</p>
<pre><code>from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
tokenizer = AutoTokenizer.from_pretrained("Davlan/distilbert-base-multilingual-cased-ner-hrl"... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to create custom back button in navigationBar in swift?<pre><code>public override func viewDidLoad() {
super.viewDidLoad()
navigationItem.backBar... | <p>You should be able to change the back button image <strong>globally</strong> by using</p>
<pre><code>UINavigationBar.appearance().backIndicatorImage = UIImage(named: "arrow-back")
UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage(named: "arrow-back")
</code></pre>
<p>And if ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I efficiently search for multiple adjacent elements in a std::set?<p>I have a set containing a sortable data type. I need to be able to search to fin... | <p>Something along these lines, perhaps. This relies on the capability, added in C++14, of <code>std::set::equal_range</code> et al to perform heterogeneous searches, given a comparator that has overloads for combinations of different types.</p>
<pre><code>template<typename A, typename B>
class overall_type {
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Target pseudo-class not hidden content<p>I'm trying to do an horizontal menu: when the user clicks (or tap) on one option, the content appears below the menu... | <p>It looks like you could just add another CSS rule for each type of tag you want to hide. Something like this:</p>
<pre><code>div.items hr:not(:target), div.items p:not(:target) {display: none}
div.items hr:target, div.items p:target { display: block; }
</code></pre>
<p>Just add as many rules as you need. Better ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Instantiation of QAxObject from dumpcpp segfault with minGw C++ -o2 or -o3 flag<p>Qt version: 5.12.10</p>
<p>I wanted to interface with an application using ... | <p>The mistake was on me.</p>
<p>After getting the IUnknown * from the COM, we have to get a IDispatch * from it and then instantiate directly the classes:</p>
<pre class="lang-cpp prettyprint-override"><code> //Initialize COM, load the ROT, get the monikers and for each monikers
//Check if the monikers name is the ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to get an item after mapping through an array<p>im trying to loop through my students array ( array of items of type Student) and then calculate the aver... | <p>You're passing <code>Student</code> as second argument to <code>map</code> for some reason. </p>
<p>The <code>map</code> function takes only two arguments: a function to apply to every element of a list and the list itself. But you're trying to pass it three arguments: first argument <code>calculateAverage</code>, ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Node-Red: Parse JavaScript Object with Double value<p>I am using node-RED to call in data from a robot. In the debug window it says it is a 'msg: Object', an... | <p>After the node that gets the above information (the data in {} in the question}, I then used the function node to construct the message that I wanted to sent to the IIOT platform. I did</p>
<pre><code>const str = msg.payload
msg.payload = " ," + str
// where the text I required was in " "
return ... |
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 shift multiple rows from pandas dataframes with different lengths?<p>I have a pandas dataframe that looks like the image attached
<a href="... | <p>Use <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.startswith.html" rel="nofollow noreferrer"><code>Series.str.startswith</code></a> to detect Well columns ,<strong>cols_Well</strong> in example (this step could be omitted and select columns yourself).</p>
<p>Then we can calcu... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
check if file exists for multiple files in different directories<p>I am creating bash script and everything works fine except for this:</p>
<pre><code>read ... | <p>You can't substitute the array into the filename, you need to loop over the array.</p>
<pre><code>read -p "Write directory names:" -a dirs
for dir in "${dirs[@]}"; do
for f in "/home/user/downloads/$dir/"*.zip; do
if [ -f "$f" ]
then
# do something
else
# do somet... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Having trouble lerping a game object back and forth<p>I have this hand icon that I want to move back and forth. So far I have it set up inside a coroutine li... | <p>Where are you resetting the elapsedTime?</p>
<p>You don't need a Coroutine to move the object back and forth. You can just check if your percentageComplete variable is equal to 1 and swap the start and end point. Also reset the elapsed time.</p>
<p>Source: <a href="https://vionixstudio.com/2021/11/03/how-to-lerp-in-... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Django admin Add form - Limit number of displayed Model by foreign key when date is within range<p>Consider I have the below simple model:</p>
<pre><code>cl... | <p>use <code>raw_id_fields</code> in your admin config to prevent loading all objects</p>
<pre class="lang-py prettyprint-override"><code>@admin.register(models.MyModel)
class MyModelAdmin(admin.ModelAdmin):
raw_id_fields = ('dateid',)`
</code></pre>
<p>it shows up like bellow and you can select object when click... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Error importing "Esri.ArcGISRuntime" to Qt Creator<p>After running the code an error came:
QQmlApplicationEngine failed to load component
qrc:/main.qml:19:1:... | <p>I will summarise the issues discussed in the comment thread to bring to an end.</p>
<ol>
<li><p>Use Qt 5.15 these days and preferably always the latest bug fix release. Which is currently 5.15.5 for open-source, and not commercial, customers at the time of writing this. Even better to switch to 6.x when possible.</p... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Getting indices of a sorted list of lists in Python<p>I have a list of lists called <code>test</code> and I am trying to get the array locations when the ele... | <p>I hope I've understood your question right. You can <em>flatten</em> your list to a list with indices and then sort it (assuming the <code>test</code> isn't pre-sorted):</p>
<pre class="lang-py prettyprint-override"><code>test = [[1, 2], [3, 4]]
out = [
l
for _, l in sorted(
((v, [i, j]) for i, l in... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to use SqlBulkCopy to write an IAsyncEnumerable<p>I have the following method that returns an <code>IAsyncEnumerable<T></code>:</p>
<pre><code>asy... | <p>using the example <a href="https://www.codeproject.com/Articles/1095790/Using-SqlBulkCopy-with-IDataReader-for-Hi-Perf-Ins" rel="nofollow noreferrer">here</a>, I've come up with an IDataReader that takes a IAsyncEnumerable, and implements the appropriate portion of the interface.</p>
<pre><code>public class Generic... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to draw a rectangle in wxwidgets?<pre><code>#include "wx/wx.h"
class MyFrame : public wxFrame{
public:
MyFrame();
~MyFrame();
priva... | <p>There are multiple issues with the code posted, but I'll restrict this answer to the question that was asked. If you want to draw a rectangle on the applications frame, you need to </p>
<ol>
<li>declare the OnPaint method in the frame class, and</li>
<li>alter the event table macro to set the OnPaint method to han... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
ajax highchart. how to passing data to highchart?<p>this is my query on my controller. I want to register participants every year. I got the year and the dat... | <p>Use array and response json in your controller and each loop in your front js.</p>
<p><strong>Controller:</strong></p>
<pre><code>$data['chart'] = array([
'status' => 200,
'tahunan' => $value_an_year,
'tahun' => $years,
'message' =&g... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Kivy ScrollView trys to scroll, but bounces back evert time<p>So I have a ScrollView inside a GridLayout, but my Scroll view wont scroll. it moves to reveal ... | <p>Although your guess about <code>self.size_hint_y = None</code> is right but setting <code>self.height = self.minimum_height</code> in <code>__init__</code> is not. Because during initialization the default values are applied. So what you need to do is, make the layout listen to any changes whenever any widget gets a... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to save Unicode or Nature Language text to the MySQL database in vb.net<p>Code is working but updated Unicode words show ??????? mark. How to fix this fa... | <p>Finally, I got answer. Inserting the character set to the Connection String</p>
<pre><code> Character Set=utf8;
</code></pre>
<p>Like this</p>
<pre><code>Public Function Mysqlconnection() As String
conn = New MySqlConnection("server=" & server & ";user=" & user & ";pw=" & password &... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Double footer on vue-boostrap table component<p>I would like to implement a double footer for a bootstrap-vue table.</p>
<pre><code><b-table
striped ... | <p>You can use the <code>custom-foot</code> slot. This slot will render directly into the <code>tfoot</code> of the table, so you have free control to structure the foot however you want using <code>tr</code> and <code>td</code></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-bab... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Discord.py bot can't read my messages except if mention is included<p>So, my bot was working normally umtil this happened. It didn't respond to my commands s... | <p>I believe the issue here is your intents. Try changing your intents from <code>discord.Intents.default()</code> to <code>discord.Intents.all()</code> and make sure your bot has the appropriate permission in the discord developer portal.</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Django show message in every view<p>I want to show a message in every view in my Django project. Once a user has created an account, I send them an email ask... | <p>You can achieve this by simply creating context processor and can check user is verified or not. According to it you can pass some context to your template.
Like:</p>
<pre><code>def myContextProcessor(request):
return {
"is_loggedIn": True
}
</code></pre>
<p>and register it in <code>settings.py</cod... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to correctly iterate over a pandas column considering a slice of values on Python?<p>I happen to have the following information stored in a variable call... | <p>Another sollution, using <code>.rolling</code>:</p>
<pre class="lang-py prettyprint-override"><code>for d in df["Open Price"].rolling(4):
if len(d) != 4:
continue
print(d, "\n")
</code></pre>
<p>Prints:</p>
<pre class="lang-none prettyprint-override"><code>0 0.00001241
1 0.0... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Custom Compiler Warning To Remind To Use Method<p>I have written an extension method on <code>ILogger</code> and need the complier to emit warning to use tha... | <p>Here are some ideas:</p>
<ol>
<li>Don't do it. Logs should identify themselves by the message/eventid. You don't need to know the line numbers - these can change over time anyway.</li>
<li>Setup your DI to return a logger that does the extra logging.</li>
<li>Setup the context in the constructor (this will not give ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
object-literal-sort-keys needs type info to use "match-declaration-order" or "match-declaration-order-only"<p>In my <code>tslint.json</code> I have <code>obj... | <p>The option <code>"match-declaration-order"</code> for the <a href="https://palantir.github.io/tslint/rules/object-literal-sort-keys/" rel="nofollow noreferrer">object-literal-sort-keys</a> rule requires tslint to have type information, since it needs to check object literal against their defined type. To ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Update reusable Label widget in Kivy using Clock.Interval<p>I'm developing a multiple page Kivy app that I want to have a clock widget in several pages. I wa... | <p>The problem is that the ClockWidget created in the build method is different from the ClockWidget created as a child of BoxLayout in the .kv, in your case only the Clock only calls the update_clock method of the first.</p>
<p>On the other hand I see it unnecessary to create a new StringProperty in ClockWidget since... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Coloring pivot table pandas dataframe<p>I have a pivot table created using pandas which looks like below:</p>
<pre><code>**Account** AA-PRD AB-PRD AC-PRD ... | <p>You can create DataFrame of styles with <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.io.formats.style.Styler.apply.html" rel="nofollow noreferrer"><code>Styler.apply</code></a> and set rows by masks with <code>loc</code>:</p>
<pre><code>def color(x):
c1 = 'background-color: yellow'
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
using a single Dynamodb resource in terraform and create 3 tables with different names<p>I have a used case where,
I need to create 3 dynamodb tables but onl... | <p>If the only difference is in name, then you can do:</p>
<pre><code>variable "names" {
default = ["MN_SKU_COLOR", "GB_SKU_COLOR", "CH_SKU_COLOR"]
}
resource "aws_dynamodb_table" "table" {
for_each = toset(var.names)
name ... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Tibble select word and add column<p>I have a list of word and phrases and I would like create a DB that select that word and add in a column, not delete but ... | <p>You could use <code>regmatches</code> like this:</p>
<pre class="lang-r prettyprint-override"><code>DB <- data.frame(heading_1 = c("Hello world", "Say world", "Say something"))
DB
#> heading_1
#> 1 Hello world
#> 2 Say world
#> 3 Say something
list_of_words &l... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
CMake is successful, but make fails when linking<p>I am trying to compile my project on macOS with CMake. I have gstreamer installed via brew and I can acces... | <p>The error:</p>
<pre><code>ld: library not found for -lgstreamer-1.0
</code></pre>
<p>indicates that the library <code>gstreamer-1.0</code> was passed to the linker, but the linker doesn't know where to find it (likely because it does not reside in the typical system paths). It is up to CMake to provide the <strong... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
HTML enclose text with no extra whitespace in div tag<p><strong>Disclaimer: I am decently new to HTML.</strong> I know this is (most likely) going to be mark... | <p>the <code>border</code> will always be surrounding the element <code>width</code> and <code>height</code> including the <code>padding</code>. change the <code>width</code> of the form and if you want it to align to the right use:</p>
<pre><code>form {
width: 30%;
margin-left: auto;
}
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Replace child name by concatenating its parent name, move up at level of parent, and remove the parent element using Ling to Xml<p>I have this original Xml:<... | <p>Your primary issue is that your <code>.Nodes()</code> list is changing while you are enumerating it. You need to use <code>.ToList</code> or <code>.ToArray</code> on it.</p>
<p>It feels like you are over-complicating this anyway. You can just remove each child node, rename it, and add back as a sibling of its parent... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Chatwoot - Send attachments - NodeJS<p>I need help with something... I'm trying to send files through the ChatWoot API but I'm not able to do it...</p>
<p>I'... | <p>I have also faced this same issue ironically and in the end I had to use Axios to get a successful form post to Chatwoot (self-hosted), here is the working code I am using. While I did not see any error in your code I hope this snippet helps as it was the only way I got to work after a day of tinkering.</p>
<pre><co... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Mongo DB aggregate grouping multiple values that belong to the same document<p>I have documents that look like this</p>
<pre><code>{
"_id": "5e3334cede31d95... | <p>You need to add extra field into <code>$group</code> and <code>$project</code> stages.</p>
<p>You need to use <code>$max</code> operator for <code>time</code> field and accumulate<code>tests</code> field <code>time:tests</code> values. In the last stage, we <code>$reduce</code> <code>tests</code> field taking highe... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I select a checkbox based on the class of a parent node?<p>I have a table with checkboxes as the value in one of the columns. Certain rows have a spe... | <p>Something like this should work:</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>$('tr:not(.ignore) :checkbox').prop('checked', true);</code></pre>
<pre class="snippet-code... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to strikethrough Japanese text using unicode characters<p>Please take a look at this jsfiddle:</p>
<p><a href="https://jsfiddle.net/darrengates/c5mwohb7/... | <p>It does not appear that there is a simple Unicode solution to this issue. Using HTML's (or ) appears to be the best approach. As @skomisa noted in his comments, "text-decoration-style: double" is advisable when doing strikethrough with Japanese.</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Add input fields on button click with data from PHP<p>I'm trying to add input fields on button click everything I working as it should, but need to do 3 thin... | <p>The issues 2 y 3 are pretty straightforward. You just need to decrement the variable <code>i</code> when removing a member. Also, don't allow to create new ones when <code>i>=7</code>. </p>
<p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
<div class="snippet-code sn... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to Prevent on Uploading Duplicated Image(s) to Preview before Upload<p>How can I stop loading to preview of files which are already listed in the preview... | <p>One possible solution is using array of files and prevent adding duplicate files into this array using filename, something like this:</p>
<p><em>untested code</em></p>
<pre><code>// send this to the server
var files = [];
function readImage(file) {
var reader = new FileReader();
var image = new Image();
... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Unit Testing the SEQUENCE of values emitted from a single livedata<p>I want to unit-test the sequence of a LiveData's results. I have a <code>result</code> L... | <p>Yes, it's possible, I'll include an example which is using the <a href="https://github.com/mockk/mockk" rel="nofollow noreferrer">mockk</a> library. Let's say that you have a ViewModel and a LiveData<Your_type_here> <code>result</code>. You have to add a mocked observer (androidx.lifecycle.Observer) which valu... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Data consistency with MongoDB<p>What options are there to ensure that changes on documents in a MongoDB are not lost in case of a system that works as follow... | <p>An approach that immediately comes to mind is versioning your documents.</p>
<p>Let each document have a field <code>version</code> with, say, integer values.</p>
<ul>
<li>Worker 1 reads a document and sees that its version is <code>5</code>.</li>
<li>Worker 2 reads this same document.</li>
<li>Worker 1 completes ca... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Change text size of all point on a line chart in Chart.js 3.x version<p>I want to change the text size of a all point on a line chart in Chart.js.
my code:</... | <p>You could change the font options of DataLabels plugin.</p>
<pre><code>datalabels: {
font: {
size: 30
},
align: 'top',
anchor: 'end'
}
</code></pre> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do I print a shuffled order of strings that never repeat? ARDUINO<p>I'm trying to make a scramble generator for the rubik's cube, every letter correspond... | <p>You can put the moves in an array and then shuffle the array:</p>
<pre class="lang-c++ prettyprint-override"><code>const char *moves[] = {"R ", "L' ", "B' ", "D2 ", "F ", "U2 "};
const int num_moves = sizeof(moves) / sizeof(moves[0]);
// Shuffle
for (int i... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Why I can use a function to set a table index using arguments but i can't set a varble passed as a parameter<p>im new to lua (and programming )
I would like ... | <p>From the <a href="https://www.lua.org/manual/5.4/manual.html#2.5.1" rel="nofollow noreferrer">Lua manual</a>:</p>
<blockquote>
<p>Tables, functions, threads, and (full) userdata values are objects:
variables do not actually contain these values, only references to
them. Assignment, parameter passing, and function re... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Styling imported from svelte style tag stays when moving back to old page<p>Two of my svelte kit pages have similar styling, so i extracted it to a scss file... | <p>I would recommend not using <code>:global</code> without scoping it first, otherwise those rules really should apply globally.</p>
<p>If you have multiple pages that should use the style, you could define a class to be used as indicator on some root container and only use <code>:global</code> within that scope if re... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
ASP.NET Core Failed AJAX Post Request<p>I've been trying to pass an object of information to .NET Core Controller method. Passing a single string and receivi... | <p>Try setting the <code>Content-Type</code> header on your AJAX request, you can see it is present in your Fiddler request.</p>
<pre><code>$.ajax({
...
contentType: 'application/json'
...
});
</code></pre>
<p>The default content type for <a href="https://api.jquery.com/jquery.ajax/" rel="nofollow noreferrer">j... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Headless debugging on Windows<p>There is a bug that I would like to fix that only occurs on Windows Server without a GUI running. I have set up a Windows Ser... | <p>MS has 2 console debuggers called <a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugging-using-cdb-and-ntsd" rel="nofollow noreferrer">CDB and NTSD</a> so you don't actually need Visual Studio GUI to do the debugging. In fact there are a lot of <a href="https://docs.microsoft.com/en-us... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to prevent a group of buttons from wrapping in the mui?<p>Excepted result:
<a href="https://i.stack.imgur.com/dOXRQ.png" rel="nofollow noreferrer"><img s... | <p>You can use <code>flex: none;</code> on the buttons.</p>
<pre><code><Box
sx={{
display: "flex",
justifyContent: "space-between",
marginTop: 2,
width: "100%",
overflowX: "scroll",
button: {
flex: "none"
}
}}
>
<Button v... |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Problem with "nuget restore" with some lib's in build azure Pipeline<p>I am using netcoreapp3.1 and everything works with the command dotnet restore and dotn... | <p>I was using the wrong Agent Specification, the correct would be windows-2019 I was using windows-2017</p> |
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Where clause in a calculation<p>Say I have this table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>month</th>
<th>num_of_fru... | <p>If you want to check other rows in the table, you will likely want either a subquery in your <code>SELECT</code> or to join the table to itself.</p>
<p>I think you are probably trying to do:</p>
<pre><code>SELECT
harvested - (num_of_fruits - (SELECT num_of_fruits FROM mytable t2 WHERE t2.month = date_trunc('month',... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.