question_id
int64
37.6M
73.2M
input_text
stringlengths
88
52.4k
output_text
stringlengths
37
35.6k
title
stringlengths
15
150
tags
stringlengths
1
107
q_score
int64
-19
397
view_count
int64
3
879k
answer_count
int64
1
21
accepted_answer_id
int64
37.6M
73.8M
answer_id
int64
37.6M
73.8M
a_score
int64
-5
1.29k
is_accepted
bool
1 class
creation_date
stringlengths
20
24
input_text_instruct
stringlengths
251
52.6k
72,807,629
Overestimated Monte Carlo results in brightway<p>I am running a Montecarlo simulation on ecoinvent v 3.8 consequential system model and when randomly sampling the activity <em>market for waste paper, sorted' (kilogram, GLO, None)</em> I get very unrealistic and overestimated results.</p> <pre><code>myact = bw.Database(...
<p>An excellent question, not easy to answer, but you can find my workings here:</p> <p><a href="https://github.com/brightway-lca/brightway2/blob/master/notebooks/Investigating%20interesting%20Monte%20Carlo%20results.ipynb" rel="nofollow noreferrer">https://github.com/brightway-lca/brightway2/blob/master/notebooks/Inve...
Overestimated Monte Carlo results in brightway
brightway
1
67
1
72,821,344
72,821,344
1
true
2022-06-29T20:43:29.260Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Overestimated Monte Carlo results in brightway<p>I am running a Montecarlo simulation on ecoinvent v 3.8 consequential system model and when randomly samplin...
72,926,989
how to implement trait futures::stream::Stream?<p>So I'm getting a Response from the reqwest crate and passing it to a HttpResponseBuilder from the actix_web create. However I've tried and failed to understand how to implement the Stream trait from the futures create on a custom struct to act as a middleman and copy th...
<p>This is possible but requires you to understand what <a href="https://doc.rust-lang.org/std/pin/index.html" rel="nofollow noreferrer">pinning</a> is and how to use it safely.</p> <p>Basically, we just need to proxy to <code>self.stream.poll_next()</code>, but this method accepts <code>Pin&lt;&amp;mut Self&gt;</code>...
how to implement trait futures::stream::Stream?
rust
1
67
1
72,927,429
72,927,429
1
true
2022-07-10T08:00:02.463Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to implement trait futures::stream::Stream?<p>So I'm getting a Response from the reqwest crate and passing it to a HttpResponseBuilder from the actix_web...
73,019,624
Sql distinct group of rows<p>In sql i want get distict sets of rows : identical group for Characteristic and Value only one time :</p> <p>The column Characteristic can range from one to 10</p> <p>Table :</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">Name</th> ...
<p>You can use <code>STRING_AGG</code> to join all the characteristics together, then use <code>ROW_NUMBER</code> and <code>DENSE_RANK</code> to count them. Then you re-join that back to the base table.</p> <p>For your first query, you can do it like this.</p> <pre class="lang-sql prettyprint-override"><code>SELECT G...
Sql distinct group of rows
sql|sql-server
-1
67
1
73,021,276
73,021,276
1
true
2022-07-18T08:50:48.407Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Sql distinct group of rows<p>In sql i want get distict sets of rows : identical group for Characteristic and Value only one time :</p> <p>The column Charact...
73,025,655
how to call function in django template using conditionals<p>I have a model for Group:</p> <pre><code>class Group(models.Model): leader = models.ForeignKey(User, on_delete=models.CASCADE) name = models.CharField(max_length=55) description = models.TextField() joined = models.ManyToManyField(User, blank=True...
<p>For this, you might want to perform ac check in your join function prior to adding the user and after adding the user. This way, if the group is full, you can return that to the view, or if the user is the last to join the group, you can then close it. something like this may work:</p> <pre><code>def check_group(gro...
how to call function in django template using conditionals
django|django-views|django-templates|django-postgresql
1
67
2
73,026,291
73,026,291
1
true
2022-07-18T16:30:46.010Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to call function in django template using conditionals<p>I have a model for Group:</p> <pre><code>class Group(models.Model): leader = models.ForeignKe...
72,798,092
Replacing values in yml file using yq - invalid key reference<p>I am currently working with editing/modifying yml files. I am a bit new using yq and unsure if I am going overboard using the tool. I am trying to replace two values in the yaml file with two environment values(linux system) as shown below. I am getting an...
<p>With <a href="https://github.com/mikefarah/yq" rel="nofollow noreferrer">mikefarah/yq</a>, it is relatively straightforward to just import the environment variables to the local context and update the required YAML elements</p> <pre class="lang-none prettyprint-override"><code>k=&quot;$APP_KEY&quot; n=&quot;$APP_NAM...
Replacing values in yml file using yq - invalid key reference
awk|sed|yaml|yq
0
67
2
72,803,745
72,803,745
1
true
2022-06-29T08:23:13.157Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Replacing values in yml file using yq - invalid key reference<p>I am currently working with editing/modifying yml files. I am a bit new using yq and unsure i...
72,904,745
query to find the maximum gap between dates<p>I have a table with the name of each customer and date columns and want to write a query to give me the number of gap days for each user,</p> <pre><code>name date ali 2022-01-01 ali 2022-01-04 ali 2022-01-05 ser 2022-03-01 </code></pre> <p>the answer should be 3 for ali and...
<p>One approach to achieve this is using a window function (like lag, lead) to find the prior/next day and then find the difference between the dates (current and prior, for example ) using datediff function. Something like this..</p> <pre><code>SELECT name, MAX(datediff(date, PreviousDate)) AS Gap FROM (SELECT ...
query to find the maximum gap between dates
sql|database|apache-spark-sql
0
67
2
72,905,281
72,905,281
1
true
2022-07-07T22:09:45.390Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: query to find the maximum gap between dates<p>I have a table with the name of each customer and date columns and want to write a query to give me the number ...
72,932,769
AsyncImage. Cannot use switch statement in Phase closure?<p>When I use switch statement in phase in asyncImage it gave me this error.</p> <blockquote> <p>Trailing closure passed to parameter of type 'CGFloat' that does not accept a closure</p> </blockquote> <p>I understand that docs uses if let statements to extract t...
<p>you can use a switch statement, use this, works for me:</p> <pre><code>case .failure(_): // &lt;-- here </code></pre> <p>Here is the code I used to show that my answer works:</p> <pre><code>struct ContentView: View { @State private var stringURL = &quot;https://upload.wikimedia.org/wikipedia/commons/e/ef/...
AsyncImage. Cannot use switch statement in Phase closure?
swift|xcode|swiftui|swiftui-asyncimage
0
67
1
72,933,073
72,933,073
1
true
2022-07-11T00:35:29.090Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: AsyncImage. Cannot use switch statement in Phase closure?<p>When I use switch statement in phase in asyncImage it gave me this error.</p> <blockquote> <p>Tr...
72,983,950
SwiftUI List Multiple Selection Data Model<p>I have a list of data objects that the user can select from a list. It's a multiple selection type of list. Typically you add a bindable Set to the List view initializer to allow multiple selection.</p> <p><a href="https://i.stack.imgur.com/3DUDw.png" rel="nofollow noreferre...
<p>If it is needed only in view, then we can have property to selection, like for List, but work with it directly.</p> <p>Here is a sketch of idea (provided code is not enough to prepare working demo)</p> <pre><code>struct OP1PrincipleListView: View { // The model feeds data to a published array. @ObservedObjec...
SwiftUI List Multiple Selection Data Model
list|swiftui|data-modeling
1
67
1
72,984,229
72,984,229
1
true
2022-07-14T16:40:45.230Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: SwiftUI List Multiple Selection Data Model<p>I have a list of data objects that the user can select from a list. It's a multiple selection type of list. Typi...
72,770,722
Time format is not recognized in snowflake<p>I have a table field in below format in snowflake. While trying to_date(), to_timestamp() function, its erring out with error message as - Timestamp '8/05/2018 9:03:53 PM' is not recognized.</p> <p>Format - '8/05/2018 9:03:53 PM'</p>
<p>Specify the format in the TO_TIMESTAMP as follows:</p> <p><code>to_timestamp('8/05/2018 9:03:53 PM','MM/DD/YYYY HH12:MI:SS AM') -- assumes MM/DD/YYYY</code></p> <p>or</p> <p><code>to_timestamp('8/05/2018 9:03:53 PM','DD/MM/YYYY HH12:MI:SS AM') -- assumes DD/MM/YYYY</code></p>
Time format is not recognized in snowflake
datetime|snowflake-cloud-data-platform
0
67
2
72,772,497
72,772,497
1
true
2022-06-27T10:38:40.377Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Time format is not recognized in snowflake<p>I have a table field in below format in snowflake. While trying to_date(), to_timestamp() function, its erring o...
72,981,995
Powershell Recursive copying and pause between each file is copied<p>I have the following script to recursive copy data and create a log file of the destination, could any assist please, I would like to pause for 10 seconds after each file is copied so each file allocated a different created time stamp.</p> <pre><code>...
<p><code>Copy-Item</code> has a <code>-PassThru</code> parameter that outputs each item that is currently processed. By piping to <code>ForEach-Object</code> you can add a delay after each file.</p> <pre class="lang-sh prettyprint-override"><code>Copy-Item -Path $SourcePath -Destination $TargetPath -recurse -Force -Pas...
Powershell Recursive copying and pause between each file is copied
powershell|script|copy-item
1
67
2
72,984,002
72,984,002
1
true
2022-07-14T14:14:46.620Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Powershell Recursive copying and pause between each file is copied<p>I have the following script to recursive copy data and create a log file of the destinat...
72,932,808
How can I filter array while typing<p>Like with my solution, I have to type &quot;Back-End Developer&quot; to get filter results. Can I just show results while typing &quot;back&quot; or &quot;backend&quot;? Even if I don't type the &quot;-&quot; filter doesn't work.</p> <p>I guess I have to use <code>some</code> and <...
<p>Do not need to use the <code>===</code> operator just use the <code>includes</code> method</p> <pre><code> useEffect(() =&gt; { if(positions.length &gt; 0) { let newList = [...positions]; if(searchTerm) { newList = newList.filter(i =&gt; i.position.toLowerCase().includes(searchTerm.toLowerCase())...
How can I filter array while typing
reactjs|typescript|next.js
0
67
1
72,932,848
72,932,848
1
true
2022-07-11T00:46:31.773Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How can I filter array while typing<p>Like with my solution, I have to type &quot;Back-End Developer&quot; to get filter results. Can I just show results whi...
72,945,594
Count the people in the entire chain of command<p><a href="https://stackoverflow.com/questions/2340696/counting-number-of-children-in-hierarchical-sql-data">Counting number of children in hierarchical SQL data</a></p> <p>This post counts direct reports at each level, but I am wanting to count the complete subordinate c...
<p>Updated logic:</p> <p>Start the search from all nodes (each as a separate root) and find all children of each root. Set (n = 0) for the root node and (n = 1) for each child of that root. Once done, just SUM(n) over each root. We could also COUNT(*)-1 without needing n (this solution also shown below).</p> <p>Here...
Count the people in the entire chain of command
sql|common-table-expression
0
67
1
72,946,047
72,946,047
1
true
2022-07-11T23:28:26.293Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Count the people in the entire chain of command<p><a href="https://stackoverflow.com/questions/2340696/counting-number-of-children-in-hierarchical-sql-data">...
73,017,221
Why are my list items not being displayed on listView (Android)<p>I have created one listview where I want to retrieve the items from sqlite database. So I have created one method as a List named as <code>getrequestitems</code> where I will map the details and add to a arraylist.</p> <pre class="lang-java prettyprint-o...
<blockquote> <p>But When I open that activity It doesn't displayed any records. I have debug the code but can't any exception. I have written wrong query?</p> </blockquote> <p><strong>probably</strong> as it appears that you are very likely comparing the anecdotal <em>oranges and apples</em> (see explanation/example) t...
Why are my list items not being displayed on listView (Android)
java|android|android-listview|android-sqlite
0
67
1
73,030,825
73,030,825
1
true
2022-07-18T04:08:36.680Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why are my list items not being displayed on listView (Android)<p>I have created one listview where I want to retrieve the items from sqlite database. So I h...
72,854,907
Take previously viewed products only<p>I store events such as view, cart, purchase etc. for my products. Now I would like to take only products which were viewed before purchase.</p> <p>I can't come up with an idea how to do it in omptimal way.</p> <p>Here is my table structure below</p> <div class="s-table-container">...
<p>You can use a subquery to get the <code>event_type</code> value before the last one.</p> <p>Here is what the query might look like</p> <pre><code>SELECT id, user_id, product_id, event_type, event_time FROM ( SELECT id, user_id, product_id, event_type, event_time, LAG(even...
Take previously viewed products only
sql|postgresql
0
67
2
72,855,539
72,855,539
1
true
2022-07-04T09:58:33.973Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Take previously viewed products only<p>I store events such as view, cart, purchase etc. for my products. Now I would like to take only products which were vi...
72,921,003
Why does RegOpenKeyExA fail to open a key path with a space in the name?<p>Why does <code>RegOpenKeyExA</code> throw a path not found error according to the error codes from Microsoft <a href="https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-" rel="nofollow noreferrer">docs</a></p> <p>othe...
<p><code>RegOpenKeyEx()</code> allows spaces just fine. MANY Registry keys have spaces in their names.</p> <p>Error 2 is <code>ERROR_FILE_NOT_FOUND</code>, which means the key you are trying to open does not exist. And indeed, the <code>Windows Defender</code> key does not exist in <code>HKEY_CURRENT_USER</code>, it ...
Why does RegOpenKeyExA fail to open a key path with a space in the name?
c++|winapi|registry
1
67
1
72,923,894
72,923,894
1
true
2022-07-09T11:31:47.560Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why does RegOpenKeyExA fail to open a key path with a space in the name?<p>Why does <code>RegOpenKeyExA</code> throw a path not found error according to the ...
72,951,157
Image gallery not show after request access permission<p>i try to show image gallery after user permission to allow all photos, but the gallery is not showing. but when i back to previous controller and navigate back, the gallery show up. but that's not what i want, i want after user allow the image show up.</p> <p>thi...
<p>The way that <code>UICollectionView.rx.items</code> works is that it observes its dataSource. When the dataSource emits a new array, the items operator will reload the collection view and call its closure for each item.</p> <p>Since you are using <code>just</code> as your data source, only one array is emitted and t...
Image gallery not show after request access permission
swift|rx-swift|phphotolibrary
1
67
1
72,966,207
72,966,207
1
true
2022-07-12T10:55:44.567Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Image gallery not show after request access permission<p>i try to show image gallery after user permission to allow all photos, but the gallery is not showin...
72,774,203
How to bind and display a set of colors in WPF listview?<p>Im struggling with a problem that might seem easy first: I want to display some grid with different colors. I have a listview that is binded to a list. The list containst Colors (i have tried SolidColorBrush as well). The listview can display the elements, so i...
<p>You would use a SolidColorBrush as value of the Setter:</p> <pre><code>&lt;Setter Property=&quot;Background&quot;&gt; &lt;Setter.Value&gt; &lt;SolidColorBrush Color=&quot;{Binding}&quot;/&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; </code></pre> <p>Besides that, the ControlTemplate must also use the ...
How to bind and display a set of colors in WPF listview?
c#|wpf|xaml|listview|binding
0
67
2
72,774,566
72,774,566
1
true
2022-06-27T14:56:36.090Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to bind and display a set of colors in WPF listview?<p>Im struggling with a problem that might seem easy first: I want to display some grid with differen...
72,903,837
How to convert Hex to binary in C and output binary as a char array?<p>I'm trying to write a function that converts hex char into binary array so it's easy to read all the ones and zeros one by one. Am having problems with the code. I currently have written the code below. It gives me an error saying that it returns an...
<p>There are 2 major problems in your code:</p> <ul> <li><code>char output[] = &quot;&quot;;</code> defines an array of <code>char</code> just large enough to hold the empty string. For you purpose, you should allocate an array with a size <code>4 * strlen(input) + 1</code></li> <li><code>return output;</code> returns ...
How to convert Hex to binary in C and output binary as a char array?
arrays|c|binary|char|hex
1
67
2
72,903,982
72,903,982
1
true
2022-07-07T20:25:11.877Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to convert Hex to binary in C and output binary as a char array?<p>I'm trying to write a function that converts hex char into binary array so it's easy t...
72,877,967
How to get datatypes of each row using pandas?<p>I have a dataframe that looks like this.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Name</th> <th>Age</th> </tr> </thead> <tbody> <tr> <td>John</td> <td>20.5</td> </tr> <tr> <td>Alice</td> <td>39.1</td> </tr> <tr> <td>Pam</td> <td>41.0</...
<p>I expect this to work in your case:</p> <pre><code>df = pd.DataFrame({'Name':['John', 'Alice', 'Pam', 203921], 'Age':[20.5, 39.1, 41.0, 'Hope']}) df['Name_Type'] = [True if type(x) == str else False for x in df.Name] df['Age_Type'] = [True if type(x) == float else False for x in df.Age] print(df) </code></pre> <p>Re...
How to get datatypes of each row using pandas?
python|pandas|dataframe
0
67
1
72,878,495
72,878,495
1
true
2022-07-06T04:28:36.090Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to get datatypes of each row using pandas?<p>I have a dataframe that looks like this.</p> <div class="s-table-container"> <table class="s-table"> <thead>...
72,931,467
Ansible filter dict based on key presence and list values<p>I have this variable :</p> <pre><code>components: comp_one: name: first_component remote_server_path: &quot;/tmp/path/one&quot; binaries: - test - test_two comp_two: name: second_component remote_server_path: &quot;/tmp/pa...
<p>Use <a href="https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html#magic-variables" rel="nofollow noreferrer"><em>group_names</em></a>. This is: <em>&quot;List of groups the current host is part of.&quot;</em>. For the host <em>host_one</em> in the inventory <em>hosts.yaml</em> this is<...
Ansible filter dict based on key presence and list values
ansible|jinja2
1
67
1
72,931,773
72,931,773
1
true
2022-07-10T19:53:48.420Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Ansible filter dict based on key presence and list values<p>I have this variable :</p> <pre><code>components: comp_one: name: first_component remot...
72,907,199
ValueError: setting an array element with a sequence while running NearestNeighbor<p>I have pyspark dataframe like this:</p> <pre><code>+------+---------------------------------------------------------------------+ |id |features | +------+------------------...
<p><code>df.toPandas()</code> returns a column of lists. You need to convert this column of lists to a 2D array. When you do <code>df_collect['features'].apply(lambda x: np.array(x)).to_numpy()</code> you get an array of arrays which is not the same as a 2D array. So you need</p> <pre><code>df_collect = df.toPandas() f...
ValueError: setting an array element with a sequence while running NearestNeighbor
python|pandas|numpy|knn|nearest-neighbor
2
67
2
72,908,725
72,908,725
1
true
2022-07-08T05:56:54.507Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: ValueError: setting an array element with a sequence while running NearestNeighbor<p>I have pyspark dataframe like this:</p> <pre><code>+------+-------------...
72,962,720
imagemagick check if image is of almost one single color<p>Friends,</p> <p>I have a stack of color-scanned images. Some are from regular white paper with text or images, others were scanned from colored paper (blank pages, same green colored paper used.)</p> <p>I'd like to identify these colored paper images. Problems:...
<p>Have a look at HSV colourspace on <a href="https://en.wikipedia.org/wiki/HSL_and_HSV" rel="nofollow noreferrer">Wikipedia</a> - specifically <a href="https://en.wikipedia.org/wiki/HSL_and_HSV#/media/File:HSL-HSV_hue_and_chroma.svg" rel="nofollow noreferrer">this</a> diagram.</p> <p>It should be a better place to fin...
imagemagick check if image is of almost one single color
imagemagick
1
67
1
72,978,849
72,978,849
1
true
2022-07-13T07:53:46.460Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: imagemagick check if image is of almost one single color<p>Friends,</p> <p>I have a stack of color-scanned images. Some are from regular white paper with tex...
73,000,220
Extracting multiple abstracts from pubmed from external pubmed IDs list with biopython<p>I am trying to extract the abstracts for 60K articles from Pubmed using PubmedIDs. I am trying to export the abstracts into a dictionary. I guess there is some issue with the code I am using, especially while parsing the pubmed IDs...
<p>Note that <code>Entrez.efetch</code> will only return 1000 records. Since you indicate that you want to download 60K abstracts, I have modified your code to download the abstracts in batches.</p> <pre class="lang-py prettyprint-override"><code>from Bio import Entrez import sys import csv Entrez.email = 'anonymous@g...
Extracting multiple abstracts from pubmed from external pubmed IDs list with biopython
python|python-3.x|dictionary|biopython
3
67
1
73,048,324
73,048,324
1
true
2022-07-15T22:41:35.617Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Extracting multiple abstracts from pubmed from external pubmed IDs list with biopython<p>I am trying to extract the abstracts for 60K articles from Pubmed us...
72,928,284
Comparable<Integer> array comparison java<p>I'm tasked with writing mergesort in java, the task also specified I can't use integers, I have to use Comparable integers. This is my first time using java. My problem is comparing elements in two comp-int arrays inside the merging function. I have tried <code>if (list[i].co...
<p>Here is what you should be doing.</p> <pre><code>public static Integer [] merge(Integer[] list, Integer[]list2 ) { Integer[] C = new Integer[list.length + list2.length]; int i = 0; int j = 0; int k = 0; while (i &lt; list.length &amp;&amp; j &lt; list2.length) { if (list[i].compareTo(list2[j]) &...
Comparable<Integer> array comparison java
java|conditional-statements|mergesort|comparable
-3
67
2
72,929,528
72,929,528
1
true
2022-07-10T11:52:49.600Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Comparable<Integer> array comparison java<p>I'm tasked with writing mergesort in java, the task also specified I can't use integers, I have to use Comparable...
73,000,795
ASP.NET Web API works locally but returning SqlException error on AWS Lambda<p>I am trying to host a Web API on aws lambda. The API connects to a database on AWS RDS. The database does store and serve data correctly. The problem is that when I run the API locally, it does return data from the database correctly, but af...
<p>Lambda is a Serverless compute environment that runs methods/functions. You are looking for a hosting solution for your ASP.NET Web API. Look at deploying your ASP.NET Web API to Elastic Beanstalk. Elastic Beanstalk for .NET is available to anyone who hosts a web app that uses IIS.</p> <p>Details here:</p> <p><a hre...
ASP.NET Web API works locally but returning SqlException error on AWS Lambda
c#|amazon-web-services|api|asp.net-web-api|aws-lambda
0
67
1
73,005,112
73,005,112
1
true
2022-07-16T00:47:50.883Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: ASP.NET Web API works locally but returning SqlException error on AWS Lambda<p>I am trying to host a Web API on aws lambda. The API connects to a database on...
72,981,653
Is there a way in rspec to specify a before block for *all* examples in spec_helper.rb?<p>I'd like to run a piece of code before <em>each</em> test in my suite (many files, many <code>describe</code> blocks). Is there a way to do that, for example, by setting something in the spec_helper.rb file?</p> <p>I know about <c...
<p>You can basically add the following configuration in your spec_helper.rb:</p> <pre><code>RSpec.configure do |config| # other configs config.before(:each) do # Do something end end </code></pre>
Is there a way in rspec to specify a before block for *all* examples in spec_helper.rb?
ruby|rspec
0
67
1
72,991,418
72,991,418
1
true
2022-07-14T13:51:58.627Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Is there a way in rspec to specify a before block for *all* examples in spec_helper.rb?<p>I'd like to run a piece of code before <em>each</em> test in my sui...
73,007,085
how to convert Option<&u8> to u8<p>i want to convert Option&lt;&amp;u8&gt; to u8 so i will be able to print it</p> <p>my code:</p> <pre class="lang-rust prettyprint-override"><code>fn main() { let v : Vec&lt;u8&gt; = vec![1, 2, 3, 4, 5]; let out_of_range = &amp;v[100]; let out_of_range = v.get(100); ma...
<p>Your match statement needs the introduction of a <em>binding</em>, not a type (the <code>&amp;u8</code> you used was not expected here).</p> <p>Here <code>Some(val)</code> matches with something which is an <code>Option&lt;&amp;u8&gt;</code>, thus <code>val</code> is a binding to the embedded <code>&amp;u8</code> (i...
how to convert Option<&u8> to u8
rust
0
67
1
73,007,220
73,007,220
1
true
2022-07-16T19:27:30.557Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to convert Option<&u8> to u8<p>i want to convert Option&lt;&amp;u8&gt; to u8 so i will be able to print it</p> <p>my code:</p> <pre class="lang-rust pret...
73,004,587
how to modify this code to transfer files faster?<p>I wrote that simple client/server code in order to transfer files. the code transferred pictures and text files pretty easily and very fast. but it takes a long time to transfer an mp4 file (more than 10 minutes). how do I modify it to run faster? thank you</p> <p>the...
<p>Write as you receive and with a larger buffer.</p> <p>Also use <code>with</code> to ensure the socket and file are closed.</p> <pre><code>import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((&quot;127.0.0.1&quot;, 12345)) with s, open(&quot;received.jpg&quot;, &quot;wb&quot;) as f: wh...
how to modify this code to transfer files faster?
python|sockets|file-transfer
0
67
1
73,005,911
73,005,911
1
true
2022-07-16T13:26:09.537Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to modify this code to transfer files faster?<p>I wrote that simple client/server code in order to transfer files. the code transferred pictures and text...
72,772,908
C# Check if sections intersect<p>I have a list of N consecutive vertical and horizontal sections of fixed dimensions in a form of a succession of directions (right → ; left ←; down ↓; up ↑). The program should return true if the sections intersect. For example: N = 6: { up, left, down, down, right, up} - return True. I...
<p>The simplest code change I can think of would be to use something that will remember all the visited locations and can tell you whether or not you have visited a location before. Such an object needs a way to <em>add</em> a location to its memory, and needs a way to <em>test</em> to see if a location is remembered....
C# Check if sections intersect
c#|function|directions
0
67
3
72,775,238
72,775,238
1
true
2022-06-27T13:26:51.823Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: C# Check if sections intersect<p>I have a list of N consecutive vertical and horizontal sections of fixed dimensions in a form of a succession of directions ...
72,397,714
can i have two recyclerView with one viewHolder and two adapters?<p>Hi i'm new of android and i have a question.</p> <ol> <li><p>if I have two recyclerviews, how many viewHolder and adapter should I have?</p> </li> <li><p>can i have two recyclerView with one viewHolder and two adapters, or is it good practice to have o...
<p>This entirely depends on your business requirements.</p> <p><strong>Basics -</strong></p> <p><strong>Recyclerview -</strong> The UI part.</p> <p><strong>Adapter -</strong> Used to populate the recycler view using a few override methods.</p> <p><strong>ViewHolder -</strong> This is the unique UI items that are shown ...
can i have two recyclerView with one viewHolder and two adapters?
android
0
67
2
72,400,000
72,400,000
1
true
2022-05-26T20:30:23.537Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: can i have two recyclerView with one viewHolder and two adapters?<p>Hi i'm new of android and i have a question.</p> <ol> <li><p>if I have two recyclerviews,...
72,301,505
How to show total count of elements based on two conditions in react js?<p>I am trying to show total count of participants based on two conditions: have <code>&quot;Nume&quot;: &quot;4S110&quot;</code> and <code>&quot;Nume&quot;: &quot;Contabilitate&quot;</code> from <code>INDICATORI</code> array and <code>Cursuri</co...
<p>The <code>.filter()</code> function returns an array so you need to add <code>.length</code>. <code>Math.min()</code> can help in case you want to count such person only once (must have an entry in both items).</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div ...
How to show total count of elements based on two conditions in react js?
arrays|reactjs|object|filter|reduce
1
67
1
72,301,556
72,301,556
1
true
2022-05-19T08:54:57.953Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to show total count of elements based on two conditions in react js?<p>I am trying to show total count of participants based on two conditions: have <cod...
72,253,169
XUnit Test Moq failing<p>I am new to XUnit and Moq. I am attempting a simple test, but can't get it to work.</p> <p>I have 7 test records and would like to add an 8th for my test.</p> <p>My test always fails with the original 7 test records instead of 8.</p> <p>I have setup my test per below..</p> <pre><code>public cla...
<p>The problem is because you are returning a fixed value</p> <pre><code>_mockRepo.Setup(x =&gt; x.CountAsync()).ReturnsAsync(list.Count); </code></pre> <p>The above is the same as</p> <pre><code>_mockRepo.Setup(x =&gt; x.CountAsync()).ReturnsAsync(7); </code></pre> <p>it will return 7 every time since it was setup wit...
XUnit Test Moq failing
c#|asp.net-core|moq|xunit
1
67
1
72,253,453
72,253,453
1
true
2022-05-16T00:42:42.493Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: XUnit Test Moq failing<p>I am new to XUnit and Moq. I am attempting a simple test, but can't get it to work.</p> <p>I have 7 test records and would like to a...
72,347,884
How to inject a specific implementation in asp.net core<p>I have a Repository which has a dependency of <code>User</code></p> <p>I need to put other implementation of <code>User</code> and I can do it like that, but with this approach I do not know how to mock my repository</p> <pre><code>private readonly IRepository&l...
<p>Just as you inject <code>MyAppDbContext</code> into <code>SomeClass</code> you can also inject an instance of <code>User</code>, e.g.</p> <pre><code>private readonly IRepository&lt;Entity&gt; _repository; public SomeClass(MyAppDbContext context, User user) { _repository= new EfRepository&lt;WorkOrder&gt;(context,...
How to inject a specific implementation in asp.net core
c#|asp.net-core|mocking
0
67
1
72,348,030
72,348,030
1
true
2022-05-23T11:37:18.683Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to inject a specific implementation in asp.net core<p>I have a Repository which has a dependency of <code>User</code></p> <p>I need to put other implemen...
72,263,555
Are delete events considered close_write in inotifywait?<p>I have a simple inotifywait script that watches for FTP file uploads to be <em>closed</em> and then moving them to a aws s3. It seems to be working except that in the inotify logs, it indicates that the file was not found ( although the file was indeed uploaded...
<p>Cleaned-up your script and added some safety with quotes and check for already processed file in case the filesystem triggers duplicate events for same file.</p> <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/env bash # Prevents expanding pattern without matches shopt -s nullglob # Expands pattern into...
Are delete events considered close_write in inotifywait?
bash|inotify|inotifywait
1
67
1
72,266,149
72,266,149
1
true
2022-05-16T17:53:11.070Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Are delete events considered close_write in inotifywait?<p>I have a simple inotifywait script that watches for FTP file uploads to be <em>closed</em> and the...
72,263,626
what do the symbols (* + !) at the end of a git branch mean?<p>I sometimes notice that my git branch has suffixes of <code>!</code> or <code>*</code> or <code>+</code>. Thats probably not an exhaustive list, just a few I noticed. I think <code>+</code> means the branch is dirty, and <code>!</code> means I should pull m...
<p>This is the prompt of your terminal, the information displayed depends on the extension you use to print git information in that prompt.</p> <p>The <code>! * +</code> characters are not part of <code>git</code> commands, they are added by that extension, probably to indicate one of :</p> <ul> <li>current branch is u...
what do the symbols (* + !) at the end of a git branch mean?
git|visual-studio-code|branch|git-branch
0
67
1
72,264,821
72,264,821
1
true
2022-05-16T17:58:51.083Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: what do the symbols (* + !) at the end of a git branch mean?<p>I sometimes notice that my git branch has suffixes of <code>!</code> or <code>*</code> or <cod...
72,325,374
Running msbuild via cmake inside powershell<p>I have a CMake project that generates a Visual Studio solution that builds with MSBuild.</p> <p>The command I am using to build the project is:</p> <pre><code>cmake --build Debug -- -v:diag </code></pre> <p>using the <code>--</code> option causes the <code>-v:diag</code> op...
<p>Unfortunately, you've hit a bug in PowerShell's parameter binder, present up to at least PowerShell 7.2.4:</p> <p><code>-v:diag</code> is unexpectedly passed as <em>two</em> arguments, <code>-v:</code> and <code>diag</code>, <em>if <code>--</code> comes beforehand</em> in calls to external programs - see <a href="ht...
Running msbuild via cmake inside powershell
powershell|cmake
1
67
1
72,325,402
72,325,402
1
true
2022-05-20T22:42:10.633Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Running msbuild via cmake inside powershell<p>I have a CMake project that generates a Visual Studio solution that builds with MSBuild.</p> <p>The command I a...
72,372,118
How to Parse JSON when the object name is a number?<p>I have been trying to parse the JSON data I get from my browser, however, I've run into a problem. In the browser, when I copy the path of the property: bedrooms, this is the path I get:</p> <ul> <li>0.bedrooms</li> </ul> <p>The 0 is the name of the object, and bedr...
<p>According to your screenshot the root object is an array</p> <pre><code>struct HomeData: Decodable { let bathrooms: Double let bedrooms: Double let price: Int let rawAddress: String let squareFootage: Int let propertyType: String } func parseJSON(homeData: Data){ let decoder = JSONDe...
How to Parse JSON when the object name is a number?
json|swift
-2
67
1
72,380,830
72,380,830
1
true
2022-05-25T04:54:38.723Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to Parse JSON when the object name is a number?<p>I have been trying to parse the JSON data I get from my browser, however, I've run into a problem. In t...
72,262,903
How to check in array if it contains given element<p>I am trying below code but its not working so first am trying to get a person department Name currently, hard coded it to check</p> <pre><code>var arr=[] let CurrDept = &quot;AB-CDE-F&quot;; var Detept=CurrDept.substring(0,5); arr.push(Detept) </code></pre> <p>Now in...
<p>You can use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter" rel="nofollow noreferrer">Array.prototype.filter</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith" rel="nofollow noreferrer">String.pr...
How to check in array if it contains given element
javascript
2
67
2
72,263,152
72,263,152
1
true
2022-05-16T16:56:41.930Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to check in array if it contains given element<p>I am trying below code but its not working so first am trying to get a person department Name currently,...
72,284,835
C# generic bounds<p>I have a abstract dto class,I want to write a batch class to deal the derived dto:</p> <p>dto:</p> <pre><code>public abstract class Command { private string TraceNo { get; set; } public override string ToString() { return ObjectDumper.Dump(this); } ...
<p>Okay... so now we have this method:</p> <pre><code> public static Dictionary&lt;int, T&gt; GetCommandHandler&lt;T, TC&gt;() where TC : Command where T : ICommandHandler&lt;TC&gt; { List&lt;ICommandHandler&lt;Command&gt;&gt; list; var dic = new Dictionary&lt;int, T&gt;(); dic[2] = new Logi...
C# generic bounds
c#|.net|generics
0
67
1
72,285,236
72,285,236
1
true
2022-05-18T07:27:27.017Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: C# generic bounds<p>I have a abstract dto class,I want to write a batch class to deal the derived dto:</p> <p>dto:</p> <pre><code>public abstract class Comma...
72,304,251
Dropdown option cannot be selected if I put the component inside my label<p>Why doesn't my <code>Dropdown</code> component work when I put it inside my <code>&lt;label&gt;</code> tag? The dropdown is displaying the options, but if you click on one, the selection is not working/displayed.</p> <p>Any suggestions?</p> <pr...
<p>Firstly here's something important to note: <a href="https://i.stack.imgur.com/N2SEi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N2SEi.png" alt="enter image description here" /></a></p> <p>Based on this image, a console snippet from sandbox, it shows that the selection happens, but it gets cle...
Dropdown option cannot be selected if I put the component inside my label
reactjs|dropdown|tailwind-css
1
67
1
72,355,097
72,355,097
1
true
2022-05-19T12:06:34.437Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Dropdown option cannot be selected if I put the component inside my label<p>Why doesn't my <code>Dropdown</code> component work when I put it inside my <code...
72,366,296
Count how many times class member was printed<p>I need to count how many times class members were printed using function <code>Print</code> which is <strong>inspector</strong>. Constructor should set private elements of class.</p> <pre><code>#include &lt;cmath&gt; #include &lt;iostream&gt; class Vector3d { double x, ...
<p>You need to overload copy constructor and copy assign operator for <code>Vector3d</code> class. Now you are copying state of <code>count</code> field into <code>v2</code> object, therefore it starts from 3 not from 0.</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;cmath&gt; #include &lt;iostream&g...
Count how many times class member was printed
c++|class
-1
67
1
72,366,365
72,366,365
1
true
2022-05-24T16:23:51.683Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Count how many times class member was printed<p>I need to count how many times class members were printed using function <code>Print</code> which is <strong>...
72,382,033
Matplotlib cmap - custom color definition<p>I am plotting a graph using matplotlib.</p> <p>Here is the code:</p> <pre><code>fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.set_title(&quot;Grid search results - &quot; + model_name) ax.set_xlabel(&quot;Log10(Wight decay)&quot;) ax.set_ylabel(&quot;Log10(...
<p>One cheap/quick solution might be to create a &quot;categorical color value&quot;, like this:</p> <pre><code>import matplotlib.pyplot as plt import matplotlib.cm as cm from matplotlib.colors import ListedColormap import numpy as np N = 40 x = np.random.uniform(0, 1, N) y = np.random.uniform(0, 1, N) z = np.random.u...
Matplotlib cmap - custom color definition
python|matplotlib
0
67
1
72,382,881
72,382,881
1
true
2022-05-25T17:35:30.140Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Matplotlib cmap - custom color definition<p>I am plotting a graph using matplotlib.</p> <p>Here is the code:</p> <pre><code>fig = plt.figure() ax = fig.add_s...
72,259,781
How to read comma-separated csv file with `sscanf()`<p>I'm attempting to print an array of structures read from a CSV file in Excel. However, only the students' IDs are printed; other information was also printed but some confusing rare characters. Can you please tell me what could be wrong with this code?</p> <pre><co...
<p>There are multiple problems:</p> <ul> <li><p>you should not use <code>feof()</code>. Read <a href="https://stackoverflow.com/questions/5431941/why-is-while-feof-file-always-wrong">Why is “while ( !feof (file) )” always wrong?</a> <br> Use this loop instead:</p> <pre><code> while (fgets(buffer, sizeof buffer, source...
How to read comma-separated csv file with `sscanf()`
c|csv|scanf|structure|strtok
1
67
1
72,260,309
72,260,309
1
true
2022-05-16T13:11:11.227Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to read comma-separated csv file with `sscanf()`<p>I'm attempting to print an array of structures read from a CSV file in Excel. However, only the studen...
72,377,149
Filter Operator API response not working in RxSwift<p>I am not able to find out the what is the issue , just to filter out response based on status code as follow:</p> <p>The code should be filter out the response based on the status code &amp; return <code>response &amp; data</code> as observable.</p> <p><a href="http...
<p>There are few issues with your approach:</p> <ul> <li>Why are you using <code>Observable.create</code> when you have <code>URLSession.shared.rx.response</code> that is already returning <code>Observable</code>?</li> <li>Your last <code>flatMap</code> should return an <code>Observable</code> but you are not returning...
Filter Operator API response not working in RxSwift
ios|swift|api|rxjs|rx-swift
0
67
1
72,377,588
72,377,588
1
true
2022-05-25T11:53:44.023Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Filter Operator API response not working in RxSwift<p>I am not able to find out the what is the issue , just to filter out response based on status code as f...
72,268,407
awk from file using echo and output to file<p>A.txt contains:</p> <pre><code>/*333*/ asdfasdfadfg sadfasdfasgadas @@@ /*555*/ hfawehfihohawe aweihfiwahif aiwehfwwh @@@ /*777*/ jawejfiawjia ajwiejfjeiie eiuehhawefjj @@@ </code></pre> <p>B.txt contains:</p> <pre><code>555 777 </code></pre> <p>I want to create the loop, f...
<p>Making a few alterations to your code provides the desired outcome with the example data provided:</p> <pre><code>while read -r f do awk -v var=&quot;/[*]$f[*]/&quot; '$0 ~ var {flag=1} /@@@/{flag=0} flag' A.txt &gt; &quot;$f&quot;.txt done &lt; B.txt cat 555.txt /*555*/ hfawehfihohawe aweihfiwahif aiwehfwwh c...
awk from file using echo and output to file
bash|awk
1
67
3
72,268,644
72,268,644
1
true
2022-05-17T04:59:18.080Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: awk from file using echo and output to file<p>A.txt contains:</p> <pre><code>/*333*/ asdfasdfadfg sadfasdfasgadas @@@ /*555*/ hfawehfihohawe aweihfiwahif aiw...
72,278,938
Javascript - grouping an array and then sorting the grouped result based on length<p>this is the array ;</p> <pre><code>var dataArr = [ { &quot;permalink&quot;: /* link*/ &quot;subreddit&quot;: &quot;mac&quot; }, { &quot;permalink&quot;: /* link*/ &quot;subreddit&quot;: &quot;worldnews&quot; }...
<p>From my above comment ...</p> <blockquote> <p><em>&quot;In case the OP <strong>depends</strong> on key insertion order (though it would even work) of an object (because this is what the OP is asking for) then the OP's entire data handle approach is at question. What one could do instead ... create a sorted array of ...
Javascript - grouping an array and then sorting the grouped result based on length
javascript|object|key|reduce|insertion-order
-1
67
1
72,280,108
72,280,108
1
true
2022-05-17T18:21:13.323Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Javascript - grouping an array and then sorting the grouped result based on length<p>this is the array ;</p> <pre><code>var dataArr = [ { &quot;permali...
72,294,827
Is it possible to emulate v-model input behaviour on a paragraph tag?<h1>Solution:</h1> <p>Thanks to @Jeronimas I figured out how to use <code>dynamic components</code> in vue. Basically you create a <code>child component</code> that switches between <code>&lt;p&gt;</code>and <code>&lt;input&gt;</code> tags, depending ...
<p>Like in the comment above using <code>:is</code> could work when switching between the states.</p> <p><code>&lt;component :is=&quot;tag&quot;&gt;</code></p> <p><code>tag</code> value could be dynamic and depending on the <code>tag</code> value the component would change its state.</p> <p>I would suggest using <code>...
Is it possible to emulate v-model input behaviour on a paragraph tag?
javascript|html|vue.js|vuejs3
1
67
1
72,296,146
72,296,146
1
true
2022-05-18T19:17:09.570Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Is it possible to emulate v-model input behaviour on a paragraph tag?<h1>Solution:</h1> <p>Thanks to @Jeronimas I figured out how to use <code>dynamic compon...
72,304,708
Score update. Change in every 5 seconds<p>I'm new to unity and I'm developing a 2d game. I want my game to update the &quot;scoretext&quot; every 5 seconds and I want it to update for +1. But my code is not working. It is updating in like 0.000...1 second (I mean the program doesn't wait 5 seconds to update). How can I...
<h2> Solution 1: </h2> <p>Simple use of <code>InvokeRepeating</code> code:</p> <pre class="lang-cs prettyprint-override"><code>void ScoreUp() { score++; scoretext.text = score.ToString(); } void Start() { InvokeRepeating(nameof(ScoreUp), 0f, 5f); // 0=delay, 5f = repeat Time } </code></pre> <hr> <h2> Soluti...
Score update. Change in every 5 seconds
c#|unity3d|2d
1
67
1
72,304,823
72,304,823
1
true
2022-05-19T12:38:19.313Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Score update. Change in every 5 seconds<p>I'm new to unity and I'm developing a 2d game. I want my game to update the &quot;scoretext&quot; every 5 seconds a...
72,375,441
Attempt to get token returns undefined<p>I'm using an API with javascript to make a login and, the login is working, but now, I need to make the logout and I need to get the token from the success message that appears on the console like this:</p> <pre><code>{&quot;access&quot;:1,&quot;message&quot;:&quot;Success!&quot...
<p>In your code <code>result</code> is a <code>string</code> and what you need is an object.</p> <pre class="lang-js prettyprint-override"><code> fetch(&quot;https://api.secureme.pt/api/v1/auth/login&quot;, requestOptions) .then((response) =&gt; response.json()) // parse JSON data .then((result) =&gt; c...
Attempt to get token returns undefined
javascript
-3
67
1
72,375,473
72,375,473
1
true
2022-05-25T09:52:25.477Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Attempt to get token returns undefined<p>I'm using an API with javascript to make a login and, the login is working, but now, I need to make the logout and I...
72,310,981
Simple vanilla javascript accordion - problem when click on active item<p>I have a problem with my accordion script.</p> <p>Can someone explain me - why after clicking on the <strong>active item</strong>, the animation is not performed like when clicking on the next item?</p> <p>It seems to me that the problem is at th...
<p>Just a little change in the conditionals makes it work (for some reason i got a downvote so i posted the whole code):</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> l...
Simple vanilla javascript accordion - problem when click on active item
javascript|accordion
0
67
3
72,311,669
72,311,669
1
true
2022-05-19T20:57:17.727Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Simple vanilla javascript accordion - problem when click on active item<p>I have a problem with my accordion script.</p> <p>Can someone explain me - why afte...
72,268,421
How does Web3-Token verify method really work and is it really secure?<p>I have read how Web3 Auth works and this picture shows it: <a href="https://i.stack.imgur.com/xnve6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xnve6.png" alt="enter image description here" /></a></p> <p>It seems that the we...
<p>As stated in the <a href="https://github.com/bytesbay/web3-token" rel="nofollow noreferrer">web3-token</a> <code>package.json</code>, this package implements the <a href="https://eips.ethereum.org/EIPS/eip-4361" rel="nofollow noreferrer">EIP-4361</a> standard (which is currently unfinished in May 2022).</p> <p>Its a...
How does Web3-Token verify method really work and is it really secure?
ethereum|metamask
0
67
1
72,268,824
72,268,824
2
true
2022-05-17T05:01:35.747Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How does Web3-Token verify method really work and is it really secure?<p>I have read how Web3 Auth works and this picture shows it: <a href="https://i.stack....
72,297,504
How to transpose a single column in BigQuery without specifying all the values in the column?<p>I have a table of the following type:</p> <pre><code>col_A col_B col_C col_D 1 ab cd val1 2 cd ef val2 2 cd ef val3 3 ab bc val4 </code></pre> <p>What I would like to do is somethi...
<p>Hope this is helpful: You said you don't know what values in <code>col_D</code> in advance, so it will be needed to create a pivot query dynamically using <code>EXECUTE IMMEDIATE</code>.</p> <pre class="lang-sql prettyprint-override"><code>CREATE TEMP TABLE sample AS SELECT * FROM UNNEST([STRUCT (1 AS col_A, 'ab' ...
How to transpose a single column in BigQuery without specifying all the values in the column?
sql|google-bigquery
0
67
2
72,298,455
72,298,455
2
true
2022-05-19T00:55:49.537Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to transpose a single column in BigQuery without specifying all the values in the column?<p>I have a table of the following type:</p> <pre><code>col_A co...
72,330,732
Pushing Array of object from react to mongodb+express server issue<p>I'm store array of object but it is giving mer following error.</p> <p>(node:87929) UnhandledPromiseRejectionWarning: ValidationError: Place validation failed: placesToVisit: Cast to embedded failed for value &quot;[{&quot;name&quot;:&quot;xczc&quot;,...
<p>You must convert the string to an array:</p> <pre class="lang-js prettyprint-override"><code>placesToVisit: JSON.parse(req.body.placesToVisit), </code></pre>
Pushing Array of object from react to mongodb+express server issue
reactjs|mongodb|express
0
67
1
72,331,065
72,331,065
2
true
2022-05-21T15:05:36.200Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Pushing Array of object from react to mongodb+express server issue<p>I'm store array of object but it is giving mer following error.</p> <p>(node:87929) Unha...
72,345,271
Functor application over division<p>My question can be written in the context of lists. I have a function doing what is analogous to:</p> <pre class="lang-hs prettyprint-override"><code>div' xs n = (*) (1 / n) &lt;$&gt; xs </code></pre> <p>Can this be simplified at all? I have been unable to work anything out.</p>
<p>You can work with the <a href="https://wiki.haskell.org/Section_of_an_infix_operator" rel="nofollow noreferrer"><em>section of an infix operator</em> <sup>[Haskell-wiki]</sup></a> and write <code>(/ n)</code> to construct a function that will divide by <code>n</code>, that means you can implement <code>div'</code> a...
Functor application over division
haskell|functor
1
67
1
72,346,669
72,346,669
2
true
2022-05-23T08:14:52.527Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Functor application over division<p>My question can be written in the context of lists. I have a function doing what is analogous to:</p> <pre class="lang-hs...
72,352,246
Netty doesn't complain if port is already used<p>Following problem: I expect an exception if a port is already used.</p> <p>So I tried to start my server twice in a thread</p> <pre><code> public void start() { new Thread(new Runnable() { @Override public void run() { EventLoopGroup bo...
<p>After binding you are directly taking the channel from the future, but it probably hasn’t finished at that point. Try to wait for your bind to complete with <code>bind(port).sync()</code>.</p> <p>See for reference <a href="https://www.baeldung.com/netty#6-server-bootstrap" rel="nofollow noreferrer">https://www.baeld...
Netty doesn't complain if port is already used
java|netty
1
67
1
72,352,996
72,352,996
2
true
2022-05-23T16:59:08.150Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Netty doesn't complain if port is already used<p>Following problem: I expect an exception if a port is already used.</p> <p>So I tried to start my server twi...
72,378,728
How to extract a specific substring (based on regex) from an array of strings<p>I have a big array of strings:</p> <pre><code>['{{Wanted Value}}', 'true', '{{Wanted Value}}', '{{Wanted Value}} unwanted {{Wanted Value}}', 'false'...] </code></pre> <p>I want to filter the array and extract every <code>{{Wanted Value}}</c...
<p>You can try this approach</p> <ul> <li><code>flatMap</code> is to collect all matched strings</li> <li><code>filter</code> is to get rid of empty results</li> </ul> <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 ...
How to extract a specific substring (based on regex) from an array of strings
javascript|arrays
0
67
2
72,378,893
72,378,893
2
true
2022-05-25T13:39:43.510Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to extract a specific substring (based on regex) from an array of strings<p>I have a big array of strings:</p> <pre><code>['{{Wanted Value}}', 'true', '{...
72,393,440
importing range from another book using data validation in google sheets<p>I want a drop-down list here :</p> <p><a href="https://i.stack.imgur.com/E4KbG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E4KbG.png" alt="enter image description here" /></a></p> <p>But the range is in another book called...
<p>this is not possible. you need to import your list in some column first (you can hide it in 3 ways) and only then you can create your dropdown</p>
importing range from another book using data validation in google sheets
arrays|google-sheets|filter|import|dropdown
2
67
1
72,393,482
72,393,482
2
true
2022-05-26T14:27:15.340Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: importing range from another book using data validation in google sheets<p>I want a drop-down list here :</p> <p><a href="https://i.stack.imgur.com/E4KbG.png...
72,257,313
Why is this Swift web scraper not working?<p>I am having trouble scraping an image HTML link with a code I found on youtube (<a href="https://www.youtube.com/watch?v=0jTyKu9DGm8&amp;list=PLYjXqILgs9uPwYlmSrIkNj2O3dwPCcoBK&amp;index=2" rel="nofollow noreferrer">https://www.youtube.com/watch?v=0jTyKu9DGm8&amp;list=PLYjXq...
<p>This fails because you do not wait until your func has pulled the link. You are in an async context here. One possible solution:</p> <pre><code>//Make a class in instead of a struct and inherit from ObservableObject class ImageLink: ObservableObject { let url = URL(string: &quot;https://guide.michelin.com/th/en...
Why is this Swift web scraper not working?
swift
1
67
1
72,257,625
72,257,625
2
true
2022-05-16T09:53:41.800Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why is this Swift web scraper not working?<p>I am having trouble scraping an image HTML link with a code I found on youtube (<a href="https://www.youtube.com...
72,397,003
Sorting a list following specific order of elements<p>Let's say that I need to sort a list like:</p> <p><code>A=[1,1,1,1,1,1,1,0,0,0]</code></p> <p>following a ratio between 1 and 0 of 4:1, obtaining so <code>A=[1,1,1,1,0,1,1,1,0,0]</code>.</p> <p>Is that possible? I tried to use a <code>count</code> comand in this way...
<h2>Using simple arithmetic</h2> <p>Assuming the sequence contains only zeroes and ones.</p> <pre class="lang-py prettyprint-override"><code>from collections import Counter def reorder_4_1(seq): c = Counter(seq) q1, r1 = divmod(c[1], 4) diff = q1 - c[0] if diff &gt; 0: return [1,1,1,1,0] * c[0]...
Sorting a list following specific order of elements
python|list|sorting|count
3
67
2
72,397,209
72,397,209
2
true
2022-05-26T19:23:20.467Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Sorting a list following specific order of elements<p>Let's say that I need to sort a list like:</p> <p><code>A=[1,1,1,1,1,1,1,0,0,0]</code></p> <p>following...
72,280,664
Compare two List<string> in c# and find the duplicates<p>I've tried the methods here:</p> <ul> <li><a href="https://stackoverflow.com/questions/21148175/compare-two-liststring-and-print-the-duplicates">Compare two List&lt;string&gt; and print the duplicates</a></li> <li><a href="https://stackoverflow.com/questions/1746...
<blockquote> <p>even though I thought intersect would find ANY sort of duplicates and give it to the list</p> </blockquote> <p>Your thought is correct.</p> <blockquote> <p>Am I missing something super obvious here?</p> </blockquote> <p>You are missing to draw the straightforward and simple conclusion: Your assumption t...
Compare two List<string> in c# and find the duplicates
c#|list|linq|string-comparison
-1
67
1
72,280,806
72,280,806
2
true
2022-05-17T21:03:39.553Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Compare two List<string> in c# and find the duplicates<p>I've tried the methods here:</p> <ul> <li><a href="https://stackoverflow.com/questions/21148175/comp...
72,293,405
Pandas - Adding New Columns - Using Loops<p>I am new to python and working on a dataframe whose first column is 'Country' followed by 144 columns of numeric data.</p> <p><strong>Goal and Expected Result:</strong></p> <p>Need to create new columns which is an average of 3 columns. ex: first new column is an average of f...
<p>Much more verbose than the other answer but hopefully still helpful. The idea is to (1) melt the &quot;wide table&quot; to a &quot;long table&quot;, (2) add a year_quarter column, and (3) group on that column.</p> <pre><code>import pandas as pd import numpy as np num_cols = 14 num_rows = 5 np.random.seed(1) #Crea...
Pandas - Adding New Columns - Using Loops
python|pandas|dataframe|loops
2
67
2
72,293,926
72,293,926
2
true
2022-05-18T17:15:05.470Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Pandas - Adding New Columns - Using Loops<p>I am new to python and working on a dataframe whose first column is 'Country' followed by 144 columns of numeric ...
72,314,078
Access control plane from another ec2 instance<p>I am trying to access the kubectl of the master node that is running on an ec2 instance. I want to do this from another ec2 instance running on a different vpc. What steps should I take to make this possible?</p> <p>I have the kubeconfig file on my second machine already...
<ul> <li>If both of your <strong>EC2</strong> are in diff VPCs you can do the <code>VPC peering</code>.</li> <li>If you want to expose your master and K8s setup you can directly use the public IP(if exist) of EC2 and <code>kubectl</code> will connect to k8s cluster over the internet.</li> </ul> <p>You can also checkout...
Access control plane from another ec2 instance
amazon-web-services|kubernetes|amazon-ec2
1
67
2
72,314,180
72,314,180
2
true
2022-05-20T05:45:56.813Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Access control plane from another ec2 instance<p>I am trying to access the kubectl of the master node that is running on an ec2 instance. I want to do this f...
72,363,430
Can Some one explain why I get these output?<p>I am new to c.</p> <p>My Question.</p> <blockquote> <p>Why do some numbers end up negative when the value was positive?</p> </blockquote>
<p>Here is an explanation for the output you are seeing. 1000 in binary is 1111101000 (10 bits) and is stored in an <code>int</code> (signed 32 bits)</p> <p>When you cast that to an <code>unsigned char</code> (that has 8 bits), the top bits get &quot;cut off&quot;.</p> <p>So you get: <code>11101000</code> which is <cod...
Can Some one explain why I get these output?
c|casting|unsigned
0
67
1
72,363,668
72,363,668
2
true
2022-05-24T13:04:11.947Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Can Some one explain why I get these output?<p>I am new to c.</p> <p>My Question.</p> <blockquote> <p>Why do some numbers end up negative when the value was ...
72,240,417
How to change the final array to the front in JavaScript?<p>The case is:</p> <pre class="lang-js prettyprint-override"><code>function trocaPrimeiroEUltimo(array) { array.array[0] array.array[array.length - 1] return array } </code></pre> <p>I did this way, but it didn't work. I can't change the structure of...
<p>Do you want to replace the last value with the first value? if so, do:</p> <pre class="lang-js prettyprint-override"><code>temp = array[0] array[0] = array[array.length-1] array[array.length-1] = temp </code></pre> <p>That's a simple swap.</p>
How to change the final array to the front in JavaScript?
javascript|arrays|function
-2
67
2
72,240,449
72,240,449
2
true
2022-05-14T12:56:29.697Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to change the final array to the front in JavaScript?<p>The case is:</p> <pre class="lang-js prettyprint-override"><code>function trocaPrimeiroEUltimo(ar...
72,352,231
Given a total # of items and items per row, what column does an item belong to?<p>I have an application using CSS grid which will contain an variable number of grid elements, although I'll know the # of items in each row - is there an easy way to determine the column # of a given item?</p> <p>ie. given 32 elements arra...
<p>To take 1-based numbering into account:</p> <pre><code>column = (itemIndex - 1) % colsPerRow + 1 </code></pre> <p>(no need in <code>if</code> clause)</p>
Given a total # of items and items per row, what column does an item belong to?
javascript|math
1
67
2
72,352,353
72,352,353
2
true
2022-05-23T16:57:48.193Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Given a total # of items and items per row, what column does an item belong to?<p>I have an application using CSS grid which will contain an variable number ...
72,380,211
Global function call from function in unnamed namespace with the same name<p>I have a some code. file1.cpp:</p> <pre><code>extern void callout(); int answer() { return 5; } int main(){ callout(); return 0; } </code></pre> <p>file2.cpp</p> <pre><code>#include &lt;iostream&gt; using std::cout; using std::...
<p>First of all, if you want to call a function, it needs to be declared in the translation unit. The <code>answer</code> function from <code>file1.cpp</code> is currently not declared in <code>file2.cpp</code>'s translation unit.</p> <p>To fix this add a header file included in both <code>.cpp</code> files containing<...
Global function call from function in unnamed namespace with the same name
c++
0
67
1
72,381,282
72,381,282
2
true
2022-05-25T15:13:54.487Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Global function call from function in unnamed namespace with the same name<p>I have a some code. file1.cpp:</p> <pre><code>extern void callout(); int answer...
72,376,699
segmentation fault in c. Can anyone tell me how to solve it?<p>Can anyone tell me how can I solve the segmentation fault? I am still in a very early session of the class. I know that the segmentation fault has to do with my array and variable &quot;storedplain&quot;. My intention was to create an array with int type an...
<p><code>int storedplain[] = {0};</code> is the same as <code>int storedplain[1] = {0};</code>.</p> <p>This means <code>storedplain[i] = conversion2</code> will write past the end of <code>storedplain</code> since <code>i &lt; strlen(plaintext)</code> will result in a value for <code>i</code> larger than 0.</p> <p>A so...
segmentation fault in c. Can anyone tell me how to solve it?
c
-2
67
1
72,376,865
72,376,865
2
true
2022-05-25T11:21:25.437Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: segmentation fault in c. Can anyone tell me how to solve it?<p>Can anyone tell me how can I solve the segmentation fault? I am still in a very early session ...
72,241,926
Other ways of showing prop-based conditonal text in Vue?<p>I have a component that renders text based on the users membership status and I want to change the interpolated text based on that prop value. Is there a more efficient way of showing different text based on the prop besides a bunch divs/p tags with<code>v-if</...
<p>Maybe something like following snippet (map your plans and use computed property ):</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 { ref, computed } = Vue const app =...
Other ways of showing prop-based conditonal text in Vue?
javascript|vue.js|vuejs3|vue-props
2
67
2
72,242,023
72,242,023
2
true
2022-05-14T16:02:48.193Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Other ways of showing prop-based conditonal text in Vue?<p>I have a component that renders text based on the users membership status and I want to change the...
72,322,013
JSON data into variable<p><strong>EDIT</strong>: I solved that error, however, it only seems to print out just one instance. How can I make it put all the entries into that variable?</p> <p>I'm a little bit too new to this, but I'm trying. Sorry if the question sounds stupid. I've configured a JSON server and it works ...
<p>You're declaring the variable in an inner scope. So the outer scopes don't know what that variable is. Try:</p> <pre><code>function solicitare() { const dategraph = {}; // &lt;--- const adresa = &quot;http://localhost:4000/listaexamene?callback=?&quot;; $.getJSON(adresa, function (raspuns) { $.each(raspuns...
JSON data into variable
json|https|json-server
0
67
1
72,322,064
72,322,064
2
true
2022-05-20T16:22:35.100Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: JSON data into variable<p><strong>EDIT</strong>: I solved that error, however, it only seems to print out just one instance. How can I make it put all the en...
72,381,107
Why is "margin-top:10%" pushing more than 10% of its parent div?<p>In my div-1 the height is 300px, but when I try to add margin to <code>&lt;p&gt;</code> inside of it, well it works pretty fine with px but with percentage it pushes more than 10% of its parent div.</p> <p><div class="snippet" data-lang="js" data-hide="...
<p>When you defining margin in percentages, it's <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_definition" rel="nofollow noreferrer">refer to the width of the containing block</a>, try to use <code>vh</code> instead of <code>%</code>, or use another solution, if it's not suit your project; Oth...
Why is "margin-top:10%" pushing more than 10% of its parent div?
css|margin
0
67
2
72,381,621
72,381,621
2
true
2022-05-25T16:14:16.997Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why is "margin-top:10%" pushing more than 10% of its parent div?<p>In my div-1 the height is 300px, but when I try to add margin to <code>&lt;p&gt;</code> in...
72,391,415
Connecting to SQL Server and add user results in an error<p>I try to write code in C# to connect to a SQL Server database so I can register an user account but I dont know why I get stuck at</p> <pre><code>con.Open(); </code></pre> <p>I wrote server name correctly, I have tried with the <code>User ID = sa;</code> and ...
<p>Most likely just a little typo - use a <strong>backslash</strong> - not a forward slash - in your connection string:</p> <pre><code>protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(@&quot;Data Source=DESKTOP-62V61RT\SQLEXPRESS; Initial Catalog =ShopOnlineDB; Integr...
Connecting to SQL Server and add user results in an error
c#|sql-server
0
67
1
72,391,606
72,391,606
2
true
2022-05-26T11:55:54.007Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Connecting to SQL Server and add user results in an error<p>I try to write code in C# to connect to a SQL Server database so I can register an user account b...
72,255,455
Add heap-allocated string to Panic handler<p>I am in the context of a web application, where each request is assigned a unique correlation ID. I am running in a <code>wasm</code> environment with the <code>wasm32-unknown-unknown</code> target. One request is always served by one thread, and the entire environment is to...
<p>As per your example, you could <strong>move</strong> the id into the clusure:</p> <pre class="lang-rust prettyprint-override"><code>// Assume we have a request here from somewhere. let request = get_request_from_framework(); let request_id = request.get_request_id(); // This is at the start of the request panic::set...
Add heap-allocated string to Panic handler
rust
4
67
1
72,256,508
72,256,508
3
true
2022-05-16T07:20:33.253Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Add heap-allocated string to Panic handler<p>I am in the context of a web application, where each request is assigned a unique correlation ID. I am running i...
72,295,909
Mean of variables in a 2-way table in r<p>I am trying to get a 2-way table with the mean of observations. My dataframe is like this</p> <pre><code>df ID value Cl Dom Con &lt;chr&gt; &lt;dbl&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; G1-MAT1 1 B Knowing Ar G1-MAT2 0 B...
<p>With the {tidyverse} you can use <code>group_by()</code> and <code>summarize()</code> and then <code>pivot_wider()</code> to put it in the format you show.</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) d &lt;- tibble(value = sample(0:1, 100, T), Dom = sample(c(&quot;Knowing&quot;...
Mean of variables in a 2-way table in r
r|tidyverse
1
67
2
72,295,964
72,295,964
3
true
2022-05-18T20:57:57.023Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Mean of variables in a 2-way table in r<p>I am trying to get a 2-way table with the mean of observations. My dataframe is like this</p> <pre><code>df ID ...
72,307,454
List Cons-Into Function?<p>I am often wanting to take one list and cons every element into an existing list.</p> <pre><code>MyList = [3,2,1], MyNewElements = [4,5,6], MyNewList = lists:foldl(fun(A, B) -&gt; [A | B] end, MyList, MyNewElements). %% [6,5,4,3,2,1] </code></pre> <p>Assuming <code>MyList</code> has 1M elemen...
<p>Adding a short list to the beginning of a long list is cheap - the execution time of the <code>++</code> operator is proportional to the length of the first list. The first list is copied, and the second list is added as the tail without modification.</p> <p>So in your example, that would be:</p> <pre><code>lists:r...
List Cons-Into Function?
erlang
1
67
3
72,315,720
72,315,720
3
true
2022-05-19T15:42:54.087Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: List Cons-Into Function?<p>I am often wanting to take one list and cons every element into an existing list.</p> <pre><code>MyList = [3,2,1], MyNewElements =...
72,321,563
What's happening with the order of operations comparing "x is not y" vs "x is (not y)" in Python?<p>What's happening in Python to make the following different?</p> <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; one = 1 &gt;&gt;&gt; one is not False True &gt;&gt;&gt; one is (not False) False </code></pre> ...
<p>You can use the <code>ast</code> module to see how Python parses the two differently.</p> <p>In the first case, the parser recognizes <code>is not</code> as a single (two-word) operator, with operands <code>one</code> and <code>False</code>.</p> <pre><code>&gt;&gt;&gt; print(ast.dump(ast.parse(&quot;one is not False...
What's happening with the order of operations comparing "x is not y" vs "x is (not y)" in Python?
python
0
67
2
72,321,757
72,321,757
3
true
2022-05-20T15:41:43.177Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: What's happening with the order of operations comparing "x is not y" vs "x is (not y)" in Python?<p>What's happening in Python to make the following differen...
72,348,284
returning T inside a type resolves to never when a string enum is passed as generic type<p>Consider the following <code>enum A</code>:</p> <pre><code>enum A { ONE, TWO = &quot;TWO&quot; } </code></pre> <p>I want to write a generic <code>type</code> which checks if a <code>string</code> or <code>number</code> is par...
<p>This is a known bug in TypeScript, see <a href="https://github.com/microsoft/TypeScript/issues/41778" rel="nofollow noreferrer">microsoft/TypeScript#41778</a>. Even though <code>A.TWO extends &quot;TWO&quot;</code> is seen as true, the compiler does not manipulate enum types as one would expect. Specifically, <cod...
returning T inside a type resolves to never when a string enum is passed as generic type
typescript|types|typescript-generics|typescript-never
4
67
1
72,349,374
72,349,374
3
true
2022-05-23T12:08:18.893Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: returning T inside a type resolves to never when a string enum is passed as generic type<p>Consider the following <code>enum A</code>:</p> <pre><code>enum A ...
72,349,995
How to change order of elements when device is mobile<p>I have sth like this</p> <pre><code>&lt;div className=&quot;Image&quot;&gt;&lt;div&gt;&lt;div className=&quot;Text&quot;&gt;&lt;div&gt; &lt;div className=&quot;Text&quot;&gt;&lt;div&gt;&lt;div className=&quot;Image&quot;&gt;&lt;div&gt; &lt;div className=&quot;Imag...
<p>Using <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox" rel="nofollow noreferrer">Flexbox</a>, you can use <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/order" rel="nofollow noreferrer">order</a>.</p> <p><div class="snippet" data-lang="js" data-h...
How to change order of elements when device is mobile
javascript|css
-1
67
2
72,350,185
72,350,185
3
true
2022-05-23T14:09:54.377Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to change order of elements when device is mobile<p>I have sth like this</p> <pre><code>&lt;div className=&quot;Image&quot;&gt;&lt;div&gt;&lt;div classNa...
72,383,340
I have fitted a GLM and failing to plot the model using ggplot<p>I have made a GLM and am trying to plot the model using ggplot using the following code. I think i need to add the type argument so that my model doesn't just produce a horizontal flat line. However i am struggling to fit it using the type argument as i r...
<p>Here's one that puts the predictions on the right scale:</p> <pre class="lang-r prettyprint-override"><code>library(tidyverse) aids &lt;- structure(list(cases = c(2, 6, 10, 8, 12, 9, 28, 28, 36, 32), quarter = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L), ...
I have fitted a GLM and failing to plot the model using ggplot
r|ggplot2|glm
0
67
3
72,383,489
72,383,489
3
true
2022-05-25T19:42:40.627Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: I have fitted a GLM and failing to plot the model using ggplot<p>I have made a GLM and am trying to plot the model using ggplot using the following code. I t...
72,272,033
Animation is not applied when hovering sidebar<p>I use chakra ui.<br /> When I hover the sidebar, the sidebar extends to the right. I am using transition, but the animation is not applied. It is a bit choppy.<br /> I am using transition=&quot;all 0.3s&quot; but no animation happens when hover is applied.<br /> I don't ...
<p>You need to add CSS transition to main Flex also:</p> <pre><code>&lt;Flex background=&quot;blue.50&quot; flexDirection=&quot;column&quot; height=&quot;100vh&quot; justifyContent=&quot;space-between&quot; onMouseEnter={() =&gt; setState((prevState) =&gt; !prevState)} onMouseLeave={...
Animation is not applied when hovering sidebar
css|reactjs|sass|chakra-ui
1
67
1
72,272,529
72,272,529
4
true
2022-05-17T10:06:47.283Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Animation is not applied when hovering sidebar<p>I use chakra ui.<br /> When I hover the sidebar, the sidebar extends to the right. I am using transition, bu...
72,295,624
how to create SQL procedure which contains compile time errors?<p>I am writing a one time SQL procedure which will add an identity column to a table, then set the primary key of the table to that new identity column. But I cannot compile the SQL procedure because the CREATE PROCEDURE statement returns a compile error....
<p>You can do this one if you reduce it to one alter table like :</p> <pre><code>CREATE or replace PROCEDURE TESTSQL() LANGUAGE SQL SPECIFIC ORDHEADP5T ...
how to create SQL procedure which contains compile time errors?
db2|ibm-midrange
0
67
1
72,299,730
72,299,730
4
true
2022-05-18T20:31:33.767Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: how to create SQL procedure which contains compile time errors?<p>I am writing a one time SQL procedure which will add an identity column to a table, then se...
72,398,087
Difference between `Stream.each/2` and `Stream.map/2`?<p>They have the same (or equivalent) typespecs:</p> <pre><code>each(Enumerable.t(), (element() -&gt; term())) :: Enumerable.t() </code></pre> <pre><code>map(Enumerable.t(), (element() -&gt; any())) :: Enumerable.t() </code></pre> <p>The types <code>term</code> and ...
<p><code>Stream.map/2</code> will <em>transform</em> the enumerable: it RETURNS the result of its operation. <code>Stream.each/2</code> does not modify the enumerable; it's useful for emitting side-effects only.</p> <pre><code>iex&gt; Stream.map([1, 2, 3], fn x -&gt; x * 2 end) |&gt; Enum.to_list() [2, 4, 6] iex&gt; S...
Difference between `Stream.each/2` and `Stream.map/2`?
elixir
1
67
2
72,398,149
72,398,149
4
true
2022-05-26T21:15:47.443Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Difference between `Stream.each/2` and `Stream.map/2`?<p>They have the same (or equivalent) typespecs:</p> <pre><code>each(Enumerable.t(), (element() -&gt; t...
72,330,589
Can I generate a map that shows a particular row was in a particular group in SQLite?<p>Say I have the following data:</p> <pre><code>+--------+-------+ | Group | Data | +--------+-------+ | 1 | row 1 | | 1 | row 2 | | 1 | row 3 | | 20 | row 1 | | 20 | row 3 | | 10 | row 1 | | 10 | row ...
<p>To find the missing values, first thing is to prepare a dataset which have all possible combination. You can achieve that using <code>CROSS JOIN</code>.</p> <p>Once you have that DataSet, compare it with the actual DataSet.</p> <p>Considering the Order by is done in the Grp column, you can achieve it using below.</p...
Can I generate a map that shows a particular row was in a particular group in SQLite?
sql|sqlite
0
67
2
72,335,160
72,335,160
4
true
2022-05-21T14:46:36.530Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Can I generate a map that shows a particular row was in a particular group in SQLite?<p>Say I have the following data:</p> <pre><code>+--------+-------+ | Gr...
72,286,078
How to substitute the concrete substring of a string in the string's list?<p>I have the following list of strings:</p> <pre><code>list_of_str = ['Notification message', 'Warning message', 'This is the |xxx - show| message.', 'Notification message is defined by |xxx - show|', 'Notification message'] </code></pre> <p>How...
<p>Reverse iteration, find and replace:</p> <pre><code>for i, s in enumerate(reversed(list_of_str), 1): if 'show|' in s: list_of_str[-i] = s.replace('show|', 'Placeholder|') break </code></pre>
How to substitute the concrete substring of a string in the string's list?
python|string
-1
67
3
72,286,171
72,286,171
5
true
2022-05-18T08:55:59.140Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to substitute the concrete substring of a string in the string's list?<p>I have the following list of strings:</p> <pre><code>list_of_str = ['Notificatio...
72,316,393
(Windows)Can I get the program to be changed or be stopped while it is running?<p>I am now writing a win32 program in C++. I want to show my running process on the window, just like time is flowing.</p> <p>For example, this code</p> <pre><code>int a=0; for(int i=0;i&lt;10;i++) { a++;//The change in &quot;a&quot; can ...
<p>You want to create a timer with <a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-settimer" rel="noreferrer">SetTimer</a>. Then watch for the <a href="https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-timer" rel="noreferrer">WM_TIMER</a> messages and update the screen then. This i...
(Windows)Can I get the program to be changed or be stopped while it is running?
c++|winapi|interrupt
1
67
2
72,316,460
72,316,460
5
true
2022-05-20T09:12:57.777Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: (Windows)Can I get the program to be changed or be stopped while it is running?<p>I am now writing a win32 program in C++. I want to show my running process ...
72,351,470
Why elements of BTreeMap<K, V> can be got by smth of different type than K, but it's not the case with Vec and binary_search?<p>I have a question to ask. Let's take a look at the following code:</p> <pre><code>use std::collection::BTreeMap; fn main() { let mut hm: BTreeMap&lt;String, String&gt; = BTreeMap::new(); ...
<p>There was <a href="https://github.com/rust-lang/rust/pull/41590" rel="noreferrer">an attempt</a> to change the signature of <code>binary_search</code> to support accepting a borrowed version of the value but <a href="https://github.com/rust-lang/rust/pull/41590#issuecomment-304115519" rel="noreferrer">it broke stuff...
Why elements of BTreeMap<K, V> can be got by smth of different type than K, but it's not the case with Vec and binary_search?
rust
2
67
1
72,351,809
72,351,809
5
true
2022-05-23T15:53:52.960Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Why elements of BTreeMap<K, V> can be got by smth of different type than K, but it's not the case with Vec and binary_search?<p>I have a question to ask. Let...
72,371,935
How to make a Java object of generic type, in Clojure?<p>Clojure <code>empty</code> changes types of Java collections. For example a <code>JavaParser</code> <code>MethodCallExpr</code> object <code>mce</code>,</p> <pre class="lang-clj prettyprint-override"><code>(type (.getArguments mce)) ;; =&gt; com.github.javaparser...
<p><code>empty</code> works only for classes that implement <code>clojure.lang.IPersistentCollection</code>. It won't work for anything else.</p> <p>In your case, if you know that the type is <code>NodeList</code>, just construct it yourself via Java interop. If you don't know that it's <code>NodeList</code> in some ge...
How to make a Java object of generic type, in Clojure?
clojure|javaparser
0
67
1
72,372,191
72,372,191
5
true
2022-05-25T04:23:57.543Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to make a Java object of generic type, in Clojure?<p>Clojure <code>empty</code> changes types of Java collections. For example a <code>JavaParser</code> ...
72,249,054
Cannot use '<>' due to non-private method which doesn't override or implement a method from a supertype<p>I have the below specified behavior.</p> <pre><code>interface ValueEditorPopupView&lt;T&gt; { void setValue(T value); void setApplyEnabled(); } abstract class ValueEditorPopup&lt;T&gt; implements ValueEditorP...
<p>This is by design and is specified in <a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-15.html#jls-15.9.5" rel="noreferrer">JLS §15.9.5</a>:</p> <blockquote> <p>If a class instance creation expression with a <code>ClassBody</code> uses a diamond (<code>&lt;&gt;</code>) for the type arguments of the cl...
Cannot use '<>' due to non-private method which doesn't override or implement a method from a supertype
java|generics
5
67
1
72,249,602
72,249,602
6
true
2022-05-15T14:14:54.433Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Cannot use '<>' due to non-private method which doesn't override or implement a method from a supertype<p>I have the below specified behavior.</p> <pre><code...
72,361,600
Getting blocked by CORS policy error despite adding appropriate headers<p>I am trying to send an HTTP request from my React app to my local server on a different port. However, every time I send a POST HTTP request, this error happens:</p> <p><a href="https://i.stack.imgur.com/J346p.png" rel="nofollow noreferrer">CORS ...
<p>You need to use the router.</p> <pre class="lang-js prettyprint-override"><code>app.use('/', router); </code></pre>
Getting blocked by CORS policy error despite adding appropriate headers
reactjs|express|cors
-1
67
1
72,362,047
72,362,047
-1
true
2022-05-24T10:52:20.330Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Getting blocked by CORS policy error despite adding appropriate headers<p>I am trying to send an HTTP request from my React app to my local server on a diffe...
72,357,193
How do I check if an object's children (and their children, infinite levels) are undefined?<p>Given the below object, I want to create a function that can determine if any field in the tree has an undefined values. I need the function to traverse infinitely (or walk this tree of objects) when checking for undefined.</p...
<p>You can check the object tree recursively and do whatever you want with <code>undefined</code> keys.</p> <pre><code>function fn(object) { if (typeof object === 'undefined') { // do something return; } for (let key in object) { if (typeof object[key] === 'undefined') { // do somethin...
How do I check if an object's children (and their children, infinite levels) are undefined?
javascript|node.js
-1
67
1
72,367,465
72,367,465
-1
true
2022-05-24T04:23:38.100Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How do I check if an object's children (and their children, infinite levels) are undefined?<p>Given the below object, I want to create a function that can de...
72,858,829
(HTML, CSS) text-align : center is not working on <div><p>I used text-align:center to center the three divisions, but they are all aligned on the left. I was told that because these three elements are all block, so they wouldn't center.However, I tried to add display:inline-block, but when I inspected the page, it stil...
<p>You can do it in multiple ways, the simplest and the <strong>first way</strong> is to write a CSS like:</p> <pre><code>div { text-align: center } </code></pre> <p>The <strong>second way</strong> if you want to use a inline CSS in your HTML code itself:</p> <pre><code>&lt;div style=&quot;text-align:center&quot;&gt; ...
(HTML, CSS) text-align : center is not working on <div>
html|css
1
67
2
72,859,100
72,859,100
1
true
2022-07-04T15:10:25.410Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: (HTML, CSS) text-align : center is not working on <div><p>I used text-align:center to center the three divisions, but they are all aligned on the left. I was...
72,967,240
SOLVED - How to find values between and count it<p>I want to build a panel where the admin can display the total page views. I do save timestamps for each click when a user change page or refresh it.</p> <p>I want to find how many user viewed at the date by using timestamp.</p> <pre><code>$Today = time(); $EightDaysSe...
<p>Considering your fieldname is <code>Date</code> you can use the database for calculation and filtering.</p> <p>This query will create a value <code>diff</code> in days and the WHERE clause will find all entries up to 7 days. The results are sorted by <code>diff</code>.</p> <pre><code>$Query = $db-&gt;prepare('SELECT...
SOLVED - How to find values between and count it
php
0
67
1
72,967,532
72,967,532
1
true
2022-07-13T13:34:46.560Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: SOLVED - How to find values between and count it<p>I want to build a panel where the admin can display the total page views. I do save timestamps for each cl...
72,947,692
Next js - How to Update or Clear/Reset const array value?<p>I am Beginner to fronted development.I am working on next js project.</p> <p>My task is to display result on form submit, Which i have done. Next task is to reset form and also clear/reset search result on button click. I am not able to find the solution, how ...
<p>I will assume the data returned from your API is an array of objects, please try this and let me know if that works:</p> <pre><code>export default function Home() { const [userSearchResults, setUserSearchResults] = useState([]); const validationSchema = Yup.object().shape({ searchQuery: Yup.string().required...
Next js - How to Update or Clear/Reset const array value?
reactjs|next.js
0
67
1
72,948,764
72,948,764
1
true
2022-07-12T06:04:11.500Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Next js - How to Update or Clear/Reset const array value?<p>I am Beginner to fronted development.I am working on next js project.</p> <p>My task is to displa...
72,939,409
database context manager and query execution exception handling<p>I would like to connect to a database, execute a query inside a context manager and handle the exceptions</p> <pre><code>import pyodbc class db_connection(object): def __init__(self, connection_string): self.connection_string = connection_s...
<p>The pythonic way would be to close in the <em>_ exit _</em> statement the resource you opened in the <em>_ enter _</em> statement (to prevent memory leaks etc). But connections are meant to be <strong>reused</strong> so we don't need to close them everytime. If you want to reuse connections try researching how conne...
database context manager and query execution exception handling
python|database|contextmanager
0
67
2
72,948,845
72,948,845
1
true
2022-07-11T13:31:32.080Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: database context manager and query execution exception handling<p>I would like to connect to a database, execute a query inside a context manager and handle ...
72,780,509
Convert a directory of JSON files to one CSV file with a Py loop<p>I have a directory with hundreds of JSON files, and would like to convert and merge them into one CSV file.</p> <p>I found <a href="https://stackoverflow.com/questions/1871524/how-can-i-convert-json-to-csv">this</a> question. One answer explains how to ...
<p>You can accumulate all data frames in a list and use <strong>pd.concat()</strong> to merge them into one huge dataframe:</p> <pre><code>import pandas as pd import os dir1 = 'jsfiles' dfs = [] fileList = os.listdir(dir1) for ffile in fileList: with open(os.path.join(dir1, ffile), encoding='utf-8') as inputfile: ...
Convert a directory of JSON files to one CSV file with a Py loop
python|json|pandas|csv
0
67
1
72,781,011
72,781,011
1
true
2022-06-28T03:42:17.827Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Convert a directory of JSON files to one CSV file with a Py loop<p>I have a directory with hundreds of JSON files, and would like to convert and merge them i...
72,806,519
Swift 5: Add UITableView with dynamic prototype cells in XIB<p>I am trying to add a UITableView element to a XIB which I want to present as a sheet from the bottom but I only get the option of static cells. Isn't it possible to have dynamic tables within a XIB or am I missing something?</p> <p><a href="https://i.stack....
<p>A prototype cell is a feature of a table view <em>controller</em>, not a table view. You would need to have a table view controller object in your XIB in order to have a prototype cell. Having a table view controller in a XIB is a perfectly legal thing to do, though it is rarely done nowadays, because storyboards ar...
Swift 5: Add UITableView with dynamic prototype cells in XIB
ios|swift|uitableview
0
67
2
72,850,362
72,850,362
1
true
2022-06-29T18:59:23.330Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Swift 5: Add UITableView with dynamic prototype cells in XIB<p>I am trying to add a UITableView element to a XIB which I want to present as a sheet from the ...
72,906,548
Argument or block definition required<p>I am using <code>kubernetes_network_policy</code> resource. I have around ten network poilices and each of them is different. I want the <code>from cidr</code> block to be executed only when I pass a value to <code>ingress_to_cidr</code>. When I am trying execute <code>terragrunt...
<p>You can <strong>nest dynamic blocks</strong>. So I think in your case it should be:</p> <pre><code>resource &quot;kubernetes_network_policy&quot; &quot;example-policy&quot; { for_each = var.inputs metadata { name = each.value.name namespace = each.value.namespace } spec { pod_selector { ...
Argument or block definition required
terraform|terraform0.12+|terraform-provider-kubernetes
1
67
1
72,906,603
72,906,603
1
true
2022-07-08T04:10:57.347Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Argument or block definition required<p>I am using <code>kubernetes_network_policy</code> resource. I have around ten network poilices and each of them is di...
72,917,171
How to count the number of specific objects in a Django model?<p>I have a Django model called <code>User</code> and would like to count how many items are within the <code>following</code> object.</p> <pre><code>class User(AbstractUser): following = models.ManyToManyField(&quot;self&quot;, related_name=&quot;follow...
<p>You can count the total number of following relations with:</p> <pre><code>User.following<strong>.through.objects</strong>.count() # total number of following relations</code></pre> <p>If you want to add an extra attribute to the <code>User</code> objects with the number of <code>following</code>s <em>per</em> <cod...
How to count the number of specific objects in a Django model?
django|django-models
2
67
2
72,917,196
72,917,196
1
true
2022-07-08T21:29:08.707Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: How to count the number of specific objects in a Django model?<p>I have a Django model called <code>User</code> and would like to count how many items are wi...
72,773,647
Converting an unsigned char array to jstring<p>I'm having issues trying to convert an unsigned char array to jstring.</p> <p>The context is I'm using a shared c library from Java. So I'm implementing a JNI c++ file. The function I use from the library returs a <code>unsigned char* num_carte_transcode</code></p> <p>And ...
<p>The string passed to <code>NewStringUTF</code> must be null-terminated. The string you're passing, however, is not null-terminated, and it looks like there's some garbage at the end of the string before the first null.</p> <p>I suggest creating a larger array, and adding a null terminator at the end:</p> <pre><code>...
Converting an unsigned char array to jstring
java|c++|java-native-interface
0
67
1
72,774,212
72,774,212
2
true
2022-06-27T14:19:40.700Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Converting an unsigned char array to jstring<p>I'm having issues trying to convert an unsigned char array to jstring.</p> <p>The context is I'm using a share...
72,777,580
Counting how many times each letter appears in the string<p>I'm trying to count how many times each letter appears in the string and then display it in a list eg. The word &quot;hello&quot; would be: {h:1, e:1, l:2, o:2} This is my code.</p> <pre><code> text = input() dict = {} for k in range(len(text))...
<p>You can use the following code to count letter frequencies:</p> <pre><code>d = {} for letter in text: d[letter] = d.get(letter, 0) + 1 print(d) </code></pre>
Counting how many times each letter appears in the string
python
1
67
2
72,777,612
72,777,612
2
true
2022-06-27T19:47:26.367Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Counting how many times each letter appears in the string<p>I'm trying to count how many times each letter appears in the string and then display it in a lis...
72,785,494
Prevent double quotes in lists of list when reading and writing csv files in pandas dataframe<p>Before reading / writing into csv file, when performing the command below on the original pandas dataframe</p> <pre><code> user 0 [mary, jane] 1 [alex, andrew] </code></pre> <p>When doing the command -&gt;</p> <pre><co...
<p>While writing into csv, following code can be used in order to remove double quotes. This parameter is an inbuilt feature of df.to_csv()</p> <pre><code>df.to_csv('users.csv',index=False,header= False,sep = ',', quoting = csv.QUOTE_NONE, escapechar = ' ') </code></pre> <p>Hope it helps !</p>
Prevent double quotes in lists of list when reading and writing csv files in pandas dataframe
python|python-3.x|pandas|dataframe|read-write
0
67
1
72,785,571
72,785,571
2
true
2022-06-28T11:19:27.197Z
Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions. Stackoverflow question: Prevent double quotes in lists of list when reading and writing csv files in pandas dataframe<p>Before reading / writing into csv file, when performing the c...